_encode_events
assumes that event.attributes.dropped
exists
#3761
Labels
_encode_events
assumes that event.attributes.dropped
exists
#3761
This line:
opentelemetry-python/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/trace_encoder/__init__.py
Line 139 in 8ad10f7
is essentially assuming that
event.attributes
is aBoundedAttributes
, but its type is declared astypes.Attributes
, i.e.Optional[Mapping[str, AttributeValue]]
. This means thatevent.attributes
could easily be another mapping such asdict
or evenNone
in which case trying to access.dropped
raisesAttributeError
.Just above in the same file is an example of one good way to solve this:
opentelemetry-python/exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/trace_encoder/__init__.py
Line 122 in 8ad10f7
i.e. a property
Event.dropped_attributes
identical toReadableSpan.dropped_attributes
could be created.For context, I encountered this problem while creating modified copies of
Event
objects in which sensitive data is removed in a customSpanProcessor
.The text was updated successfully, but these errors were encountered: