Return the current active span, if no trace provider is available null will be returned but when a trace provider is available a span instance will always be returned, even if there is no active span (in which case a non-recording span will be returned).
OptionalcreateNew: booleanOptional flag to create a non-recording span if no active span exists, defaults to true. When false, returns the existing active span or null without creating a non-recording span, which can improve performance when only checking if an active span exists.
The current active span or null if no trace provider is available or if createNew is false and no active span exists
Gets the current distributed trace active context for this instance
OptionalcreateNew: booleanOptional flag to create a new instance if one doesn't currently exist, defaults to true. By default this will use any located parent as defined by the IConfiguration.traceHdrMode configuration for each new instance created.
Get the current trace provider.
The current trace provider, or null if none is set
Set the current Active Span, if no trace provider is available the span will be not be set as the active span.
The span to set as the active span
An ISpanScope instance that provides the current scope, the span will always be the span passed in even when no trace provider is available
Sets the current distributed trace context for this instance if available
Start a new span with the given name and optional parent context.
Note: This method only creates and returns the span. It does not automatically set the span as the active trace context. Context management should be handled separately using setTraceCtx() if needed.
The name of the span
Optionaloptions: IOTelSpanOptionsOptions for creating the span (kind, attributes, startTime)
Optionalparent: IDistributedTraceContextOptional parent context. If not provided, uses the current active trace context
A new span instance, or null if no trace provider is available
Interface for OpenTelemetry trace operations. This interface provides span creation, context management, and trace provider operations that are common across different SDK implementations (Core, AISKU, etc.).
Since
3.4.0