class DatabaseInstrumentation extends AbstractInstrumentation

Constants

protected DURATION_BOUNDARIES

protected CONNECTION_ROLE_ATTRIBUTE

Properties

protected InstrumentationOptions $options from  AbstractInstrumentation
protected TracerInterface|null $tracer
protected HistogramInterface|null $duration
protected bool $queryText
protected int|null $queryTextMaxLength

Methods

void
register(array $options)

Register the instrumentation with normalized options.

void
registerInstrumentation()

Register database listeners and instruments.

bool
tracesEnabled()

Determine whether trace output is enabled.

bool
metricEnabled(string $name)

Determine whether a metric is enabled.

array
indexObservers(array $names, array $observers)

Index callback observers by their matching instrument name.

__construct(Dispatcher $events, TracerProviderInterface $tracerProvider, MeterProviderInterface $meterProvider, ClockInterface $clock, ExceptionContextRegistry $exceptionContexts, OperationOrigin $origins, ProcessIdentity $identity)

Create database instrumentation.

void
queryExecuted(QueryExecuted $event)

Record a completed database query.

void
queryFailed(QueryFailed $event)

Record a failed database query.

void
recordQuery(string $query, float $elapsedMilliseconds, Connection $connection, string|null $connectionRole, Throwable|null $exception = null)

Record one completed database operation.

array
attributes(Connection $connection, string|null $connectionRole, string|null $operation, string|null $errorType)

Return low-cardinality attributes shared by spans and metrics.

string|null
operation(string $query)

Return the database operation when the query has one safe leading statement.

string
queryText(string $query)

Return the bounded query template.

string
systemName(string $driver)

Return the semantic database system name for a Hypervel driver.

string|null
serverAddress(Connection $connection, string|null $connectionRole)

Return the configured server address when it identifies the queried endpoint.

string
errorType(Throwable $exception)

Return the canonical error type for a failed operation.

string
spanName(string|null $operation, array $attributes)

Return the semantic span name for a database operation.

Details

final void register(array $options)

Register the instrumentation with normalized options.

Parameters

array $options

Return Value

void

at line 70
protected void registerInstrumentation()

Register database listeners and instruments.

Return Value

void

protected bool tracesEnabled()

Determine whether trace output is enabled.

Return Value

bool

protected bool metricEnabled(string $name)

Determine whether a metric is enabled.

Parameters

string $name

Return Value

bool

protected array indexObservers(array $names, array $observers)

Index callback observers by their matching instrument name.

The SDK supplies observers in the same order as the instruments passed to batchObserve(), so the unchanged name order is the mapping contract.

Parameters

array $names
array $observers

Return Value

array

at line 56
__construct(Dispatcher $events, TracerProviderInterface $tracerProvider, MeterProviderInterface $meterProvider, ClockInterface $clock, ExceptionContextRegistry $exceptionContexts, OperationOrigin $origins, ProcessIdentity $identity)

Create database instrumentation.

Parameters

Dispatcher $events
TracerProviderInterface $tracerProvider
MeterProviderInterface $meterProvider
ClockInterface $clock
ExceptionContextRegistry $exceptionContexts
OperationOrigin $origins
ProcessIdentity $identity

at line 106
protected void queryExecuted(QueryExecuted $event)

Record a completed database query.

Parameters

QueryExecuted $event

Return Value

void

at line 123
protected void queryFailed(QueryFailed $event)

Record a failed database query.

Parameters

QueryFailed $event

Return Value

void

at line 137
protected void recordQuery(string $query, float $elapsedMilliseconds, Connection $connection, string|null $connectionRole, Throwable|null $exception = null)

Record one completed database operation.

Parameters

string $query
float $elapsedMilliseconds
Connection $connection
string|null $connectionRole
Throwable|null $exception

Return Value

void

at line 202
protected array attributes(Connection $connection, string|null $connectionRole, string|null $operation, string|null $errorType)

Return low-cardinality attributes shared by spans and metrics.

Parameters

Connection $connection
string|null $connectionRole
string|null $operation
string|null $errorType

Return Value

array

at line 225
protected string|null operation(string $query)

Return the database operation when the query has one safe leading statement.

Parameters

string $query

Return Value

string|null

at line 245
protected string queryText(string $query)

Return the bounded query template.

Parameters

string $query

Return Value

string

at line 255
protected string systemName(string $driver)

Return the semantic database system name for a Hypervel driver.

Parameters

string $driver

Return Value

string

at line 269
protected string|null serverAddress(Connection $connection, string|null $connectionRole)

Return the configured server address when it identifies the queried endpoint.

Parameters

Connection $connection
string|null $connectionRole

Return Value

string|null

at line 291
protected string errorType(Throwable $exception)

Return the canonical error type for a failed operation.

Parameters

Throwable $exception

Return Value

string

at line 301
protected string spanName(string|null $operation, array $attributes)

Return the semantic span name for a database operation.

Parameters

string|null $operation
array $attributes

Return Value

string