Create test span data in ClickHouse.
(async_clickhouse_client, test_trace_data, test_span_id, test_trace_id)
| 128 | |
| 129 | @pytest.fixture |
| 130 | async def test_span_data(async_clickhouse_client, test_trace_data, test_span_id, test_trace_id): |
| 131 | """Create test span data in ClickHouse.""" |
| 132 | # Use the same project ID as the trace data |
| 133 | project_id_str = test_trace_data["ResourceAttributes"]["agentops.project.id"] |
| 134 | |
| 135 | # Insert test span |
| 136 | span_data = { |
| 137 | "Timestamp": datetime.now(timezone.utc), |
| 138 | "TraceId": test_trace_id, |
| 139 | "SpanId": test_span_id, |
| 140 | "ParentSpanId": "", |
| 141 | "TraceState": "", |
| 142 | "SpanName": "test_span", |
| 143 | "SpanKind": "SPAN_KIND_INTERNAL", |
| 144 | "ServiceName": "test_service", |
| 145 | "ResourceAttributes": {"agentops.project.id": project_id_str, "service.name": "test_service"}, |
| 146 | "ScopeName": "", |
| 147 | "ScopeVersion": "", |
| 148 | "SpanAttributes": {"operation": "test", "test": "value"}, |
| 149 | "Duration": 1000000, # 1ms in nanoseconds |
| 150 | "StatusCode": "STATUS_CODE_OK", |
| 151 | "StatusMessage": "", |
| 152 | "Events.Timestamp": [], |
| 153 | "Events.Name": [], |
| 154 | "Events.Attributes": [], |
| 155 | "Links.TraceId": [], |
| 156 | "Links.SpanId": [], |
| 157 | "Links.TraceState": [], |
| 158 | "Links.Attributes": [], |
| 159 | } |
| 160 | |
| 161 | await async_clickhouse_client.insert( |
| 162 | table="otel_traces", data=[list(span_data.values())], column_names=list(span_data.keys()) |
| 163 | ) |
| 164 | |
| 165 | yield span_data |
| 166 | |
| 167 | # Cleanup: delete the span data after the test |
| 168 | await async_clickhouse_client.command(f"DELETE FROM otel_traces WHERE SpanId = '{test_span_id}'") |
| 169 | |
| 170 | |
| 171 | @pytest.fixture |
nothing calls this directly
no test coverage detected
searching dependent graphs…