Drop attributes and spans
This page shows you how to withhold named attributes, or leave whole spans out of a trace, so that content no other redaction rule covers stays inside your application.
Use these two settings for content that doesn't belong to a tool, such as a chain's scratchpad or an output parser that echoes its own input:
redact_attributesreplaces the value of each named attribute with a fingerprint. The attribute still appears in the trace.suppress_spansstops each named span from being created, along with every span under it.
You set both in your application code with aio.redaction_policy(...). Neither one has an environment variable, and both are off by default. Your application's requests don't change. Only the telemetry sent to AIO changes.
Prerequisites
- The Python SDK is installed and sends traces. For more information, see Instrument your code.
- You know the attribute keys or span names you want to withhold. To find a span's name, open the trace in the UI. The header of the step detail pane shows the span name. For more information, see Explore traces.
Withhold named attributes
- Pass the attribute keys to
redact_attributesinaio.redaction_policy(...). - Pass the policy to
aio.initthrough theredactionargument. Callaio.initonce, at startup, before you create any HTTP or model clients.
In the following example, replace my_app.scratchpad and my_app.parser_input with the attribute keys you want to withhold:
import acceldata_aio_tracer as aio
aio.init(
redaction=aio.redaction_policy(
redact_attributes=["my_app.scratchpad", "my_app.parser_input"],
),
)
Here's what happens to each listed attribute:
- Applies to all telemetry. The rule checks every span and log record, whatever the span or tool.
- Replaced, not removed. If the attribute is present and not empty, its value becomes a fingerprint:
sha256:followed by the SHA-256 hash of the value. The same value always produces the same fingerprint. - Other rules win. If another redaction rule already changed the attribute, that rule's result stays.
Leave whole spans out of a trace
- Pass the span names to
suppress_spansinaio.redaction_policy(...). - Pass the policy to
aio.initthrough theredactionargument. Callaio.initonce, at startup, before you create any HTTP or model clients.
In the following example, replace my_chain with the name of the span you want to leave out:
import acceldata_aio_tracer as aio
aio.init(
redaction=aio.redaction_policy(
suppress_spans=["my_chain"],
),
)
A span matches if its full name is in the list, or if the part of its name after the first space is in the list. For example, my_chain matches a span named invoke_agent my_chain.
Here's what happens to a matching span:
- Never created. The span isn't created, so its content is never built.
- Children dropped too. Every span under it is left out of the trace as well.
- Other spans unaffected. Spans that don't match are recorded as usual.
Caution
Any real work under a suppressed span is lost without a warning. Suppress a span only when everything beneath it is plumbing.
Use both settings in one policy
One policy can withhold attributes and suppress spans at the same time. You can also combine these settings with the other redaction settings.
import acceldata_aio_tracer as aio
aio.init(
redaction=aio.redaction_policy(
redact_attributes=["my_app.scratchpad"],
suppress_spans=["my_chain"],
),
)
aio.init applies a policy only on its first call. A second call returns True without applying the new policy, so put all of your settings in the policy you pass the first time.
Troubleshooting
- The policy has no effect. Check that the first call to
aio.initpasses the policy. Later calls don't apply a new one. aio.initraisesRedactionUnavailable. Your application set up an OpenTelemetryTracerProviderbefore it calledaio.init, so the SDK can't redact span content. The message reads: "aio: redaction is configured, but this application already set up an OpenTelemetry TracerProvider. Redaction is applied by the span exporter, which that provider does not use, so span content would be exported unredacted. Call aio.init() before configuring OpenTelemetry." Callaio.initbefore you configure OpenTelemetry.
Next steps
- Overview: learn what redaction withholds and how withheld content appears in the UI.
- Redact tool arguments and results: withhold what specific tools receive or return.
- Redact by pattern: scrub text that matches patterns.
- Python SDK: see every parameter of
aio.redaction_policy.

Have a suggestion?