MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / clickhouse_update_span

Function clickhouse_update_span

app/api/agentops/exporter/processor.py:451–477  ·  view source on GitHub ↗

Update a record in ClickHouse by deleting and re-inserting it.

(span_id: str, update_data: dict)

Source from the content-addressed store, hash-verified

449
450
451async def clickhouse_update_span(span_id: str, update_data: dict) -> None:
452 """Update a record in ClickHouse by deleting and re-inserting it."""
453 # reasons for going this route at the moment:
454 # - serialization is a bitch and there is no tooling readily available to help with it
455 # - latency for propagation of updates is apparently comparable to deletion
456
457 def merge_dicts_recursive(old, new):
458 result = old.copy()
459 for key, value in new.items():
460 if key in result and isinstance(result[key], dict) and isinstance(value, dict):
461 result[key] = merge_dicts_recursive(result[key], value)
462 else:
463 result[key] = value
464 return result
465
466 existing_span: dict = await clickhouse_get_span_raw(span_id)
467 if existing_span:
468 await clickhouse_delete_span(span_id) # yolo
469 else:
470 existing_span = {}
471
472 merged_data = merge_dicts_recursive(existing_span, update_data)
473 await clickhouse_create(
474 [
475 merged_data,
476 ]
477 )
478
479
480async def write_trace_with_timeout(trace: Trace) -> None:

Callers 5

update_sessionFunction · 0.85
update_llm_eventFunction · 0.85
update_action_eventFunction · 0.85
update_tool_eventFunction · 0.85
update_error_eventFunction · 0.85

Calls 4

clickhouse_get_span_rawFunction · 0.85
clickhouse_delete_spanFunction · 0.85
merge_dicts_recursiveFunction · 0.85
clickhouse_createFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…