Logging Latent Metadata
Sometimes you might want to log additional metadata after a span has already been ingested. This is especially useful when your system enriches interactions with more information that wasn’t available at generation time.
Logging Metadata via the Python SDK
You can attach metadata, corrections, or other enriched information to specific spans using the log_metadata()
function in the Arize Python SDK
Step 1: Set Up the SDK
Step 2: Create Your Metadata Patch
To update metadata on spans, your DataFrame must include:
context.span_id
– identifies the span to updateEither:
A
patch_document
column containing JSON objectsOne or more
attributes.metadata.*
columnsOr both (in which case, the
patch_document
is applied after the field-level updates and will override any conflicting keys)
Example Structures
Type Handling
string
, int
, float
Fully supported
bool
Automatically converted to string ("true"
/ "false"
)
Objects / Arrays
Serialized to JSON strings
None
/ null
Stored as JSON null
(does not remove the field)
⚠️
null
values do not remove fields—they explicitly set them tonull
.
Step 3: Log Metadata
Response Format
Success
Error
Common Error Types
parse_failure
Invalid JSON in patch document
patch_failure
Patch could not be applied
type_conflict
Existing field has a different data type
segment_not_found
Span ID not found
connection_failure
Network or API connectivity issue
druid_rejection
Backend rejected update (e.g., schema mismatch)
Last updated
Was this helpful?