Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MockSpan

OpenTracing Span implementation designed for use in unit tests.

Hierarchy

Index

Constructors

constructor

Properties

_finishMs

_finishMs: number

Private _logs

_logs: Log[]

Private _mockTracer

_mockTracer: MockTracer

Private _operationName

_operationName: string

Private _startMs

_startMs: number

Optional _startStack

_startStack: undefined | string

Private _tags

_tags: object

Type declaration

  • [key: string]: any

Private _uuid

_uuid: string

Methods

Protected _addTags

  • _addTags(set: object): void

Protected _context

Protected _finish

  • _finish(finishTime?: undefined | number): void

Private _generateUUID

  • _generateUUID(): string

Protected _getBaggageItem

  • _getBaggageItem(key: string): string | undefined

Protected _log

  • _log(fields: object, timestamp?: undefined | number): void

Protected _setBaggageItem

  • _setBaggageItem(key: string, value: string): void

Protected _setOperationName

  • _setOperationName(name: string): void

Protected _tracer

addReference

addTags

  • addTags(keyValueMap: object): this
  • 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).

    Parameters

    • keyValueMap: object
      • [key: string]: any

    Returns this

    [description]

context

debug

durationMs

  • durationMs(): number

finish

  • finish(finishTime?: undefined | number): void
  • Sets the end timestamp and finalizes Span state.

    With the exception of calls to Span.context() (which are always allowed), finish() must be the last call made to any span instance, and to do otherwise leads to undefined behavior.

    Parameters

    • Optional finishTime: undefined | 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.
      

    Returns void

getBaggageItem

  • getBaggageItem(key: string): string | undefined
  • Returns the value for a baggage item given its key.

    Parameters

    • key: string
          The key for the given trace attribute.
      

    Returns string | undefined

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

log

  • log(keyValuePairs: object, timestamp?: undefined | number): this
  • Add a log record to this Span, optionally at a user-provided timestamp.

    For example:

    span.log({
        size: rpc.size(),  // numeric value
        URI: rpc.URI(),  // string value
        payload: rpc.payload(),  // Object value
        "keys can be arbitrary strings": rpc.foo(),
    });
    
    span.log({
        "error.description": someError.description(),
    }, someError.timestampMillis());
    

    Parameters

    • keyValuePairs: object
         An object mapping string keys to arbitrary value types. All
         Tracer implementations should support bool, string, and numeric
         value types, and some may also support Object values.
      
      • [key: string]: any
    • Optional timestamp: undefined | number
         An optional parameter specifying the timestamp in milliseconds
         since the Unix epoch. Fractional values are allowed so that
         timestamps with sub-millisecond accuracy can be represented. If
         not specified, the implementation is expected to use its notion
         of the current time of the call.
      

    Returns this

logEvent

  • logEvent(eventName: string, payload: any): void
  • DEPRECATED

    Parameters

    • eventName: string
    • payload: any

    Returns void

operationName

  • operationName(): string

setBaggageItem

  • setBaggageItem(key: string, value: string): this
  • Sets a key:value pair on this Span that also propagates to future children of the associated Span.

    setBaggageItem() enables powerful functionality given a full-stack opentracing integration (e.g., arbitrary application data from a web client can make it, transparently, all the way into the depths of a storage system), and with it some powerful costs: use this feature with care.

    IMPORTANT NOTE #1: setBaggageItem() will only propagate baggage items to future causal descendants of the associated Span.

    IMPORTANT NOTE #2: Use this thoughtfully and with care. Every key and value is copied into every local and remote child of the associated Span, and that can add up to a lot of network and cpu overhead.

    Parameters

    • key: string
    • value: string

    Returns this

setOperationName

  • setOperationName(name: string): this
  • Sets the string name for the logical operation this span represents.

    Parameters

    • name: string

    Returns this

setTag

  • setTag(key: string, value: any): this
  • Adds a single tag to the span. See addTags() for details.

    Parameters

    • key: string
    • value: any

    Returns this

tags

  • tags(): object

tracer

uuid

  • uuid(): string

Generated using TypeDoc