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

Function test_trace_data

app/api/tests/public/test_public_api.py:86–126  ·  view source on GitHub ↗

Create test trace data in ClickHouse.

(async_clickhouse_client, test_project_with_api_key, test_trace_id)

Source from the content-addressed store, hash-verified

84
85@pytest.fixture
86async def test_trace_data(async_clickhouse_client, test_project_with_api_key, test_trace_id):
87 """Create test trace data in ClickHouse."""
88 import random
89
90 project = test_project_with_api_key
91 project_id_str = str(project.id)
92
93 # Insert test trace
94 trace_data = {
95 "Timestamp": datetime.now(timezone.utc),
96 "TraceId": test_trace_id,
97 "SpanId": str(random.randint(10**19, 10**20 - 1)), # Unique span ID for the root span
98 "ParentSpanId": "",
99 "TraceState": "",
100 "SpanName": "test_trace",
101 "SpanKind": "SPAN_KIND_INTERNAL",
102 "ServiceName": "test_service",
103 "ResourceAttributes": {"agentops.project.id": project_id_str},
104 "ScopeName": "",
105 "ScopeVersion": "",
106 "SpanAttributes": {"tags": "test,public-api"},
107 "Duration": 1000000,
108 "StatusCode": "STATUS_CODE_OK",
109 "StatusMessage": "",
110 "Events.Timestamp": [],
111 "Events.Name": [],
112 "Events.Attributes": [],
113 "Links.TraceId": [],
114 "Links.SpanId": [],
115 "Links.TraceState": [],
116 "Links.Attributes": [],
117 }
118
119 await async_clickhouse_client.insert(
120 table="otel_traces", data=[list(trace_data.values())], column_names=list(trace_data.keys())
121 )
122
123 yield trace_data
124
125 # Cleanup: delete the trace data after the test
126 await async_clickhouse_client.command(f"DELETE FROM otel_traces WHERE TraceId = '{test_trace_id}'")
127
128
129@pytest.fixture

Callers

nothing calls this directly

Calls 1

insertMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…