Skip to content

AttributesBehavior

Defined in: attributes.behavior.ts:58

Collects attributes that describe what the rest of the chain decided, and adds them to the execution’s attribute bag, which TraceBehavior applies to its span and MetricsBehavior to its labels when includeContextAttributes is on.

Behaviors that take no telemetry dependency publish their decisions as context.items entries and export a factory that reads them, such as buildCacheAttributes of @nestjs-pipeline/cache. This behavior runs those factories after the chain unwinds, so every inner behavior has published its item by then. The application chooses the factories, can wrap one to rename or drop attributes, and can register the behavior globally or per handler.

Register it inside TraceBehavior and MetricsBehavior and outside the behaviors it describes. It never changes the outcome: the result or error of the chain is returned as it was.

PipelineModule.forRoot({
globalBehaviors: {
before: [
TraceBehavior,
[AttributesBehavior, {
factories: [buildCacheAttributes, buildIdempotencyAttributes],
}],
],
},
});

new AttributesBehavior(): AttributesBehavior

AttributesBehavior

handle(context, next): Promise<unknown>

Defined in: attributes.behavior.ts:59

IPipelineContext

NextDelegate

Promise<unknown>

IPipelineBehavior.handle