class ExtensionTracer implements TracerInterface, SpanEventHandlerInterface

This implementation of the TracerInterface utilizes the opencensus extension to manage span context. The opencensus extension augments user created spans and adds automatic tracing to several commonly desired events.

Traits

Trait which provides helper methods for converting DateTime input formats.

Methods

__construct(SpanContext $initialContext = null)

Create a new ExtensionTracer

mixed
inSpan(array $spanOptions, callable $callable, array $arguments = [])

Instrument a callable by creating a Span

startSpan(array $spanOptions)

Start a new Span. The start time is already set to the current time.

Scope
withSpan(Span $span)

Attaches the provided span as the current span and returns a Scope object which must be closed.

spans()

Return the spans collected.

addAttribute(string $attribute, string $value, array $options = [])

Add an attribute to the provided Span

addAnnotation(string $description, array $options = [])

Add an annotation to the provided Span

addLink(string $traceId, string $spanId, array $options = [])

Add a link to the provided Span

addMessageEvent(string $type, string $id, array $options = [])

Add an message event to the provided Span

spanContext()

Returns the current SpanContext

bool
enabled()

Whether or not this tracer is enabled.

attributeAdded(Span $span, string $attribute, string $value)

Triggers when an attribute is added to a span.

linkAdded(Span $span, Link $link)

Triggers when a link is added to a span.

timeEventAdded(Span $span, TimeEvent $timeEvent)

Triggers when a time event is added to a span.

Details

at line 51
__construct(SpanContext $initialContext = null)

Create a new ExtensionTracer

Parameters

SpanContext $initialContext [optional] The starting span context.

at line 67
mixed inSpan(array $spanOptions, callable $callable, array $arguments = [])

Instrument a callable by creating a Span

Parameters

array $spanOptions Options for the span. OpenCensus\Trace\Span::__construct()
callable $callable The callable to instrument.
array $arguments [optional] Arguments for the callable.

Return Value

mixed The result of the callable

at line 86
startSpan(array $spanOptions)

Start a new Span. The start time is already set to the current time.

Parameters

array $spanOptions [description]

at line 102
Scope withSpan(Span $span)

Attaches the provided span as the current span and returns a Scope object which must be closed.

Parameters

Span $span

Return Value

Scope

at line 137
SpanData[] spans()

Return the spans collected.

Return Value

SpanData[]

at line 156
addAttribute(string $attribute, string $value, array $options = [])

Add an attribute to the provided Span

Parameters

string $attribute
string $value
array $options [optional] Configuration options.

 @type Span $span The span to add the attribute to.

at line 174
addAnnotation(string $description, array $options = [])

Add an annotation to the provided Span

Parameters

string $description
array $options [optional] Configuration options.

 @type Span $span The span to add the annotation to.
 @type array $attributes Attributes for this annotation.
 @type \DateTimeInterface|int|float $time The time of this event.

Add a link to the provided Span

Parameters

string $traceId
string $spanId
array $options [optional] Configuration options.

 @type Span $span The span to add the link to.
 @type string $type The relationship of the current span relative to
       the linked span: child, parent, or unspecified.
 @type array $attributes Attributes for this annotation.
 @type \DateTimeInterface|int|float $time The time of this event.

at line 218
addMessageEvent(string $type, string $id, array $options = [])

Add an message event to the provided Span

Parameters

string $type
string $id
array $options [optional] Configuration options.

 @type Span $span The span to add the message event to.
 @type int $uncompressedSize The number of uncompressed bytes sent or
       received.
 @type int $compressedSize The number of compressed bytes sent or
       received. If missing assumed to be the same size as
       uncompressed.
 @type \DateTimeInterface|int|float $time The time of this event.

at line 231
SpanContext spanContext()

Returns the current SpanContext

Return Value

SpanContext

at line 246
bool enabled()

Whether or not this tracer is enabled.

Return Value

bool

at line 258
attributeAdded(Span $span, string $attribute, string $value)

Triggers when an attribute is added to a span.

Parameters

Span $span The span the attribute was added to
string $attribute The name of the attribute added
string $value The attribute value

at line 275
linkAdded(Span $span, Link $link)

Triggers when a link is added to a span.

Parameters

Span $span The span the link was added to
Link $link The link added to the span

at line 294
timeEventAdded(Span $span, TimeEvent $timeEvent)

Triggers when a time event is added to a span.

Parameters

Span $span The span the time event was added to
TimeEvent $timeEvent The time event added to the span