Перейти к содержимому
Русский

MetricsExtension

Это содержимое пока не доступно на вашем языке.

Defined in: src/metrics/MetricsExtension.ts:30

MetricsExtension — the system.extension(MetricsExtensionId) accessor that hands back a MetricsRegistry. By default the extension creates a NoopMetricsRegistry (zero-cost) so framework instrumentation pays nothing when the user doesn’t enable metrics.

Opt in:

const metrics = system.extension(MetricsExtensionId).enable(); // … or raise / disable the per-family cardinality cap: const metricsOptions = MetricsRegistryOptions.create().withMaxSeriesPerFamily(50_000); system.extension(MetricsExtensionId).enable(metricsOptions); // … or pre-register a custom registry: system.extension(MetricsExtensionId).useRegistry(myCustomRegistry);

After enable(), the same system.extension(MetricsExtensionId) accessor returns the live DefaultMetricsRegistry; calls before that return the noop.

new MetricsExtension(_system): MetricsExtension

Defined in: src/metrics/MetricsExtension.ts:39

ActorSystem

MetricsExtension

disable(): void

Defined in: src/metrics/MetricsExtension.ts:84

Go back to the noop registry, discarding whatever was collected. Mirrors TracingExtension.disable(), and lets a tool that switched metrics on for its own use (DevTools does) leave the system as it found it.

void


enable(options?): MetricsRegistry

Defined in: src/metrics/MetricsExtension.ts:51

Replace the noop registry with a real one. Returns the live registry so callers can wire counters / gauges immediately. Idempotent — repeated calls return the same instance once a real registry is in place, so options only takes effect on the call that actually installs the registry.

MetricsRegistryOptions

MetricsRegistry


get(): MetricsRegistry

Defined in: src/metrics/MetricsExtension.ts:42

Current registry — noop until enable() has been called.

MetricsRegistry


isEnabled(): boolean

Defined in: src/metrics/MetricsExtension.ts:74

True if a real (non-noop) registry is installed.

boolean


useRegistry(registry): void

Defined in: src/metrics/MetricsExtension.ts:64

Plug in a custom registry — useful when you want to share a single registry across multiple ActorSystems (rare) or to instrument with a third-party Prom client library directly.

MetricsRegistry

void