feat(observability): client-side redaction of PII/secrets in telemetry spans#256
Merged
Merged
Conversation
Port client-side OTEL span redaction from the private SDK (#342): - RedactingSpanExporter and reusable redaction policies (regex, attribute, callback) with exported DEFAULT_* constants - configureTelemetry gains a redaction option (on by default in dedicated mode); warns when ignored in global/custom modes - shutdownTelemetry to flush and shut down the SDK-owned provider - bundler-ignore magic comments on the lazy OTel import - OTel SDK/exporter/resources declared as optional peerDependencies - README section, TOC entry, and examples/src/observability Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
simonvdk-mistral
marked this pull request as ready for review
July 16, 2026 12:50
Yousria
approved these changes
Jul 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds client-side redaction of OpenTelemetry spans emitted by the SDK, so PII and secrets are stripped before spans leave the process.
New public API (
@mistralai/mistralai/extra/observability)RedactingSpanExporter— wraps any OTELSpanExporterand redacts span attributes, events, links, and resource attributes before delegating export. Reusable by any OpenTelemetry application, independent of the Mistral client.RegexRedactionPolicy(default) — content-oriented: keeps keys/structure, redacts matched substrings (secret tokens plus PII: emails, card-like sequences, IPv4).AttributeRedactionPolicy— key-oriented: redacts whole values for sensitive keys, then scans kept values for secret tokens.CallbackRedactionPolicy— a(key, value) => value | undefinedmasker for full control (can drop attributes entirely).configureTelemetry(client, provider?, options?)gains aredactionoption:false, a policy instance, or a callback to customize.RedactingSpanExporterto redact there.shutdownTelemetry(client)— flushes and shuts down the SDK-owned provider so short-lived programs export buffered spans before exiting.Other changes
examples/src/observability/(dedicated mode, global provider with redaction, custom/extended policies).Usage
Testing
npm run build— cleannpm run lint— 0 warnings / 0 errorstests/— 174/174 pass (new: 18 redaction, 47 policy, +11 telemetry)