MediaWiki master
Wikimedia\Telemetry\TracerState Class Reference

Holds shared telemetry state, such as finished span data buffered for export. More...

Public Member Functions

 activateSpan (SpanContext $spanContext)
 Make the given span the active span.
 
 addSpanContext (SpanContext $context)
 Add the given span to the list of finished spans.
 
 clearSpanContexts ()
 Clear the list of finished spans.
 
 deactivateSpan (SpanContext $spanContext)
 Deactivate the given span, if it was the active span.
 
 endRootSpan (int $spanStatus=SpanInterface::SPAN_STATUS_UNSET)
 End the root span associated with the current request or process.
 
 getActiveSpanContext ()
 Get the context of the currently active span, or null if no span is active.
 
 getSpanContexts ()
 Get the list of finished spans.
 
 setRootSpan (SpanInterface $rootSpan)
 Set the root span associated with the current request or process.
 

Static Public Member Functions

static destroyInstance ()
 Reset shared tracer state.
 
static getInstance ()
 Get or initialize the shared tracer state for the current process or web request.
 

Detailed Description

Holds shared telemetry state, such as finished span data buffered for export.

Since this data is tied to the lifetime of a given web request or process, this class is a singleton to avoid discarding data in the case of MediaWiki service container resets.

Since
1.43
Access: internal

Definition at line 16 of file TracerState.php.

Member Function Documentation

◆ activateSpan()

Wikimedia\Telemetry\TracerState::activateSpan ( SpanContext $spanContext)

Make the given span the active span.

Parameters
SpanContext$spanContextContext of the span to activate
Returns
void

Definition at line 90 of file TracerState.php.

◆ addSpanContext()

Wikimedia\Telemetry\TracerState::addSpanContext ( SpanContext $context)

Add the given span to the list of finished spans.

Parameters
SpanContext$context
Returns
void

Definition at line 66 of file TracerState.php.

◆ clearSpanContexts()

Wikimedia\Telemetry\TracerState::clearSpanContexts ( )

Clear the list of finished spans.

Definition at line 81 of file TracerState.php.

◆ deactivateSpan()

Wikimedia\Telemetry\TracerState::deactivateSpan ( SpanContext $spanContext)

Deactivate the given span, if it was the active span.

Parameters
SpanContext$spanContextContext of the span to deactivate
Returns
void

Definition at line 99 of file TracerState.php.

◆ destroyInstance()

static Wikimedia\Telemetry\TracerState::destroyInstance ( )
static

Reset shared tracer state.

Useful for testing.

Definition at line 52 of file TracerState.php.

◆ endRootSpan()

Wikimedia\Telemetry\TracerState::endRootSpan ( int $spanStatus = SpanInterface::SPAN_STATUS_UNSET)

End the root span associated with the current request or process.

Since
1.44
Parameters
int$spanStatusThe status of the root span. One of the SpanInterface::SPAN_STATUS_** constants.

Definition at line 139 of file TracerState.php.

◆ getActiveSpanContext()

Wikimedia\Telemetry\TracerState::getActiveSpanContext ( )

Get the context of the currently active span, or null if no span is active.

Returns
SpanContext|null

Definition at line 114 of file TracerState.php.

◆ getInstance()

static Wikimedia\Telemetry\TracerState::getInstance ( )
static

Get or initialize the shared tracer state for the current process or web request.

Definition at line 44 of file TracerState.php.

◆ getSpanContexts()

Wikimedia\Telemetry\TracerState::getSpanContexts ( )

Get the list of finished spans.

Returns
SpanContext[]

Definition at line 74 of file TracerState.php.

◆ setRootSpan()

Wikimedia\Telemetry\TracerState::setRootSpan ( SpanInterface $rootSpan)

Set the root span associated with the current request or process.

Since
1.44
Parameters
SpanInterface$rootSpanThe root span to set.
Exceptions
PreconditionExceptionIf a root span was already initialized for this request or process.

Definition at line 125 of file TracerState.php.


The documentation for this class was generated from the following file: