Home Reference Source Repository
import Span from 'opentracing/src/span.js'
public class | source

Span

Span represents a logical unit of work as part of a broader Trace. Examples of span might include remote procedure calls or a in-process function calls to sub-components. A Trace has a single, top-level "root" Span that in turn may have zero or more child Spans, which in turn may have children.

Constructor Summary

Public Constructor
public

constructor(imp: *)

Constructs a new Span object.

Method Summary

Public Methods
public

addTags(keyValuePairs: *): [type]

Adds the given key value pairs to the set of span tags.

public

finish(finishTime: Number)

Indicates that the unit of work represented by the span is complete or has otherwise been terminated.

public

Returns the value for the given baggage item key.

public

imp(): *

Returns the Span implementation object.

public

log(fields: object): *

Explicitly create a log record associated with the span.

public

logEvent(eventName: string, payload: object): *

Logs a event with an optional payload.

public

setBaggageItem(key: string, value: string): *

Set an arbitrary key-value string pair that will be carried along the full path of a trace.

public

Sets the string name for the logical operation this span represents.

public

setTag(key: string, value: any): *

Adds a single tag to the span.

public

Returns the Tracer object used to create this Span.

Public Constructors

public constructor(imp: *) source

Constructs a new Span object. This method should not be called directly.

Params:

NameTypeAttributeDescription
imp *

Public Methods

public addTags(keyValuePairs: *): [type] source

Adds the given key value pairs to the set of span tags.

Multiple calls to addTags() results in the tags being the superset of all calls.

The behavior of setting the same key multiple times on the same span is undefined.

The supported type of the values is implementation-dependent. Implementations are expected to safely handle all types of values but may choose to ignore unrecognized / unhandle-able values (e.g. objects with cyclic references, function objects).

Params:

NameTypeAttributeDescription
keyValuePairs *

Return:

[type]

[description]

public finish(finishTime: Number) source

Indicates that the unit of work represented by the span is complete or has otherwise been terminated.

All Span objects must have finish() called on them before they are reported to the backend implementation.

Once finish() is called on a Span object, the behavior of all methods on the object is considered undefined.

Params:

NameTypeAttributeDescription
finishTime Number

Optional finish time in milliseconds as a Unix timestamp. Decimal values are supported for timestamps with sub-millisecond accuracy. If not specified, the current time (as defined by the implementation) will be used.

public getBaggageItem(key: string): string source

Returns the value for the given baggage item key.

Params:

NameTypeAttributeDescription
key string

The key for the given trace attribute.

Return:

string

String value for the given key, or undefined if the key does not correspond to a set trace attribute.

public imp(): * source

Returns the Span implementation object. The returned object is by its nature entirely implementation-dependent.

Return:

*

public log(fields: object): * source

Explicitly create a log record associated with the span.

Params:

NameTypeAttributeDescription
fields object

object containing the log record properties

fields.timestamp number
  • optional

optional field specifying the timestamp in milliseconds as a Unix timestamp. Fractional values are allowed so that timestamps with sub-millisecond accuracy can be represented. If not specified, the implementation is expected to use it's notion of the current time of the call.

fields.event string
  • optional

the event name

fields.payload object
  • optional

an arbitrary structured payload. It is implementation-dependent how this will be processed.

Return:

*

public logEvent(eventName: string, payload: object): * source

Logs a event with an optional payload.

Params:

NameTypeAttributeDescription
eventName string

string associated with the log record

payload object
  • optional

arbitrary payload object associated with the log record.

Return:

*

public setBaggageItem(key: string, value: string): * source

Set an arbitrary key-value string pair that will be carried along the full path of a trace.

All spans created as children of this span will inherit the baggage items of this span.

Baggage items are copied between all spans, both in-process and across distributed requests, therefore this feature should be used with care to ensure undue overhead is not incurred.

Keys are case insensitive and must match the regular expresssion [a-z0-9][-a-z0-9]*.

Params:

NameTypeAttributeDescription
key string
value string

Return:

*

public setOperationName(name: string): * source

Sets the string name for the logical operation this span represents.

Params:

NameTypeAttributeDescription
name string

Return:

*

public setTag(key: string, value: any): * source

Adds a single tag to the span. See AddTags() for details.

Params:

NameTypeAttributeDescription
key string
value any

Return:

*

public tracer(): Tracer source

Returns the Tracer object used to create this Span.

Return:

Tracer