Test PII Redaction in OpenTelemetry Pipelines With Synthetic Data
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
- Prove the data is there first. Send traffic with the Collector's
debugexporter atverbosity: detailedand without your redaction processors. Confirm you can seeuser.emailon spans and on logs. A test that cannot fail proves nothing. - Turn the processors on and send again. In the backend, search for
pii.synthetic = truerecords that still have auser.emailattribute. The answer must be none. - Check the other places an email can hide. Search log bodies and span names and URL attributes for the example domains (
@example.com). Theattributesprocessor only touches keys you named; theredactionprocessor catches values. - Check you did not remove too much. Traces must still be complete, services still identifiable, and the hashed
user.namestill stable enough to group by. Redaction that breaks correlation is its own bug.
pii.synthetic = true with a surviving user.email, and fail the build if any exist.Remember the limits
- Synthetic PII tests pattern and key rules. It cannot find a leak in a field it does not populate, so keep a list of every place your real applications could put personal data.
- Redaction at the Collector does not protect data that reaches other destinations before the Collector, or local files and consoles. Treat it as one layer.
- Redaction processors cost CPU on large batches. Run the same test at volume — see Load-Test and Size a Backend.