MetricsBehavior
Αυτό το περιεχόμενο δεν είναι ακόμη διαθέσιμο στη γλώσσα σου.
Defined in: metrics.behavior.ts:150
Pipeline behavior that records OpenTelemetry metrics for every handler it wraps, complementing TraceBehavior’s spans:
pipeline.handler.duration— histogram (ms) of handler execution time;pipeline.handler.invocations— counter incremented once per completed call;pipeline.handler.active— current in-flight handler count.
The default label set is deliberately low-cardinality:
pipeline.request.kind, pipeline.request.name, and
pipeline.handler.name, plus outcome/error information when the call ends.
Both outcome and the namespaced pipeline.outcome attribute are emitted
for completed calls.
The OTel Metrics API is used directly. When no OpenTelemetry SDK / metric reader is registered, the API returns no-op instruments and recordings are discarded.
Instrument creation/recording and custom enrichment are best-effort: telemetry must not replace a successful business result or the original business error. A logger passed to the constructor, when present, reports instrumentation failures.
Examples
Section titled “Examples”Global application metrics
createPipeline({ globalBehaviors: { scope: 'all', after: [MetricsBehavior], },});Disable a very hot handler
class HealthCheckHandler { @pipeline.wrap({ kind: 'query' }, [MetricsBehavior, { enabled: false }]) async handle(query: HealthCheckQuery) {}}Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MetricsBehavior(
logger?):MetricsBehavior
Defined in: metrics.behavior.ts:154
Parameters
Section titled “Parameters”logger?
Section titled “logger?”Returns
Section titled “Returns”MetricsBehavior
Methods
Section titled “Methods”handle()
Section titled “handle()”handle(
context,next):Promise<unknown>
Defined in: metrics.behavior.ts:156
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”Promise<unknown>