Interface IDistributedTraceContext

interface IDistributedTraceContext {
    getName(): string;
    getSpanId(): string;
    getTraceFlags(): number;
    getTraceId(): string;
    isRemote: boolean;
    pageName: string;
    parentCtx?: IDistributedTraceContext;
    setName(pageName: string): void;
    setSpanId(newValue: string): void;
    setTraceFlags(newValue?: number): void;
    setTraceId(newValue: string): void;
    spanId: string;
    traceFlags?: number;
    traceId: string;
    traceState: IW3cTraceState;
}

Hierarchy

  • IDistributedTraceInit
    • IDistributedTraceContext

Properties

isRemote: boolean

Returns true if the current context was initialized (propagated) from a remote parent.

3.4.0

false

True if the context was propagated from a remote parent

pageName: string

Returns the current name of the page

This function updates the current context only, to update the name of the current and ALL parent contexts, use the setName method.

undefined

3.4.0

Provides access to the parent context of the current context.

This is a read-only property, you cannot modify the parent context directly, you can only modify the current context. If you need to modify the parent context, you need to do it through the current context using the setTraceId, setSpanId, setTraceFlags and setName methods.

null

3.4.0

spanId: string

The ID of the Span. It is globally unique with practically sufficient probability by being made as 8 randomly generated bytes, encoded as a 16 lowercase hex characters corresponding to 64 bits. If you update this value, it will only update for the current context, not the parent context.

If you update this value, it will only update for the current context, not the parent context, if you need to update the current and ALL parent contexts, use the setSpanId method.

3.4.0

traceFlags?: number

Trace flags to propagate.

It is represented as 1 byte (bitmap). Bit to represent whether trace is sampled or not. When set, the least significant bit documents that the caller may have recorded trace data. A caller who does not record trace data out-of-band leaves this flag unset.

see eW3CTraceFlags for valid flag values.

If you update this value, it will only update for the current context, not the parent context, if you need to update the current and ALL parent contexts, use the setTraceFlags method.

3.4.0

traceId: string

The current ID of the trace that this span belongs to. It is worldwide unique with practically sufficient probability by being made as 16 randomly generated bytes, encoded as a 32 lowercase hex characters corresponding to 128 bits.

It is NOT recommended that you dynamically change this value after creation and it is actively being used as this may affect anyone accessing this context (as a parent for instance). You should logically treat this as readonly after creation.

3.4.0

traceState: IW3cTraceState

Returns the current trace state which will be used to propgate context across different services. Updating (adding / removing keys) of the trace state will modify the current context.IOTelTraceState

Unlike the OpenTelemetry IOTelTraceState, this value is a mutable object, so you can modify it directly you do not need to reassign the new value to this property.

3.4.0

Methods

  • Returns the current name of the page

    Returns string

  • Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array. Also know as the parentId, used to link requests together

    Returns string

  • An integer representation of the W3C TraceContext trace-flags.

    Returns number

  • Returns the unique identifier for a trace. All requests / spans from the same trace share the same traceId. Must be read from incoming headers or generated according to the W3C TraceContext specification, in a hex representation of 16-byte array. A.k.a. trace-id, TraceID or Distributed TraceID

    Returns string

  • Sets the current name of the page, also updates the name for any parent context. This is used to identify the page in the telemetry data.

    Parameters

    • pageName: string

      The name of the page

    Returns void

    This function updates the current and ALL parent contexts with the new name, to just update the name of the current context, use the pageName property.

    Use the pageName property to avoid the side effect of changing the page name of all parent contexts.

  • Self-generated 8-bytes identifier of the incoming request. Must be a hex representation of 8-byte array. Also know as the parentId, used to link requests together https://www.w3.org/TR/trace-context/#parent-id

    Parameters

    • newValue: string

      The spanId to set

    Returns void

    Sets the spanId for the current context AND all parent contexts, if you want to set the spanId for the current context only, use the spanId property.

    Use the spanId property to avoid the side effect of changing the spanId of all parent contexts.

  • Parameters

    • OptionalnewValue: number

      An integer representation of the W3C TraceContext trace-flags.

    Returns void

    Sets the trace flags for the current context and ALL parent contexts, if you want to set the trace flags for the current context only, use the traceFlags property.

    Use the traceFlags property to avoid the side effect of changing the traceFlags of all parent contexts.

  • Set the unique identifier for a trace. All requests / spans from the same trace share the same traceId. Must be conform to the W3C TraceContext specification, in a hex representation of 16-byte array. A.k.a. trace-id, TraceID or Distributed TraceID https://www.w3.org/TR/trace-context/#trace-id

    Parameters

    • newValue: string

      The traceId to set

    Returns void

    Sets the traceId for the current context AND all parent contexts, if you want to set the traceId for the current context only, use the traceId property.

    Use the traceId property to avoid the side effect of changing the traceId of all parent contexts.