Hyperlinkv0.8.0-beta.28

Metric

Metric.MetricRegistryconsteffect/Metric.ts:1716
Context.Reference<Map<string, Metric.Metadata<any, any>>>

Context reference for the metric registry in the current context.

When to use

Use when you need a custom metric registry for an isolated program or test instead of the default registry.

Details

By default, the reference creates an empty Map the first time it is resolved. Metrics register their metadata and hooks lazily in this map when they are read or updated.

Gotchas

Because Context.Reference caches default values, the default Map is shared by contexts that do not provide an override. Provide MetricRegistry with a fresh Map when isolation matters.

Source effect/Metric.ts:17164 lines
export const MetricRegistry = Context.Reference<Map<string, Metric.Metadata<any, any>>>(
  MetricRegistryKey,
  { defaultValue: () => new Map() }
)
Referenced by 1 symbols