Telemetry
Main entry point to all telemetry operations.
Provides unified access to tracing, metrics, and logging through their respective providers. Coordinates lifecycle operations (flush, shutdown) across all providers.
Instances of Tracer, Meter, and Logger are cached by this class to ensure that calling tracer/meter/logger with the same parameters returns the same instance.
Methods
- __construct() : mixed
- flush() : bool
- Flush all pending telemetry data.
- logger() : Logger
- Get or create a logger for the given scope.
- meter() : Meter
- Get or create a meter for the given scope.
- registerShutdownFunction() : $this
- Register this instance for automatic shutdown at process end.
- shutdown() : bool
- Shutdown all telemetry and release resources.
- tracer() : Tracer
- Get or create a tracer for the given scope.
Methods
__construct()
public
__construct(Resource $resource, TracerProvider $tracerProvider, MeterProvider $meterProvider, LoggerProvider $loggerProvider) : mixed
Parameters
- $resource : Resource
- $tracerProvider : TracerProvider
- $meterProvider : MeterProvider
- $loggerProvider : LoggerProvider
flush()
Flush all pending telemetry data.
public
flush() : bool
Flushes all cached tracers, meters, and loggers. Returns true only if all flush operations succeed.
Return values
boollogger()
Get or create a logger for the given scope.
public
logger(string $name[, string $version = 'unknown' ][, null|string $schemaUrl = null ][, null|Attributes $attributes = null ][, null|Attributes $signalAttributes = null ]) : Logger
Loggers are cached by name, version, schemaUrl, and attributes. Calling this method with the same parameters returns the same Logger instance.
Parameters
- $name : string
-
The name of the instrumentation scope
- $version : string = 'unknown'
-
The version of the instrumentation scope
- $schemaUrl : null|string = null
-
Schema URL for semantic conventions
- $attributes : null|Attributes = null
-
Additional scope attributes
- $signalAttributes : null|Attributes = null
-
Default attributes merged into every emitted log record (per-call values win)
Return values
Loggermeter()
Get or create a meter for the given scope.
public
meter(string $name[, string $version = 'unknown' ][, null|string $schemaUrl = null ][, null|Attributes $attributes = null ][, null|Attributes $signalAttributes = null ]) : Meter
Meters are cached by name, version, schemaUrl, and attributes. Calling this method with the same parameters returns the same Meter instance.
Parameters
- $name : string
-
The name of the instrumentation scope
- $version : string = 'unknown'
-
The version of the instrumentation scope
- $schemaUrl : null|string = null
-
Schema URL for semantic conventions
- $attributes : null|Attributes = null
-
Additional scope attributes
- $signalAttributes : null|Attributes = null
-
Default attributes merged into every recorded metric data point (per-call values win)
Return values
MeterregisterShutdownFunction()
Register this instance for automatic shutdown at process end.
public
registerShutdownFunction() : $this
This ensures all pending spans, metrics, and logs are exported when the PHP process terminates - including exit() calls, fatal errors, and uncaught exceptions.
Return values
$this —For method chaining
shutdown()
Shutdown all telemetry and release resources.
public
shutdown() : bool
Flushes all pending data, then shuts down all transports. Transport shutdown is idempotent, allowing multiple exporters to share the same transport safely.
Return values
booltracer()
Get or create a tracer for the given scope.
public
tracer(string $name[, string $version = 'unknown' ][, null|string $schemaUrl = null ][, null|Attributes $attributes = null ][, null|Attributes $signalAttributes = null ]) : Tracer
Tracers are cached by name, version, schemaUrl, and attributes. Calling this method with the same parameters returns the same Tracer instance.
Parameters
- $name : string
-
The name of the instrumentation scope
- $version : string = 'unknown'
-
The version of the instrumentation scope
- $schemaUrl : null|string = null
-
Schema URL for semantic conventions
- $attributes : null|Attributes = null
-
Additional scope attributes
- $signalAttributes : null|Attributes = null
-
Default attributes merged into every started span (per-call values win)