Repository navigation
ObservabilityAdapter
Pair\Core\ObservabilityAdapter receives completed runtime spans from Observability.
public function record(\Pair\Core\ObservabilitySpan $span): void;ObservabilitySpan exposes the operation name, start/end timestamps, duration in milliseconds, status, sanitized attributes, and correlation ID through accessor methods and toArray().
use Pair\Core\Observability;
use Pair\Core\ObservabilityAdapter;
use Pair\Core\ObservabilitySpan;
final class LogSpanAdapter implements ObservabilityAdapter {
/**
* Forward one completed span to the application log.
*/
public function record(ObservabilitySpan $span): void {
error_log(json_encode($span->toArray(), JSON_UNESCAPED_SLASHES));
}
}
Observability::setAdapter(new LogSpanAdapter());Installing an adapter enables instrumentation unless it is explicitly disabled with Observability::enable(false). Applications can also register it under AdapterKeys::OBSERVABILITY; see AdapterRegistry.
Implement ObservabilityEventAdapter as well when the collector should receive non-span warning/error events. The two interfaces are separate so existing span-only adapters remain compatible.
See Observability for sampling, environment configuration, event limits, and debug headers. Built-in collectors include SentryObservabilityAdapter and OpenTelemetryHttpExporter.