Logging Metadata via the Python SDK
You can attach metadata, corrections, or other enriched information to specific spans using thelog_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 update- Either:
- A
patch_documentcolumn containing JSON objects - One or more
attributes.metadata.*columns - Or both (in which case, the
patch_documentis applied after the field-level updates and will override any conflicting keys)
- A
Example Structures
Type Handling
| Input Type | Behavior |
|---|---|
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) |
⚠️nullvalues do not remove fields—they explicitly set them tonull.
Step 3: Log Metadata
Response Format
Success
Error
Common Error Types
| Error Type | Description |
|---|---|
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) |