1
1
from collections import defaultdict
2
2
from typing import Any , cast
3
3
4
- # TODO(ja): Fix and update the schema
5
- from sentry_kafka_schemas .schema_types .buffered_segments_v1 import _MeasurementValue
6
-
7
4
from sentry .models .project import Project
8
- from sentry .spans .consumers .process_segments .types import Span
5
+ from sentry .spans .consumers .process_segments .types import MeasurementValue , Span
9
6
10
7
# Keys in `sentry_tags` that are shared across all spans in a segment. This list
11
8
# is taken from `extract_shared_tags` in Relay.
@@ -195,7 +192,7 @@ def compute_breakdowns(segment: Span, spans: list[Span], project: Project) -> No
195
192
measurements [f"{ breakdown_name } .{ key } " ] = value
196
193
197
194
198
- def _compute_span_ops (spans : list [Span ], config : Any ) -> dict [str , _MeasurementValue ]:
195
+ def _compute_span_ops (spans : list [Span ], config : Any ) -> dict [str , MeasurementValue ]:
199
196
matches = config .get ("matches" )
200
197
if not matches :
201
198
return {}
@@ -206,7 +203,7 @@ def _compute_span_ops(spans: list[Span], config: Any) -> dict[str, _MeasurementV
206
203
if operation_name := next (filter (lambda m : op .startswith (m ), matches ), None ):
207
204
intervals_by_op [operation_name ].append (_span_interval (span ))
208
205
209
- measurements : dict [str , _MeasurementValue ] = {}
206
+ measurements : dict [str , MeasurementValue ] = {}
210
207
for operation_name , intervals in intervals_by_op .items ():
211
208
duration = _get_duration_us (intervals )
212
209
measurements [f"ops.{ operation_name } " ] = {"value" : duration / 1000 , "unit" : "millisecond" }
0 commit comments