Optional version: stringOptional options: TracerOptionsPrivate Optional _delegatePrivate _getTry to get a tracer from the proxy tracer provider. If the proxy tracer provider has no delegate, return a noop tracer.
Private _providerReadonly nameOptional Readonly optionsOptional Readonly versionStarts a new Span and calls the given function passing it the created span as first argument. Additionally the new span gets set in context and this context is activated for the duration of the function call.
The name of the span
function called in the context of the span and receives the newly created span as an argument
Optional _context: Context | FOptional _fn: Freturn value of fn
const something = tracer.startActiveSpan('op', span => {
try {
do some work
span.setStatus({code: SpanStatusCode.OK});
return something;
} catch (err) {
span.setStatus({
code: SpanStatusCode.ERROR,
message: err.message,
});
throw err;
} finally {
span.end();
}
});
const span = tracer.startActiveSpan('op', span => {
try {
do some work
return span;
} catch (err) {
span.setStatus({
code: SpanStatusCode.ERROR,
message: err.message,
});
throw err;
}
});
do some more work
span.end();
Starts a new Span. Start the span without setting it on context.
This method do NOT modify the current Context.
The name of the span
Optional options: SpanOptionsSpanOptions used for span creation
Optional context: ContextContext to use to extract parent
Span The newly created span
const span = tracer.startSpan('op');
span.setAttribute('key', 'value');
span.end();
Proxy tracer provided by the proxy tracer provider