Namespaces

Classes

The SpanStack class allows context transfer between spans.

Interfaces

Functions

null|SpanData
active_span()

Get the active span

SpanStack|null
active_stack()

Get the active stack

void
add_distributed_tag(string $key, string $value)

Add a tag to be propagated along distributed traces' information. It also adds the tag to the local root span.

void
add_global_tag(string $key, string $value)

Add a tag to be automatically applied to every span that is created, if tracing is enabled.

false|null
close_span(float $finishTime = 0)

Close the currently active user-span on the top of the stack

false|int
close_spans_until(SpanData|null $span)

Close child spans of a parent span if a non-internal span is given, else if 'null' is given, close active, non-internal spans

void
consume_distributed_tracing_headers(null|array|callable $headersOrCallback)

Update datadog headers for distributed tracing for new spans. Also applies this information to the current trace, if there is one, as well as the future ones if it isn't overwritten

create_stack()

Initialize a new span stack and switch to it. If tracing isn't enabled, a root span stack will be created.

void
curl_multi_exec_get_request_spans(SpanData}> $array)
internal

Registers an array to be populated with spans for each request during the next curl_multi_exec() call.

array
current_context()

Get information on the current context

void
dogstatsd_count(string $metric, int $value, array $tags = [])

Update a DogStatsD counter

void
dogstatsd_distribution(string $metric, float $value, array $tags = [])

Update a DogStatsD distribution

void
dogstatsd_gauge(string $metric, float $value, array $tags = [])

Update a DogStatsD gauge

void
dogstatsd_histogram(string $metric, float $value, array $tags = [])

Update a DogStatsD histogram

void
dogstatsd_set(string $metric, int $value, array $tags = [])

Update a DogStatsD set

array
extract_ip_from_headers(array $headers)

Retrieve IPs from the given array if valid headers are found, and return them in a metadata formatting

Throwable|null
find_active_exception()

Searches parent frames to see whether it's currently within a catch block and returns that exception.

void
flush()

Closes all spans and force-send finished traces to the agent

array
generate_distributed_tracing_headers(array|null $inject = null)

Get information on the key-value pairs of the datadog headers for distributed tracing

int|null
get_priority_sampling(bool $global = false)

Get the priority sampling level

string
get_sanitized_exception_trace(Exception|Throwable $exception, int $skipFrames = 0)

Sanitize an exception

bool
hook_function(string $functionName, Closure|array|null $prehookOrConfigArray = null, Closure|null $posthook = null)

This function allows to define pre- and post-hooks that will be executed before and after the function is called.

bool
hook_method(string $className, string $methodName, Closure|array|null $prehookOrConfigArray = null, Closure|null $posthook = null)

This function allows to define pre- and post-hooks that will be executed before and after the method is called.

string
logs_correlation_trace_id()

Formatted trace id to be used for logs correlation.

root_span()

Get the root span

bool
set_distributed_tracing_context(string $traceId, string $parentId, string|null $origin = null, array|string|null $propagated_tags = null)

Apply the distributed tracing information on the current and future spans. That API can be called if there is no other currently active span.

void
set_priority_sampling(int $priority, bool $global = false)

Set the priority sampling level

void
set_user(string $userId, array $metadata = [], bool|null $propagate = null)

Add user information to monitor authenticated requests in the application.

SpanData|false
start_span(float $startTime = 0)

Start a new custom user-span on the top of the stack. If no active span exists, the new created span will be a root span, on its own new span stack (i.e., it is equivalent to 'start_trace_span'). In that case, distributed tracing information will be applied if available.

start_trace_span(float $startTime = 0)

Start a new trace

string
startup_logs()

Get startup information in JSON format

null|false|SpanStack
switch_stack(SpanData|SpanStack|null $newStack = null)

Switch back to a specific stack (even if there is no active span on that stack), or to the parent of the active stack if no stack is given.

bool
trace_function(string $functionName, Closure|array|null $tracingClosureOrConfigArray)

Instrument (trace) a specific function call. This function automatically handle the following tasks:

  • Open a span before the code executes
  • Set any errors from the instrumented call on the span
  • Close the span when the instrumented call is done.

string
trace_id()

Return the id of the current trace

bool
trace_method(string $className, string $methodName, null|Closure|array $tracingClosureOrConfigArray)

Instrument (trace) a specific method call. This function automatically handle the following tasks:

  • Open a span before the code executes
  • Set any errors from the instrumented call on the span
  • Close the span when the instrumented call is done.

false|null
update_span_duration(SpanData $span, float $finishTime = 0)

Update the duration of an already closed span