Interface for telemetry trace context.

Use appInsights.getTraceCtx() or appInsights.core.getTraceCtx() instead to get / set the current trace context. This returns an IDistributedTraceContext which supports distributed tracing and allows the core to manage the trace context.

To replace the entire trace context, use appInsights.core.setTraceCtx().

interface ITelemetryTrace {
    name?: string;
    parentID?: string;
    traceFlags?: number;
    traceID?: string;
}

Properties

name?: string

The operation/page name for this trace context.

Use IDistributedTraceContext.pageName instead via appInsights.getTraceCtx().pageName.

// Old (deprecated)
let name = context.telemetryTrace.name;

// New (recommended) - using the standard SKU (AISKU)
let traceCtx = appInsights.getTraceCtx();
let pageName = traceCtx.pageName;
traceCtx.pageName = "my-page";

// Or when using the core directly
let traceCtx = appInsights.core.getTraceCtx();
parentID?: string

The parent span ID. A 16 lowercase hex character string.

Use IDistributedTraceContext.spanId instead via appInsights.getTraceCtx().spanId.

// Old (deprecated)
let parentId = context.telemetryTrace.parentID;

// New (recommended) - using the standard SKU (AISKU)
let traceCtx = appInsights.getTraceCtx();
let spanId = traceCtx.spanId;
traceCtx.spanId = "0000000000000001";

// Or when using the core directly
let traceCtx = appInsights.core.getTraceCtx();
traceFlags?: number

An integer representation of the W3C TraceContext trace-flags.

Use IDistributedTraceContext.traceFlags instead via appInsights.getTraceCtx().traceFlags.

// Old (deprecated)
let flags = context.telemetryTrace.traceFlags;

// New (recommended) - using the standard SKU (AISKU)
let traceCtx = appInsights.getTraceCtx();
let flags = traceCtx.traceFlags;
traceCtx.traceFlags = 1; // sampled

// Or when using the core directly
let traceCtx = appInsights.core.getTraceCtx();
traceID?: string

The trace ID for this telemetry context. A 32 lowercase hex character string.

Use IDistributedTraceContext.traceId instead via appInsights.getTraceCtx().traceId.

// Old (deprecated)
let traceId = context.telemetryTrace.traceID;

// New (recommended) - using the standard SKU (AISKU)
let traceCtx = appInsights.getTraceCtx();
let traceId = traceCtx.traceId;
traceCtx.traceId = "00000000000000000000000000000001";

// Or when using the core directly
let traceCtx = appInsights.core.getTraceCtx();