Privacy

Test PII Redaction in OpenTelemetry Pipelines With Synthetic Data

Prove your scrubbing rules work, without ever putting real people's data at risk.

Telemetry often carries personal data by accident: an email in a URL, a name in a log message, a user ID in a span attribute. Scrubbing it in the Collector is common, and so is shipping a rule that does not work. Because you must never test redaction with real personal data, you need realistic fake data that is clearly labelled. OTel Studio's synthetic PII feature is built for that.

What synthetic PII adds

On any scenario's Advanced settings, turn on Synthetic PII. The root span and the logs of every request then carry user.id, user.name and user.email, generated from a fixed pool of names and email addresses on reserved example domains (example.com, example.org, example.net) — never real people. Every record is also marked pii.synthetic: true, so a pipeline under test, or an assertion, can tell the fake personal data from anything real. Banking, Social Network and E-Commerce are good scenarios to use.

A redaction configuration to test

Two Collector processors handle most cases. The attributes processor deletes, hashes or replaces named attributes; the redaction processor (contrib) masks values that match patterns, such as anything that looks like an email address:

processors:
  attributes/pii:
    actions:
      - key: user.email
        action: delete
      - key: user.name
        action: hash
  redaction:
    allow_all_keys: true
    blocked_values:
      - '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}'   # email-shaped values anywhere
    summary: info

service:
  pipelines:
    traces: { receivers: [otlp], processors: [attributes/pii, redaction, batch], exporters: [otlp/backend] }
    logs:   { receivers: [otlp], processors: [attributes/pii, redaction, batch], exporters: [otlp/backend] }

Test it in four steps

  1. Prove the data is there first. Send traffic with the Collector's debug exporter at verbosity: detailed and without your redaction processors. Confirm you can see user.email on spans and on logs. A test that cannot fail proves nothing.
  2. Turn the processors on and send again. In the backend, search for pii.synthetic = true records that still have a user.email attribute. The answer must be none.
  3. Check the other places an email can hide. Search log bodies and span names and URL attributes for the example domains (@example.com). The attributes processor only touches keys you named; the redaction processor catches values.
  4. Check you did not remove too much. Traces must still be complete, services still identifiable, and the hashed user.name still stable enough to group by. Redaction that breaks correlation is its own bug.
Make the check automatic. Because the fake data has a marker and reserved domains, you can write a permanent test: run OTel Studio in CI for a minute with Synthetic PII on (see Run OTel Studio in CI), then query your backend for pii.synthetic = true with a surviving user.email, and fail the build if any exist.

Remember the limits

Keep going