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.
https://www.w3.org/TR/trace-context/
new TraceHeader(
traceId,
parentId,
traceFlags,
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
| Parameter | Type | Description |
|---|---|---|
|
| The unique identifier for the trace |
|
| The identifier of the parent trace |
|
| Flags containing trace-related options |
|
| The trace state information for additional trace context |
Returns
TraceHeader
toTraceHeader(): object;Defined in: aa-sdk/core/src/utils/traceHeader.ts:126
Should be able to convert the trace header to the format that is used in the headers of an http request
Example
const traceHeader =
TraceHeader.fromTraceHeader(headers) || TraceHeader.default();
const headers = traceHeader.toTraceHeader();Returns
object
The trace header in the format of a record, used in our http client
| Name | Type |
|---|---|
|
|
|
|
withEvent(eventName): TraceHeader;Defined in: aa-sdk/core/src/utils/traceHeader.ts:149
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
const traceHeader =
TraceHeader.fromTraceHeader(headers) || TraceHeader.default();
const newTraceHeader = traceHeader.withEvent("newEvent");Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The key of the new event |
Returns
TraceHeader
The new trace header
static default(): TraceHeader;Defined in: aa-sdk/core/src/utils/traceHeader.ts:67
Creating a default trace id that is a random setup for both trace id and parent id
Example
const traceHeader =
TraceHeader.fromTraceHeader(headers) || TraceHeader.default();Returns
TraceHeader
A default trace header
static fromTraceHeader(headers): undefined | TraceHeader;Defined in: aa-sdk/core/src/utils/traceHeader.ts:86
Should be able to consume a trace header from the headers of an http request
Example
const traceHeader = TraceHeader.fromTraceHeader(headers);Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The headers from the http request |
Returns
undefined | TraceHeader
The trace header object, or nothing if not found