Skip to content

Commit

Permalink
add spans group test
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanda committed Jun 20, 2023
1 parent 51ee7b5 commit ddc2761
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion snuba/datasets/processors/spans_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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", ""))

Expand Down
8 changes: 6 additions & 2 deletions tests/datasets/test_spans_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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`",
Expand Down

0 comments on commit ddc2761

Please sign in to comment.