Μετάβαση στο περιεχόμενο

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).

IPipelineContext

The pipeline execution, read after CacheBehavior ran.

Record<string, boolean>

The attributes; empty when the behavior did not run.

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) });
}
}