Skip to content

bug(py): RedactedSpan crashes OTLP export with AttributeError on dropped_attributes #4493

@yesudeep

Description

@yesudeep

Description

The RedactedSpan wrapper class in genkit.core.trace.adjusting_exporter causes an
AttributeError when the OTLP trace encoder tries to serialize spans for export to
backends like AWS X-Ray.

Error

AttributeError: 'TimeAdjustedSpan' object has no attribute '_attributes'

Full traceback:

opentelemetry/.../trace_encoder/__init__.py:130 in _encode_span
    dropped_attributes_count=sdk_span.dropped_attributes,

opentelemetry/sdk/trace/__init__.py:412 in dropped_attributes
    if isinstance(self._attributes, BoundedAttributes):
                  ^^^^^^^^^^^^^^^^
AttributeError: 'TimeAdjustedSpan' object has no attribute '_attributes'

Root Cause

RedactedSpan (and its subclass TimeAdjustedSpan) wraps a ReadableSpan without
calling super().__init__(). This is intentional to avoid duplicating span state.
However, three properties in the base ReadableSpan class access private instance
variables that are only set by ReadableSpan.__init__():

  • dropped_attributes → accesses self._attributes
  • dropped_events → accesses self._events
  • dropped_links → accesses self._links

Since RedactedSpan.__init__() never calls super().__init__(), these private
fields don't exist, and the OTLP encoder crashes when it tries to serialize
span metadata.

Impact

Any telemetry plugin that uses AdjustingTraceExporter (AWS Bedrock, Google Cloud,
etc.) will crash at span export time, silently dropping all trace data.

Fix

Add dropped_attributes, dropped_events, and dropped_links property overrides
to RedactedSpan that delegate to self._span (the wrapped span).

Files

  • py/packages/genkit/src/genkit/core/trace/adjusting_exporter.py
  • py/packages/genkit/tests/genkit/core/trace/adjusting_exporter_test.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpythonPython

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions