Skip to main content

TracingStateinterface

Properties (20)

Property Type Default Required Description
addEvent⚓︎ ( name: string, attributesOrStartTime?: Attributes | TimeInput, startTime?: TimeInput ) => this x x
autoSetSuccessStatus⚓︎ boolean x x

autoSetSuccessStatus as resolved for this span (matching filter, span options, defaults): whether its status is set to OK when its callback completes with the status still UNSET. For code that ends the span itself, inside the callback - a span that has ended is past having its status set, so such code has to do what the manager would have done.

context⚓︎ Context x x x
enabled⚓︎ boolean x

If false, this is a placeholder object, and all its methods are no-ops, with the possible exception of getPropagationInfo() and injectPropagationInfo()

endTime⚓︎ Date x x x
getPropagationInfo⚓︎ () => PropagationInfo | null x

Gets the propagation info for the current span (see https://www.w3.org/TR/trace-context/#tracestate-field)

id⚓︎ string x x x
injectPropagationInfo⚓︎ (carrier: PropagationInfoCarrier & object) => void x

Sets a hidden property in the object that can be used to restore propagation information after serialization and deserialization (see withSpan 'propagationInfo' argument and Traces.extractPropagationInfo() method).

isRecording⚓︎ Span["isRecording"] x x
level⚓︎ keyof typeof SpanVerbosity x x
matchingFilter⚓︎ SpanFilter | null x x x
recordException⚓︎ Span["recordException"] x x
source⚓︎ string x x
span⚓︎ Span x x x
spanContext⚓︎ () => ReturnType<Span["spanContext"]> | undefined x

The context of the span - what a link to it is made with - or undefined when there is no span (disabled by a filter, telemetry off). A span recorded by the BufferingTracesManager has a synthetic one until it is replayed, which the replay rewrites in the links made with it.

startTime⚓︎ Date x x x
status⚓︎ SpanStatus x x x
traceId⚓︎ string x x x
updateName⚓︎ (name: string) => this x x

3 Methods

addData()⚓︎

(level: SpanVerbosity | keyof typeof SpanVerbosity, data: object | (() => object)) => void

Adds data to the span - as attributes, flattened - when the span records the given verbosity level: a level at or above the span's own level.

data given as a function is computed lazily: the function is called only when the span records the level, once, so a value that is expensive to work out costs nothing on a span that does not record it - or on a disabled span, which never calls it. A function that throws is handled like any other error inside the library: swallowed (and logged) in errorlessMode, thrown to the caller otherwise; one that returns nothing adds nothing.

On a span of the startup span buffer (BufferingTracesManager) the level is not known yet: the function is kept and called when the span is replayed into the real manager - once, and only if the span records the level - so it should not depend on state that changes in the meantime. A function that throws at the replay is logged, and its data left out.

Parameters (2)

Name Type Required Description
level⚓︎ SpanVerbosity | keyof typeof SpanVerbosity x
data⚓︎ object | (() => object) x

end()⚓︎

() => void

Ends the current span. Same as endSpan().

endSpan()⚓︎

(endTime?: Date, allowDoubleEnd?: boolean) => Promise<void>

Parameters (2)

Name Type Required Description
endTime⚓︎ Date x x
allowDoubleEnd⚓︎ boolean x x