From ddc27612f69e73938fdb19041d97d81c332db78c Mon Sep 17 00:00:00 2001 From: Dalitso Banda Date: Tue, 20 Jun 2023 11:14:37 -0700 Subject: [PATCH] add spans group test --- snuba/datasets/processors/spans_processor.py | 2 +- tests/datasets/test_spans_processor.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/snuba/datasets/processors/spans_processor.py b/snuba/datasets/processors/spans_processor.py index 6efd98b498..9e3502378d 100644 --- a/snuba/datasets/processors/spans_processor.py +++ b/snuba/datasets/processors/spans_processor.py @@ -275,6 +275,7 @@ def _process_child_span_module_details( processed_span["platform"] = _unicodify(span_data.get("span.system", "")) processed_span["action"] = _unicodify(span_data.get("span.action", "")) processed_span["status"] = span_data.get("span.status_code", 0) + processed_span["group"] = int(span_data.get("span.group", "0"), 16) def _process_span( self, span_dict: SpanDict, common_span_fields: CommonSpanDict @@ -298,7 +299,6 @@ def _process_span( processed_span["is_segment"] = 0 processed_span["op"] = _unicodify(span_dict.get("op", "")) processed_span["group_raw"] = int(span_dict.get("hash", "0"), 16) - processed_span["group"] = int(span_dict.get("group", "0"), 16) processed_span["exclusive_time"] = span_dict.get("exclusive_time", 0) processed_span["description"] = _unicodify(span_dict.get("description", "")) diff --git a/tests/datasets/test_spans_processor.py b/tests/datasets/test_spans_processor.py index 61ade24d80..4269292608 100644 --- a/tests/datasets/test_spans_processor.py +++ b/tests/datasets/test_spans_processor.py @@ -141,6 +141,7 @@ def serialize(self) -> Tuple[int, str, Mapping[str, Any]]: "span.domain": "targetdomain.tld:targetport", "span.module": "http", "span.op": "http.client", + "span.group": "b" * 16, "span.status": "ok", "span.system": self.platform, "span.status_code": 200, @@ -166,6 +167,7 @@ def serialize(self) -> Tuple[int, str, Mapping[str, Any]]: "span.action": "SELECT", "span.module": "db", "span.op": "db", + "span.group": "d" * 16, "span.domain": "sentry_tagkey", "span.system": self.platform, "span.status": "ok", @@ -254,7 +256,7 @@ def build_result(self, meta: KafkaMessageMetadata) -> Sequence[Mapping[str, Any] ), "exclusive_time": 1.2345, "op": self.op, - "group": int("a" * 16, 16), + "group_raw": int("a" * 16, 16), "span_status": SPAN_STATUS_NAME_TO_CODE.get(self.status), "span_kind": "", "description": "", @@ -303,6 +305,7 @@ def build_result(self, meta: KafkaMessageMetadata) -> Sequence[Mapping[str, Any] "exclusive_time": 0.1234, "op": "http.client", "group": int("b" * 16, 16), + "group_raw": int("b" * 16, 16), "span_status": SPAN_STATUS_NAME_TO_CODE.get("ok"), "span_kind": "", "description": "GET /api/0/organizations/sentry/tags/?project=1", @@ -343,7 +346,8 @@ def build_result(self, meta: KafkaMessageMetadata) -> Sequence[Mapping[str, Any] "duration": self.span2_duration, "exclusive_time": 0.4567, "op": "db", - "group": int("c" * 16, 16), + "group": int("d" * 16, 16), + "group_raw": int("c" * 16, 16), "span_status": SPAN_STATUS_NAME_TO_CODE.get("ok"), "span_kind": "", "description": "SELECT `sentry_tagkey`.* FROM `sentry_tagkey`",