class DeferredMeter implements MeterInterface

internal  
 

Keep pre-fork metric instruments and callbacks usable after worker binding.

Properties

protected MeterInterface|null $delegate
protected DeferredCounter|DeferredGauge|DeferredHistogram|DeferredUpDownCounter> $synchronousInstruments
protected DeferredObservableCounter|DeferredObservableGauge|DeferredObservableUpDownCounter> $observableInstruments
protected DeferredObservableCallback> $observableCallbacks
protected DeferredCallbackDestructor> $callbackDestructors

Methods

__construct(InstrumentationScope $instrumentationScope)

Create a deferred meter.

void
bind(MeterProviderInterface $provider)

Bind this handle and every pre-fork instrument to the given provider.

void
unbind()

Unbind this handle, its instruments, and its callback registrations.

ObservableCallbackInterface
batchObserve(callable $callback, AsynchronousInstrument $instrument, AsynchronousInstrument ...$instruments)

Register one callback for multiple asynchronous instruments.

CounterInterface
createCounter(string $name, string|null $unit = null, string|null $description = null, array $advisory = [])

Create a counter.

ObservableCounterInterface
createObservableCounter(string $name, string|null $unit = null, string|null $description = null, array|callable $advisory = [], callable ...$callbacks)

Create an observable counter.

HistogramInterface
createHistogram(string $name, string|null $unit = null, string|null $description = null, array $advisory = [])

Create a histogram.

GaugeInterface
createGauge(string $name, string|null $unit = null, string|null $description = null, array $advisory = [])

Create a gauge.

ObservableGaugeInterface
createObservableGauge(string $name, string|null $unit = null, string|null $description = null, array|callable $advisory = [], callable ...$callbacks)

Create an observable gauge.

UpDownCounterInterface
createUpDownCounter(string $name, string|null $unit = null, string|null $description = null, array $advisory = [])

Create an up-down counter.

ObservableUpDownCounterInterface
createObservableUpDownCounter(string $name, string|null $unit = null, string|null $description = null, array|callable $advisory = [], callable ...$callbacks)

Create an observable up-down counter.

ObservableCallbackInterface
registerObservableCallback(callable $callback, array $instruments, bool $batch = false)

Register an observable callback that follows worker rebinding.

void
forgetObservableCallback(DeferredObservableCallback $callback, WeakReference|null $target)

Forget a detached observable callback.

array
mapObservableInstruments(array $instruments)

Map this meter's deferred instruments to their current delegates.

bool
containsOwnedDeferredInstrument(array $instruments)

Determine whether the list contains an instrument owned by this meter.

array
normalizeObservableArguments(array|callable $advisory, array $callbacks)

Normalize the observable advisory and creation callbacks.

static Closure
weakenCallback(callable $callback, object|null $target)

Convert a callback to weak target ownership when it is object-bound.

Details

at line 52
__construct(InstrumentationScope $instrumentationScope)

Create a deferred meter.

Parameters

InstrumentationScope $instrumentationScope

at line 60
void bind(MeterProviderInterface $provider)

Bind this handle and every pre-fork instrument to the given provider.

Parameters

MeterProviderInterface $provider

Return Value

void

at line 86
void unbind()

Unbind this handle, its instruments, and its callback registrations.

Return Value

void

at line 106
ObservableCallbackInterface batchObserve(callable $callback, AsynchronousInstrument $instrument, AsynchronousInstrument ...$instruments)

Register one callback for multiple asynchronous instruments.

Parameters

callable $callback
AsynchronousInstrument $instrument
AsynchronousInstrument ...$instruments

Return Value

ObservableCallbackInterface

at line 126
CounterInterface createCounter(string $name, string|null $unit = null, string|null $description = null, array $advisory = [])

Create a counter.

Parameters

string $name
string|null $unit
string|null $description
array $advisory

Return Value

CounterInterface

at line 143
ObservableCounterInterface createObservableCounter(string $name, string|null $unit = null, string|null $description = null, array|callable $advisory = [], callable ...$callbacks)

Create an observable counter.

Parameters

string $name
string|null $unit
string|null $description
array|callable $advisory
callable ...$callbacks

Return Value

ObservableCounterInterface

at line 170
HistogramInterface createHistogram(string $name, string|null $unit = null, string|null $description = null, array $advisory = [])

Create a histogram.

Parameters

string $name
string|null $unit
string|null $description
array $advisory

Return Value

HistogramInterface

at line 187
GaugeInterface createGauge(string $name, string|null $unit = null, string|null $description = null, array $advisory = [])

Create a gauge.

Parameters

string $name
string|null $unit
string|null $description
array $advisory

Return Value

GaugeInterface

at line 204
ObservableGaugeInterface createObservableGauge(string $name, string|null $unit = null, string|null $description = null, array|callable $advisory = [], callable ...$callbacks)

Create an observable gauge.

Parameters

string $name
string|null $unit
string|null $description
array|callable $advisory
callable ...$callbacks

Return Value

ObservableGaugeInterface

at line 231
UpDownCounterInterface createUpDownCounter(string $name, string|null $unit = null, string|null $description = null, array $advisory = [])

Create an up-down counter.

Parameters

string $name
string|null $unit
string|null $description
array $advisory

Return Value

UpDownCounterInterface

at line 248
ObservableUpDownCounterInterface createObservableUpDownCounter(string $name, string|null $unit = null, string|null $description = null, array|callable $advisory = [], callable ...$callbacks)

Create an observable up-down counter.

Parameters

string $name
string|null $unit
string|null $description
array|callable $advisory
callable ...$callbacks

Return Value

ObservableUpDownCounterInterface

at line 278
ObservableCallbackInterface registerObservableCallback(callable $callback, array $instruments, bool $batch = false)

internal  
 

Register an observable callback that follows worker rebinding.

Parameters

callable $callback
array $instruments
bool $batch

Return Value

ObservableCallbackInterface

at line 311
void forgetObservableCallback(DeferredObservableCallback $callback, WeakReference|null $target)

internal  
 

Forget a detached observable callback.

Parameters

DeferredObservableCallback $callback
WeakReference|null $target

Return Value

void

at line 338
array mapObservableInstruments(array $instruments)

internal  
 

Map this meter's deferred instruments to their current delegates.

Parameters

array $instruments

Return Value

array

at line 358
protected bool containsOwnedDeferredInstrument(array $instruments)

Determine whether the list contains an instrument owned by this meter.

Parameters

array $instruments

Return Value

bool

at line 378
protected array normalizeObservableArguments(array|callable $advisory, array $callbacks)

Normalize the observable advisory and creation callbacks.

Parameters

array|callable $advisory
array $callbacks

Return Value

array

at line 394
static protected Closure weakenCallback(callable $callback, object|null $target)

Convert a callback to weak target ownership when it is object-bound.

This reproduces the SDK's weak-target lifetime with public PHP APIs, so discarding the registration token cannot retain the callback's object.

Parameters

callable $callback
object|null $target

Return Value

Closure