Safeguard
Security Guides•

Which trace attributes are safe: user ID, tenant, email or session?

Opaque IDs help investigations, but emails, tokens and session values do not belong in traces. A table of common attributes to record and to avoid.

Safeguard Security Team
3 min read

Record opaque internal identifiers that mean nothing outside your systems, such as an account ID or tenant ID. Avoid emails, names, tokens and session values. Anything that would help an attacker or identify a person on its own should stay out of trace attributes.

Why attributes need rules

Trace backends are searched, shared and kept for weeks. Their access list is usually wider than the production database, since developers use them daily. An attribute written once is copied to every span that carries it and to any export.

The OWASP Logging Cheat Sheet recommends not logging session identification values, access tokens, passwords, connection strings and keys directly, and suggests a hashed value for sessions if tracking is needed. The same logic applies to span attributes. It also says personal data may need pseudonymization where identity is not required.

A practical table

AttributeVerdictNotes
Internal account IDRecordOpaque, stable, useful
Tenant IDRecordEssential for multi tenant investigations
User ID, internal and randomRecordPrefer over email
Email addressAvoidPersonal data, searchable by humans
Full name, phoneAvoidPersonal data
Session IDAvoid, or record a hashRaw value can be replayed
Access token, API keyNeverCredential
Request path template, such as users slash idRecordTemplate, not the filled value
Raw URL with queryReviewMay contain tokens, see redacting query strings in spans
SQL statement with valuesAvoidUse the parameterized form
IP addressDecideOften personal data, see IP addresses in logs

Baggage versus attributes

OpenTelemetry documents that baggage is separate from span attributes and is not copied to spans automatically. You choose which baggage keys become attributes, usually through a processor your SDK provides. That is a good checkpoint to apply the table above. See can OpenTelemetry baggage leak sensitive data.

Steps

  1. Write an attribute list: name, type, allowed or not, reason. Keep it in the repository.
  2. Add a lint or review rule: new attribute names need a reviewer from security or the platform team.
  3. Use an allow list in the collector, so unlisted attributes are dropped. See OpenTelemetry collector redaction and filter processors.
  4. Scan a day of spans for emails, tokens and card patterns. Fix what you find at the source.
  5. Set trace retention to match your needs, not the maximum.

A note on correlation

You rarely need an email to correlate. A random user ID joined with your user table, in a place with tight access, gives investigators the link when needed, without spreading the identity across the trace store.

Quick check

Can I hash an email and put it in a span?

A hash of a guessable value like an email can often be reversed by trying candidates. Prefer a random internal ID.

Is a tenant ID sensitive?

Usually an opaque tenant ID is fine. If tenant names reveal customers you cannot disclose, use the ID.

Safeguard scans dependencies and builds SBOMs, covering the instrumentation libraries you ship. A free scan is at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.