interface TracerInterface

This interface allows you to use the null object pattern for your tracer.

Whenever you want to instrument your code, you don't need to check if the configured tracer is null or a real tracer.

Methods

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.

Details

at line 40
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 48
startSpan(array $spanOptions)

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

The newly created span is not attached to the current context.

Parameters

array $spanOptions [description]

at line 57
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 64
SpanData[] spans()

Return the spans collected.

Return Value

SpanData[]

at line 75
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 87
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 119
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 126
SpanContext spanContext()

Returns the current SpanContext

Return Value

SpanContext

at line 133
bool enabled()

Whether or not this tracer is enabled.

Return Value

bool