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

buildFeatureFlagAttributes

Αυτό το περιεχόμενο δεν είναι ακόμη διαθέσιμο στη γλώσσα σου.

buildFeatureFlagAttributes(context): Record<string, string | boolean>

Defined in: packages/pipeline-feature-flags/src/helpers/build-attributes.ts:51

The feature-flag decision of one execution as flat attributes, named after the OpenTelemetry feature-flag conventions: feature_flag.key and feature_flag.enabled, plus feature_flag.variant and feature_flag.reason when the provider reported them, and feature_flag.error_code only when evaluation failed. {} when FeatureFlagBehavior did not run. The targeting key and the provider’s error message are never included.

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 FeatureFlagBehavior ran.

Record<string, 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: [buildFeatureFlagAttributes] }]],
},
});

Audit metadata

audit() is declared outside featureFlag(), so the record is built after its decision:

@pipeline.wrap(
{ kind: 'command' },
audit({ action: 'order.create', metadata: buildFeatureFlagAttributes }),
featureFlag({ flag: 'checkout' }),
)

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, ...buildFeatureFlagAttributes(context) });
}
}