OpenTelemetry PHP

SpanTest extends MockeryTestCase
in package

Attributes
#[CoversClass]
\OpenTelemetry\SDK\Trace\Span::class

Table of Contents

Constants

ATTRIBUTES  = ['string_attribute' => 'some_string_value', 'float_attribute' => 3.14, 'bool_attribute' => false]
NEW_SPAN_NAME  = 'new_test_span'
SPAN_ID  = '46701247e52c2d1b'
SPAN_NAME  = 'test_span'
START_EPOCH  = 1000123789654
TRACE_ID  = 'e4a8d4e0d75c0702200af2882cb16c6b'

Properties

$expectedAttributes  : AttributesInterface
$idGenerator  : IdGeneratorInterface
$instrumentationScope  : InstrumentationScope
$link  : LinkInterface
$logWriter  : LogWriterInterface|MockObject
$parentSpanId  : string
$resource  : ResourceInfo
$spanContext  : SpanContextInterface
$spanId  : string
$spanProcessor  : MockInterface|SpanProcessorInterface
$testClock  : TestClock
$traceId  : string

Methods

createTestSpanWithAttributes()  : Span
homogeneousArrayProvider()  : array<string|int, mixed>
nonHomogeneousArrayProvider()  : array<string|int, mixed>
statusCodeProvider()  : array<string|int, mixed>
test_add_event()  : void
test_add_event_attribute_length()  : void
test_add_event_order_preserved()  : void
test_attribute_length()  : void
test_can_set_status_to_ok_after_error()  : void
test_dropping_attributes()  : void
test_dropping_attributes_provided_via_span_builder()  : void
test_dropping_events()  : void
test_dropping_links()  : void
test_end_span()  : void
test_end_twice()  : void
test_get_attribute()  : void
test_get_current_span_default()  : void
test_get_current_span_set_span()  : void
test_get_duration_active_span()  : void
test_get_duration_ended_span()  : void
test_get_instrumentation_scope_info()  : void
test_get_invalid_span()  : void
test_get_kind()  : void
test_get_span_default_context()  : void
test_get_span_explicit_context()  : void
test_get_start_epoch_nanos()  : void
test_in_process_context()  : void
test_nothing_changes_after_end()  : void
test_record_exception()  : void
test_record_exception_additional_attributes()  : void
test_set_attribute_drops_non_homogeneous_array()  : void
test_set_attribute_with_homogeneous_array()  : void
test_set_attributes()  : void
test_set_attributes_empty()  : void
test_set_attributes_merges_attributes()  : void
test_set_attributes_overrides_attribute()  : void
test_set_status_after_ok_is_ignored()  : void
test_start_span()  : void
test_to_span_data_active_span()  : void
test_to_span_data_child_span()  : void
test_to_span_data_ended_span()  : void
test_to_span_data_initial_attributes()  : void
test_to_span_data_is_immutable()  : void
test_to_span_data_kind()  : void
test_to_span_data_root_span()  : void
test_to_span_data_status()  : void
test_update_span_name()  : void
setUp()  : void
assertEvent()  : void
assertSpanData()  : void
createTestRootSpan()  : Span
createTestSpan()  : Span
expectDropped()  : void
spanDoWork()  : void

Constants

ATTRIBUTES

private mixed ATTRIBUTES = ['string_attribute' => 'some_string_value', 'float_attribute' => 3.14, 'bool_attribute' => false]

NEW_SPAN_NAME

private mixed NEW_SPAN_NAME = 'new_test_span'

SPAN_ID

private mixed SPAN_ID = '46701247e52c2d1b'

SPAN_NAME

private mixed SPAN_NAME = 'test_span'

START_EPOCH

private mixed START_EPOCH = 1000123789654

TRACE_ID

private mixed TRACE_ID = 'e4a8d4e0d75c0702200af2882cb16c6b'

Properties

$parentSpanId

private string $parentSpanId

Methods

createTestSpanWithAttributes()

public createTestSpanWithAttributes(array<string|int, mixed> $attributes) : Span
Parameters
$attributes : array<string|int, mixed>
Return values
Span

homogeneousArrayProvider()

public static homogeneousArrayProvider() : array<string|int, mixed>
Return values
array<string|int, mixed>

nonHomogeneousArrayProvider()

public static nonHomogeneousArrayProvider() : array<string|int, mixed>
Return values
array<string|int, mixed>

statusCodeProvider()

public static statusCodeProvider() : array<string|int, mixed>
Return values
array<string|int, mixed>

test_add_event()

public test_add_event() : void
Attributes
#[Group]
'trace-compliance'

test_add_event_attribute_length()

public test_add_event_attribute_length() : void

test_add_event_order_preserved()

public test_add_event_order_preserved() : void
Attributes
#[Group]
'trace-compliance'

test_attribute_length()

public test_attribute_length() : void

test_can_set_status_to_ok_after_error()

public test_can_set_status_to_ok_after_error() : void
Attributes
#[Group]
'trace-compliance'

test_dropping_attributes()

public test_dropping_attributes() : void
Attributes
#[Group]
'trace-compliance'

test_dropping_attributes_provided_via_span_builder()

public test_dropping_attributes_provided_via_span_builder() : void

test_dropping_events()

public test_dropping_events() : void
public test_dropping_links() : void

test_end_span()

public test_end_span() : void
Attributes
#[Group]
'trace-compliance'

test_end_twice()

public test_end_twice() : void

test_get_attribute()

public test_get_attribute() : void

test_get_current_span_default()

public test_get_current_span_default() : void

test_get_current_span_set_span()

public test_get_current_span_set_span() : void
Attributes
#[Group]
'trace-compliance'

test_get_duration_active_span()

public test_get_duration_active_span() : void

test_get_duration_ended_span()

public test_get_duration_ended_span() : void

test_get_instrumentation_scope_info()

public test_get_instrumentation_scope_info() : void

test_get_invalid_span()

public test_get_invalid_span() : void

test_get_kind()

public test_get_kind() : void

test_get_span_default_context()

public test_get_span_default_context() : void

test_get_span_explicit_context()

public test_get_span_explicit_context() : void

test_get_start_epoch_nanos()

public test_get_start_epoch_nanos() : void

test_in_process_context()

public test_in_process_context() : void

test_nothing_changes_after_end()

public test_nothing_changes_after_end() : void
Attributes
#[Group]
'trace-compliance'

test_record_exception()

public test_record_exception() : void
Attributes
#[Group]
'trace-compliance'

test_record_exception_additional_attributes()

public test_record_exception_additional_attributes() : void

test_set_attribute_drops_non_homogeneous_array()

public test_set_attribute_drops_non_homogeneous_array(array<string|int, mixed> $values) : void
Parameters
$values : array<string|int, mixed>
Attributes
#[DataProvider]
'nonHomogeneousArrayProvider'

test_set_attribute_with_homogeneous_array()

public test_set_attribute_with_homogeneous_array(array<string|int, mixed> $values) : void
Parameters
$values : array<string|int, mixed>
Attributes
#[DataProvider]
'homogeneousArrayProvider'

test_set_attributes()

public test_set_attributes() : void
Attributes
#[Group]
'trace-compliance'

test_set_attributes_empty()

public test_set_attributes_empty() : void

test_set_attributes_merges_attributes()

public test_set_attributes_merges_attributes() : void
Attributes
#[Group]
'trace-compliance'

test_set_attributes_overrides_attribute()

public test_set_attributes_overrides_attribute() : void

test_set_status_after_ok_is_ignored()

public test_set_status_after_ok_is_ignored(string $code) : void
Parameters
$code : string
Tags
psalm-param

StatusCode::STATUS_* $code

When span status is set to Ok it SHOULD be considered final and any further attempts to change it SHOULD be ignored.

Attributes
#[DataProvider]
'statusCodeProvider'
#[Group]
'trace-compliance'

test_start_span()

public test_start_span() : void
Attributes
#[Group]
'trace-compliance'

test_to_span_data_active_span()

public test_to_span_data_active_span() : void
Attributes
#[Group]
'trace-compliance'

test_to_span_data_child_span()

public test_to_span_data_child_span() : void

test_to_span_data_ended_span()

public test_to_span_data_ended_span() : void
Attributes
#[Group]
'trace-compliance'

test_to_span_data_initial_attributes()

public test_to_span_data_initial_attributes() : void

test_to_span_data_is_immutable()

public test_to_span_data_is_immutable() : void
Attributes
#[Group]
'trace-compliance'

test_to_span_data_kind()

public test_to_span_data_kind() : void

test_to_span_data_root_span()

public test_to_span_data_root_span() : void

test_to_span_data_status()

public test_to_span_data_status() : void

test_update_span_name()

public test_update_span_name() : void
Attributes
#[Group]
'trace-compliance'

assertSpanData()

private assertSpanData(SpanDataInterface $spanData, AttributesInterface $attributes, array<int, EventInterface$events, array<int, LinkInterface$links, string $spanName, int $startEpochNanos, int $endEpochNanos, string $status, bool $hasEnded) : void
Parameters
$spanData : SpanDataInterface
$attributes : AttributesInterface
$events : array<int, EventInterface>
$links : array<int, LinkInterface>
$spanName : string
$startEpochNanos : int
$endEpochNanos : int
$status : string
$hasEnded : bool
Tags
psalm-param

API\StatusCode::STATUS_* $status

createTestSpan()

private createTestSpan([int $kind = APISpanKind::KIND_INTERNAL ][, SpanLimits|null $spanLimits = null ][, string|null $parentSpanId = null ][, iterable<string|int, mixed> $attributes = [] ][, array<int, LinkInterface$links = [] ]) : Span
Parameters
$kind : int = APISpanKind::KIND_INTERNAL
$spanLimits : SpanLimits|null = null
$parentSpanId : string|null = null
$attributes : iterable<string|int, mixed> = []
$links : array<int, LinkInterface> = []
Tags
psalm-param

API\SpanKind::KIND_* $kind

Return values
Span

expectDropped()

private expectDropped(int $attributes, int $events, int $links) : void
Parameters
$attributes : int
$events : int
$links : int

spanDoWork()

private spanDoWork(Span $span[, string|null $status = null ][, string|null $description = null ]) : void
Parameters
$span : Span
$status : string|null = null
$description : string|null = null
Tags
psalm-param

API\StatusCode::STATUS_* $status


        
On this page

Search results