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

Breadcrumb

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

function Meter::createSynchronousWriter

Return value

array{Instrument, ReferenceCounterInterface, RegisteredInstrument}

4 calls to Meter::createSynchronousWriter()
Meter::createCounter in vendor/open-telemetry/sdk/Metrics/Meter.php
Creates a `Counter`.
Meter::createGauge in vendor/open-telemetry/sdk/Metrics/Meter.php
Creates a `Gauge`.
Meter::createHistogram in vendor/open-telemetry/sdk/Metrics/Meter.php
Creates a `Histogram`.
Meter::createUpDownCounter in vendor/open-telemetry/sdk/Metrics/Meter.php
Creates an `UpDownCounter`.

File

vendor/open-telemetry/sdk/Metrics/Meter.php, line 297

Class

Meter
@internal

Namespace

OpenTelemetry\SDK\Metrics

Code

private function createSynchronousWriter(string|InstrumentType $instrumentType, string $name, ?string $unit, ?string $description, array $advisory = []) : array {
    $instrument = new Instrument($instrumentType, $name, $unit, $description, $advisory);
    $instrumentationScopeId = $this->instrumentationScopeId($this->instrumentationScope);
    $instrumentId = $this->instrumentId($instrument);
    $instruments = $this->instruments;
    if ($writer = $instruments->writers[$instrumentationScopeId][$instrumentId] ?? null) {
        return $writer;
    }
    $stalenessHandler = $this->stalenessHandlerFactory
        ->create();
    if ($this->config
        ->isEnabled()) {
        $instruments->startTimestamp ??= $this->clock
            ->now();
        $this->metricFactory
            ->createSynchronousWriter($this->registry, $this->resource, $this->instrumentationScope, $instrument, $instruments->startTimestamp, $this->viewRegistrationRequests($instrument, $stalenessHandler), $this->exemplarFilter);
    }
    $stalenessHandler->onStale(fn() => $this->releaseStreams($instrument));
    $stalenessHandler->onStale(static function () use ($instruments, $instrumentationScopeId, $instrumentId) : void {
        unset($instruments->writers[$instrumentationScopeId][$instrumentId]);
        if (!$instruments->writers[$instrumentationScopeId]) {
            unset($instruments->writers[$instrumentationScopeId]);
        }
        $instruments->startTimestamp = null;
    });
    return $instruments->writers[$instrumentationScopeId][$instrumentId] = [
        $instrument,
        $stalenessHandler,
        new RegisteredInstrument(!$this->config
            ->isEnabled(), $this),
    ];
}

API Navigation

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