buildCacheAttributes
buildCacheAttributes(
context):Record<string,boolean>
Defined in: packages/pipeline-cache/src/helpers/build-attributes.ts:44
The cache decision of one execution as flat attributes:
{ 'cache.hit': boolean } once CacheBehavior looked the response up, and
{} when it did not run, so a request without caching never reports a
fabricated miss. The cache key is never included: it carries the tenant and
the principal, and is unbounded as a value.
The result is plain data and needs no telemetry package: put it on a span, a log line, an audit record or a metric label (bounded values only).
Parameters
Section titled “Parameters”context
Section titled “context”The pipeline execution, read after CacheBehavior ran.
Returns
Section titled “Returns”Record<string, boolean>
The attributes; empty when the behavior did not run.
Examples
Section titled “Examples”Span attributes
With AttributesBehavior of @cqrs-ddd/pipeline-opentelemetry:
createPipeline({ globalBehaviors: { before: [TraceBehavior, [AttributesBehavior, { factories: [buildCacheAttributes] }]], },});A log line from a custom behavior, after the chain ran
async handle(context: IPipelineContext, next: NextDelegate) { try { return await next(); } finally { this.logger.log({ request: context.requestName, ...buildCacheAttributes(context) }); }}