EnrichedReadableSpan Class
Wrapper to add attributes to an immutable ReadableSpan.
Since ReadableSpan is immutable after a span ends, this wrapper allows extensions to add additional attributes before export without modifying the original span.
Constructor
EnrichedReadableSpan(span: ReadableSpan, extra_attributes: dict[str, Any], excluded_attribute_keys: Set[str] | None = None)
Parameters
| Name | Description |
|---|---|
|
span
Required
|
|
|
extra_attributes
Required
|
|
|
excluded_attribute_keys
|
Default value: None
|
Methods
| get_span_context | |
| to_json |
Convert span to JSON string with enriched attributes. |
get_span_context
get_span_context()
to_json
Convert span to JSON string with enriched attributes.
to_json(indent: int | None = 4) -> str
Parameters
| Name | Description |
|---|---|
|
indent
|
JSON indentation level. Default value: 4
|
Returns
| Type | Description |
|---|---|
|
JSON string representation of the span. |
Attributes
attributes
Return merged attributes from original span and extra attributes.