class DatabaseInstrumentation extends AbstractInstrumentation

Constants

protected DURATION_BOUNDARIES

protected CONNECTION_ROLE_ATTRIBUTE

protected DB_SYSTEM_NAME_SQLITE

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.

bool
isDirectCancellation(Throwable|null $exception)

Determine whether the throwable is a direct coroutine cancellation.

string
schemaUrl()

Return the semantic conventions schema URL for Hypervel instrumentation scopes.

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 73
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 bool isDirectCancellation(Throwable|null $exception)

Determine whether the throwable is a direct coroutine cancellation.

Ending an operation by direct cancellation is control flow, not a failure.

Parameters

Throwable|null $exception

Return Value

bool

protected string schemaUrl()

Return the semantic conventions schema URL for Hypervel instrumentation scopes.

Every tracer, meter and logger obtained for one scope must pass the same URL.

Return Value

string

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 59
__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 109
protected void queryExecuted(QueryExecuted $event)

Record a completed database query.

Parameters

QueryExecuted $event

Return Value

void

at line 126
protected void queryFailed(QueryFailed $event)

Record a failed database query.

Parameters

QueryFailed $event

Return Value

void

at line 140
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 205
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 228
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 248
protected string queryText(string $query)

Return the bounded query template.

Parameters

string $query

Return Value

string

at line 258
protected string systemName(string $driver)

Return the semantic database system name for a Hypervel driver.

Parameters

string $driver

Return Value

string

at line 272
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 294
protected string errorType(Throwable $exception)

Return the canonical error type for a failed operation.

Parameters

Throwable $exception

Return Value

string

at line 304
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