MediaWiki master
|
Represents an OpenTelemetry span, i.e. More...
Inherits Wikimedia\Telemetry\SpanInterface.
Public Member Functions | ||||
__construct (Clock $clock, TracerState $tracerState, SpanContext $context) | ||||
__destruct () | ||||
activate () | ||||
Make this span the active span.This will cause any spans started without specifying an explicit parent to automatically become children of this span, for as long as it remains active.Activated spans form a stack; the most recently activated span is the active span.Long-running synchronous operations are good candidates for activation, especially if they will have other children spans created by code that is not explicitly aware of the parent span. For example, a MediaWiki EntryPoint might activate a span at the start of the request. Or a large unit of work (like wikitext parsing) might activate their own span, so that all database queries and other operations that occur during that work are automatically made descendants.
| ||||
deactivate () | ||||
Deactivate this span.Spans will also automatically be deactivated when they go out of scope.
| ||||
end (?int $epochNanos=null) | ||||
End this span, optionally specifying an override for its end time.Spans will also automatically be ended shortly after they go out of scope, but calling end() yourself is a good way to ensure the end timestamp is accurate.
| ||||
getContext () | ||||
Get the context holding data for this span.
| ||||
setAttributes (array $attributes) | ||||
Set attributes (arbitrary metadata) for this span.Any existing attributes with the same keys will be overwritten. Attributes with a null value will be ignored during export.These attributes will be attached to the span and will be searchable in the trace viewer.When deciding on the set of attributes to register as well as their naming, consider following Semantic Conventions where applicable.
| ||||
setSpanKind (int $spanKind) | ||||
Set the kind of this span, which describes how it relates to its parent and children within the overarching trace.
| ||||
setSpanStatus (int $status) | ||||
Set the status of this span.By default this is SPAN_STATUS_UNSET.
| ||||
start (?int $epochNanos=null) | ||||
Start this span, optionally specifying an override for its start time.
| ||||
Additional Inherited Members | |
![]() | |
const | SPAN_KIND_CLIENT = 3 |
Indicates that the span describes a request to some remote service. | |
const | SPAN_KIND_CONSUMER = 5 |
Indicates that the span describes a child of an asynchronous SpanInterface::SPAN_KIND_PRODUCER request. | |
const | SPAN_KIND_INTERNAL = 1 |
Default value. | |
const | SPAN_KIND_PRODUCER = 4 |
Indicates that the span describes the initiators of an asynchronous request. | |
const | SPAN_KIND_SERVER = 2 |
Indicates that the span covers server-side handling of a synchronous RPC or other incoming request from a remote client. | |
const | SPAN_STATUS_ERROR = 2 |
Indicates that the operation represented by this span failed. | |
const | SPAN_STATUS_OK = 1 |
Indicates that the operation represented by this span was successful. | |
const | SPAN_STATUS_UNSET = 0 |
Default value. | |
Represents an OpenTelemetry span, i.e.
a single operation within a trace.
Wikimedia\Telemetry\Span::__construct | ( | Clock | $clock, |
TracerState | $tracerState, | ||
SpanContext | $context ) |
Wikimedia\Telemetry\Span::__destruct | ( | ) |
Definition at line 30 of file Span.php.
References Wikimedia\Telemetry\Span\deactivate(), and Wikimedia\Telemetry\Span\end().
Wikimedia\Telemetry\Span::activate | ( | ) |
Make this span the active span.This will cause any spans started without specifying an explicit parent to automatically become children of this span, for as long as it remains active.Activated spans form a stack; the most recently activated span is the active span.Long-running synchronous operations are good candidates for activation, especially if they will have other children spans created by code that is not explicitly aware of the parent span. For example, a MediaWiki EntryPoint might activate a span at the start of the request. Or a large unit of work (like wikitext parsing) might activate their own span, so that all database queries and other operations that occur during that work are automatically made descendants.
Implements Wikimedia\Telemetry\SpanInterface.
Wikimedia\Telemetry\Span::deactivate | ( | ) |
Deactivate this span.Spans will also automatically be deactivated when they go out of scope.
Implements Wikimedia\Telemetry\SpanInterface.
Definition at line 95 of file Span.php.
Referenced by Wikimedia\Telemetry\Span\__destruct().
Wikimedia\Telemetry\Span::end | ( | ?int | $epochNanos = null | ) |
End this span, optionally specifying an override for its end time.Spans will also automatically be ended shortly after they go out of scope, but calling end() yourself is a good way to ensure the end timestamp is accurate.
int | null | $epochNanos | The end time to use, or null to use the current time. |
Implements Wikimedia\Telemetry\SpanInterface.
Definition at line 74 of file Span.php.
Referenced by Wikimedia\Telemetry\Span\__destruct().
Wikimedia\Telemetry\Span::getContext | ( | ) |
Get the context holding data for this span.
Implements Wikimedia\Telemetry\SpanInterface.
Wikimedia\Telemetry\Span::setAttributes | ( | array | $attributes | ) |
Set attributes (arbitrary metadata) for this span.Any existing attributes with the same keys will be overwritten. Attributes with a null
value will be ignored during export.These attributes will be attached to the span and will be searchable in the trace viewer.When deciding on the set of attributes to register as well as their naming, consider following Semantic Conventions where applicable.
array | $attributes | key-value mapping of attribute names to values |
Implements Wikimedia\Telemetry\SpanInterface.
Wikimedia\Telemetry\Span::setSpanKind | ( | int | $spanKind | ) |
Set the kind of this span, which describes how it relates to its parent and children within the overarching trace.
int | $spanKind | One of the SpanInterface::SPAN_KIND_** constants |
Implements Wikimedia\Telemetry\SpanInterface.
Wikimedia\Telemetry\Span::setSpanStatus | ( | int | $status | ) |
Set the status of this span.By default this is SPAN_STATUS_UNSET.
int | $spanStatus | One of the SpanInterface::SPAN_STATUS_** constants |
Implements Wikimedia\Telemetry\SpanInterface.
Wikimedia\Telemetry\Span::start | ( | ?int | $epochNanos = null | ) |
Start this span, optionally specifying an override for its start time.
int | null | $epochNanos | The start time to use, or null to use the current time. |
Implements Wikimedia\Telemetry\SpanInterface.