RFC-0028: OpenTelemetry Metrics and Span Events

  • Status: Proposed; adds an audit-sink distribution and a core fan-out sink.

  • Owner: Operations and security leads.

  • Last updated: 2026-11-30

Context

Operators run on OpenTelemetry: they need to see operation rates, failure causes, and latency next to the rest of a service, and to find a failing decrypt inside a request trace. The SDK already emits redacted cs-audit/1 events (RFC-0014); they only needed a path into telemetry that cannot leak secrets or explode metric cardinality, and that never costs a signed audit record.

Binding decision

  • cryptography_suite.audit.fanout.FanOutAuditSink(*sinks) passes every event to 1 to 16 sinks in order. Every sink is attempted even when one fails; the first failure is then re-raised, so the protector’s audit policy applies unchanged.

  • cryptography-suite-opentelemetry provides OpenTelemetryAuditSink(meter, *, span_source=None, max_pending=10000). It takes the application’s Meter (and optionally a function returning the current span, such as opentelemetry.trace.get_current_span) and does not import OpenTelemetry. It may import cryptography_suite.audit in addition to the RFC-0016 modules.

    • cryptosuite.operations, a counter of completed operations;

    • cryptosuite.operation.duration, a histogram in seconds from an operation’s started event to its succeeded or failed event, matched by operation id, with at most max_pending unmatched starts retained (oldest dropped); a negative interval records zero;

    • for each event, when the current span is recording, a span event cryptosuite.<operation>.<outcome>.

  • Attributes. Metrics carry only cryptosuite.operation, cryptosuite.outcome, cryptosuite.provider_id, and the semantic convention error.type (the stable error code). Span events add cryptosuite.operation_id and cryptosuite.policy_id. Event, key, and envelope identifiers never appear in metrics.

Security consequences

Only the allowlisted, redacted cs-audit/1 fields reach telemetry; no plaintext, key material, context value, or provider message can. Telemetry failures do not prevent the audit chain from recording, because the fan-out attempts every sink.

Test and validation requirements

tests/provider_packages/test_opentelemetry.py covers counters, durations, span events, attribute cardinality, unmatched and out-of-order events, the pending bound, non-recording spans, validation, and fan-out with one and several failing sinks. One test runs real Protector operations, including a context mismatch, under a span with the OpenTelemetry SDK’s in-memory metric reader and span exporter (opentelemetry-sdk pinned in requirements-dev.txt), and checks the exported points and span events and that the signed chain received every event.