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
Namespace
OpenTelemetry\API\MetricsCode
public function batchObserve(callable $callback, AsynchronousInstrument $instrument, AsynchronousInstrument ...$instruments) : ObservableCallbackInterface;