function Meter::batchObserve
Overrides MeterInterface::batchObserve
File
-
vendor/
open-telemetry/ sdk/ Metrics/ Meter.php, line 121
Class
- Meter
- @internal
Namespace
OpenTelemetry\SDK\MetricsCode
public function batchObserve(callable $callback, AsynchronousInstrument $instrument, AsynchronousInstrument ...$instruments) : ObservableCallbackInterface {
$referenceCounters = [];
$handles = [];
array_unshift($instruments, $instrument);
foreach ($instruments as $instrument) {
if (!$instrument instanceof InstrumentHandle) {
self::logWarning('Ignoring invalid instrument provided to batchObserve, instrument not created by this SDK', [
'instrument' => $instrument,
]);
$handles[] = self::dummyInstrument();
continue;
}
$asynchronousInstrument = $this->getAsynchronousInstrument($instrument->getHandle(), $this->instrumentationScope);
if (!$asynchronousInstrument) {
self::logWarning('Ignoring invalid instrument provided to batchObserve, instrument not created by this meter', [
'instrument' => $instrument,
]);
$handles[] = self::dummyInstrument();
continue;
}
[
$handles[],
$referenceCounters[],
] = $asynchronousInstrument;
}
assert($handles !== []);
return AsynchronousInstruments::observe($this->writer, $this->destructors, $callback, $handles, new MultiReferenceCounter($referenceCounters));
}