TraceHeader

Defined in: aa-sdk/core/src/utils/traceHeader.ts:31

Some tools that are useful when dealing with the values of the trace header. Follows the W3C trace context standard.

See

https://www.w3.org/TR/trace-context/

Constructors

Constructor

1new TraceHeader(
2 traceId,
3 parentId,
4 traceFlags,
5 traceState): TraceHeader;

Defined in: aa-sdk/core/src/utils/traceHeader.ts:45

Initializes a new instance with the provided trace identifiers and state information.

Parameters

ParameterTypeDescription

traceId

string

The unique identifier for the trace

parentId

string

The identifier of the parent trace

traceFlags

string

Flags containing trace-related options

traceState

Record<string, string>

The trace state information for additional trace context

Returns

TraceHeader

Properties

PropertyType

parentId

string

traceFlags

string

traceId

string

traceState

Record<string, string>

Methods

toTraceHeader()

1toTraceHeader(): object;

Defined in: aa-sdk/core/src/utils/traceHeader.ts:123

Should be able to convert the trace header to the format that is used in the headers of an http request

Example

Returns

object

The trace header in the format of a record, used in our http client

NameType

traceparent

`00-${string}-${string}-${string}`

tracestate

string


withEvent()

1withEvent(eventName): TraceHeader;

Defined in: aa-sdk/core/src/utils/traceHeader.ts:145

Should be able to create a new trace header with a new event in the trace state, as the key of the eventName as breadcrumbs appending onto previous breadcrumbs with the - infix if exists. And the trace parent gets updated as according to the docs

Example

Parameters

ParameterTypeDescription

eventName

string

The key of the new event

Returns

TraceHeader

The new trace header


default()

1static default(): TraceHeader;

Defined in: aa-sdk/core/src/utils/traceHeader.ts:66

Creating a default trace id that is a random setup for both trace id and parent id

Example

Returns

TraceHeader

A default trace header


fromTraceHeader()

1static fromTraceHeader(headers): undefined | TraceHeader;

Defined in: aa-sdk/core/src/utils/traceHeader.ts:84

Should be able to consume a trace header from the headers of an http request

Example

Parameters

ParameterTypeDescription

headers

Record<string, string>

The headers from the http request

Returns

undefined | TraceHeader

The trace header object, or nothing if not found