Nexus API Reference

OtelObservability
in package
implements Observability

Read onlyYes
FinalYes
Tags
psalm-api

OpenTelemetry-backed Observability provider. Owns the SDK providers so telemetry can be flushed/shut down (wired into the actor-system lifecycle by a later plan).

Table of Contents

Interfaces

Observability

Methods

__construct()  : mixed
attachExportActor()  : void
Spawns the {@see OtlpExportActor} that owns all OTLP flush I/O and attaches the three {@see AsyncExportHandles} forwarders to it, draining any batches buffered before this call. Requires {@see \Monadial\Nexus\Observability\Config\ObservabilityConfig::$asyncExport} to have been enabled when this instance was built via {@see ObservabilityFactory}.
currentContext()  : Context
Returns the ambient active context — the span currently in scope — for injection into outgoing carriers (message metadata / HTTP headers).
forceFlush()  : void
isEnabled()  : bool
Whether a real telemetry backend is wired. When false, instrumentation call sites should skip work entirely (zero overhead).
meter()  : Meter
propagator()  : ContextPropagator
psrLogger()  : LoggerInterface
A PSR-3 logger that exports records over OTLP (correlated with the active trace).
shutdown()  : void
Flush pending telemetry and stop the provider. Called once during application shutdown; a no-op provider does nothing.
tracer()  : Tracer

Methods

__construct()

public __construct(TracerProviderInterface $tracerProvider, MeterProviderInterface $meterProvider, ContextPropagator $propagator[, string $instrumentationScope = 'nexus' ][, LoggerProviderInterface|null $loggerProvider = null ][, AsyncExportHandles|null $asyncExportHandles = null ]) : mixed
Parameters
$tracerProvider : TracerProviderInterface
$meterProvider : MeterProviderInterface
$propagator : ContextPropagator
$instrumentationScope : string = 'nexus'
$loggerProvider : LoggerProviderInterface|null = null
$asyncExportHandles : AsyncExportHandles|null = null

attachExportActor()

Spawns the {@see OtlpExportActor} that owns all OTLP flush I/O and attaches the three {@see AsyncExportHandles} forwarders to it, draining any batches buffered before this call. Requires {@see \Monadial\Nexus\Observability\Config\ObservabilityConfig::$asyncExport} to have been enabled when this instance was built via {@see ObservabilityFactory}.

public attachExportActor(ActorSystem $system[, string $name = 'otlp-export' ]) : void

Idempotent while the previously attached actor is alive: a second call is a no-op. If that actor has since died, ActorSystem::spawn() prunes it and a second call respawns and re-attaches, restoring Live delivery.

Deliberately never wires an OTel-backed PSR logger into the actor (leaves the NullLogger default) — routing the export actor's own logs back through the OTLP pipeline it drives would create a feedback loop.

Parameters
$system : ActorSystem
$name : string = 'otlp-export'
Tags
throws
LogicException

if asyncExport was not enabled.

currentContext()

Returns the ambient active context — the span currently in scope — for injection into outgoing carriers (message metadata / HTTP headers).

public currentContext() : Context
Attributes
#[Override]
Return values
Context

isEnabled()

Whether a real telemetry backend is wired. When false, instrumentation call sites should skip work entirely (zero overhead).

public isEnabled() : bool
Attributes
#[Override]
Return values
bool

psrLogger()

A PSR-3 logger that exports records over OTLP (correlated with the active trace).

public psrLogger([string|null $name = null ]) : LoggerInterface

Returns a no-op logger when logs are not configured. Not part of the Observability contract — callers opt in by depending on the concrete OTel provider.

Parameters
$name : string|null = null
Return values
LoggerInterface

shutdown()

Flush pending telemetry and stop the provider. Called once during application shutdown; a no-op provider does nothing.

public shutdown() : void
Attributes
#[Override]
On this page

Search results