final class ElasticApm (View source)

Class ElasticApm is a facade (as in Facade design pattern) to the rest of Elastic APM public API.

Constants

VERSION

Methods

beginCurrentTransaction(string $name, string $type, float|null $timestamp = null, string|null $serializedDistTracingData = null)

Begins a new transaction and sets it as the current transaction.

static mixed
captureCurrentTransaction(string $name, string $type, Closure $callback, float|null $timestamp = null, string|null $serializedDistTracingData = null)

Begins a new transaction, sets as the current transaction, runs the provided callback as the new transaction and automatically ends the new transaction.

getCurrentTransaction()

Returns the current transaction.

getCurrentExecutionSegment()

If there is the current span then it returns the current span.

beginTransaction(string $name, string $type, float|null $timestamp = null, string|null $serializedDistTracingData = null)

Begins a new transaction.

static mixed
captureTransaction(string $name, string $type, Closure $callback, float|null $timestamp = null, string|null $serializedDistTracingData = null)

Begins a new transaction, runs the provided callback as the new transaction and automatically ends the new transaction.

newTransaction(string $name, string $type)

Advanced API to begin a new transaction

static string|null
createErrorFromThrowable(Throwable $throwable)

Creates an error based on the given Throwable instance with the current execution segment (if there is one) as the parent.

static string|null
createCustomError(CustomErrorData $customErrorData)

Creates an error based on the given data with the current execution segment (if there is one) as the parent.

static void
pauseRecording()

Pauses recording

static void
resumeRecording()

Resumes recording

static string
getSerializedCurrentDistributedTracingData() deprecated

No description

Details

static TransactionInterface beginCurrentTransaction(string $name, string $type, float|null $timestamp = null, string|null $serializedDistTracingData = null)

Begins a new transaction and sets it as the current transaction.

Parameters

string $name

New transaction's name

string $type

New transaction's type

float|null $timestamp

Start time of the new transaction

string|null $serializedDistTracingData
  • DEPRECATED since version 1.3 - use newTransaction()->distributedTracingHeaderExtractor() instead

Return Value

TransactionInterface

New transaction

See also

\Elastic\Apm\TransactionInterface::setName() For the description.
\Elastic\Apm\TransactionInterface::setType() For the description.
\Elastic\Apm\TransactionInterface::getTimestamp() For the description.

static mixed captureCurrentTransaction(string $name, string $type, Closure $callback, float|null $timestamp = null, string|null $serializedDistTracingData = null)

Begins a new transaction, sets as the current transaction, runs the provided callback as the new transaction and automatically ends the new transaction.

Parameters

string $name

New transaction's name

string $type

New transaction's type

Closure $callback

Callback to execute as the new transaction

float|null $timestamp

Start time of the new transaction

string|null $serializedDistTracingData
  • DEPRECATED since version 1.3 - use newTransaction()->distributedTracingHeaderExtractor() instead

Return Value

mixed

The return value of $callback

See also

\Elastic\Apm\TransactionInterface::setName() For the description.
\Elastic\Apm\TransactionInterface::setType() For the description.
\Elastic\Apm\TransactionInterface::getTimestamp() For the description.

static TransactionInterface getCurrentTransaction()

Returns the current transaction.

Return Value

TransactionInterface

The current transaction

static ExecutionSegmentInterface getCurrentExecutionSegment()

If there is the current span then it returns the current span.

Otherwise if there is the current transaction then it returns the current transaction. Otherwise it returns the noop execution segment.

Return Value

ExecutionSegmentInterface

The current execution segment

static TransactionInterface beginTransaction(string $name, string $type, float|null $timestamp = null, string|null $serializedDistTracingData = null)

Begins a new transaction.

Parameters

string $name

New transaction's name

string $type

New transaction's type

float|null $timestamp

Start time of the new transaction

string|null $serializedDistTracingData
  • DEPRECATED since version 1.3 - use newTransaction()->distributedTracingHeaderExtractor() instead

Return Value

TransactionInterface

New transaction

See also

\Elastic\Apm\TransactionInterface::setName() For the description.
\Elastic\Apm\TransactionInterface::setType() For the description.
\Elastic\Apm\TransactionInterface::getTimestamp() For the description.

static mixed captureTransaction(string $name, string $type, Closure $callback, float|null $timestamp = null, string|null $serializedDistTracingData = null)

Begins a new transaction, runs the provided callback as the new transaction and automatically ends the new transaction.

Parameters

string $name

New transaction's name

string $type

New transaction's type

Closure $callback

Callback to execute as the new transaction

float|null $timestamp

Start time of the new transaction

string|null $serializedDistTracingData
  • DEPRECATED since version 1.3 - use newTransaction()->distributedTracingHeaderExtractor() instead

Return Value

mixed

The return value of $callback

See also

\Elastic\Apm\TransactionInterface::setName() For the description.
\Elastic\Apm\TransactionInterface::setType() For the description.
\Elastic\Apm\TransactionInterface::getTimestamp() For the description.

static TransactionBuilderInterface newTransaction(string $name, string $type)

Advanced API to begin a new transaction

Parameters

string $name

New transaction's name

string $type

New transaction's type

Return Value

TransactionBuilderInterface

New transaction builder

See also

\Elastic\Apm\TransactionInterface::setName() For the description.
\Elastic\Apm\TransactionInterface::setType() For the description.

static string|null createErrorFromThrowable(Throwable $throwable)

Creates an error based on the given Throwable instance with the current execution segment (if there is one) as the parent.

Parameters

Throwable $throwable

Return Value

string|null

ID of the reported error event or null if no event was reported (for example, because recording is disabled)

static string|null createCustomError(CustomErrorData $customErrorData)

Creates an error based on the given data with the current execution segment (if there is one) as the parent.

Parameters

CustomErrorData $customErrorData

Return Value

string|null

ID of the reported error event or null if no event was reported (for example, because recording is disabled)

static void pauseRecording()

Pauses recording

Return Value

void

static void resumeRecording()

Resumes recording

Return Value

void

static string getSerializedCurrentDistributedTracingData() deprecated

deprecated Deprecated since version 1.3 - use injectDistributedTracingHeaders() instead

No description

Return Value

string

See also

injectDistributedTracingHeaders() Use it instead of this method Returns distributed tracing data for the current span/transaction