Skip to content

Commit 9b92901

Browse files
authored
feat(metrics): Tag metrics by transaction name [INGEST-542] (#1126)
1 parent 8b3cf4d commit 9b92901

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
**Features**:
66

77
- Add bucket width to bucket protocol. ([#1103](https://github.com/getsentry/relay/pull/1103))
8-
- Support multiple kafka cluster configurations ([#1101](https://github.com/getsentry/relay/pull/1101))
8+
- Support multiple kafka cluster configurations. ([#1101](https://github.com/getsentry/relay/pull/1101))
9+
- Tag metrics by transaction name. ([#1126](https://github.com/getsentry/relay/pull/1126))
910

1011
**Bug Fixes**:
1112

relay-server/src/actors/envelopes.rs

+5
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,9 @@ fn extract_transaction_metrics(event: &Event, target: &mut Vec<Metric>) {
434434
if let Some(environment) = event.environment.as_str() {
435435
tags.insert("environment".to_owned(), environment.to_owned());
436436
}
437+
if let Some(transaction) = event.transaction.as_str() {
438+
tags.insert("transaction".to_owned(), transaction.to_owned());
439+
}
437440

438441
if let Some(measurements) = event.measurements.value() {
439442
for (name, annotated) in measurements.iter() {
@@ -3266,6 +3269,7 @@ mod tests {
32663269
"timestamp": "2021-04-26T08:00:00+0100",
32673270
"release": "1.2.3",
32683271
"environment": "fake_environment",
3272+
"transaction": "mytransaction",
32693273
"measurements": {
32703274
"foo": {"value": 420.69}
32713275
},
@@ -3296,6 +3300,7 @@ mod tests {
32963300
assert!(matches!(metric.value, MetricValue::Distribution(_)));
32973301
assert_eq!(metric.tags["release"], "1.2.3");
32983302
assert_eq!(metric.tags["environment"], "fake_environment");
3303+
assert_eq!(metric.tags["transaction"], "mytransaction");
32993304
}
33003305
}
33013306

tests/integration/test_metrics.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -455,30 +455,31 @@ def test_transaction_metrics(
455455

456456
metrics = metrics_by_name(metrics_consumer, 3)
457457

458-
assert metrics["measurement.foo"] == {
458+
common = {
459+
"timestamp": int(timestamp.timestamp()),
459460
"org_id": 1,
460461
"project_id": 42,
461-
"timestamp": int(timestamp.timestamp()),
462+
"tags": {"transaction": "/organizations/:orgId/performance/:eventSlug/"},
463+
}
464+
465+
assert metrics["measurement.foo"] == {
466+
**common,
462467
"name": "measurement.foo",
463468
"type": "d",
464469
"unit": "",
465470
"value": [1.2, 2.2],
466471
}
467472

468473
assert metrics["measurement.bar"] == {
469-
"org_id": 1,
470-
"project_id": 42,
471-
"timestamp": int(timestamp.timestamp()),
474+
**common,
472475
"name": "measurement.bar",
473476
"type": "d",
474477
"unit": "",
475478
"value": [1.3],
476479
}
477480

478481
assert metrics["breakdown.breakdown1.baz"] == {
479-
"org_id": 1,
480-
"project_id": 42,
481-
"timestamp": int(timestamp.timestamp()),
482+
**common,
482483
"name": "breakdown.breakdown1.baz",
483484
"type": "d",
484485
"unit": "",

0 commit comments

Comments
 (0)