Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. MeterInterface.php

function MeterInterface::batchObserve

Reports measurements for multiple asynchronous instrument from a single callback.

The callback receives an {@link ObserverInterface} for each instrument. All provided instruments have to be created by this meter.

```php $callback = $meter->batchObserve( function( ObserverInterface $usageObserver, ObserverInterface $pressureObserver, ): void { [$usage, $pressure] = expensive_system_call(); $usageObserver->observe($usage); $pressureObserver->observe($pressure); }, $meter->createObservableCounter('usage', description: 'count of items used'), $meter->createObservableGauge('pressure', description: 'force per unit area'), ); ```

Parameters

callable $callback function responsible for reporting the measurements:

AsynchronousInstrument $instrument first instrument to report measurements for:

AsynchronousInstrument ...$instruments additional instruments to report measurements for:

Return value

ObservableCallbackInterface token to detach callback

See also

https://opentelemetry.io/docs/specs/otel/metrics/api/#multiple-instrume…

3 methods override MeterInterface::batchObserve()
LateBindingMeter::batchObserve in vendor/open-telemetry/api/Metrics/LateBindingMeter.php
Reports measurements for multiple asynchronous instrument from a single callback.
Meter::batchObserve in vendor/open-telemetry/sdk/Metrics/Meter.php
Reports measurements for multiple asynchronous instrument from a single callback.
NoopMeter::batchObserve in vendor/open-telemetry/api/Metrics/Noop/NoopMeter.php
Reports measurements for multiple asynchronous instrument from a single callback.

File

vendor/open-telemetry/api/Metrics/MeterInterface.php, line 38

Class

MeterInterface

Namespace

OpenTelemetry\API\Metrics

Code

public function batchObserve(callable $callback, AsynchronousInstrument $instrument, AsynchronousInstrument ...$instruments) : ObservableCallbackInterface;

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal