Skip to content

Commit 4d083ff

Browse files
k-fishDav1dde
andauthored
feat(tracemetrics): Allow filtering co-occurring keys (#5260)
### Summary Trace metrics has a blocker of having the available group-by and autocomplete keys being limited to the metric name selected instead of every attribute key ever ingested. Due to how the trace item filter rpc (and eap tables) are currently setup, this is only currently possible with an 'AND' on the key presence, so this is a workaround adding two temporary meta attributes that will let us experiment with this behaviour before open beta. more details [here](https://www.notion.so/sentry/Metric-Co-occurring-Attributes-2878b10e4b5d80f5a9e5ca200179b4df) --------- Co-authored-by: David Herberth <[email protected]>
1 parent 671fd86 commit 4d083ff

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
**Internal**:
6+
7+
- Add internal attributes to aid searching trace metrics ([#5260](https://github.com/getsentry/relay/pull/5260))
8+
39
## 25.10.0
410

511
**Features**:

relay-server/src/processing/trace_metrics/store.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ fn attributes(
153153
result.insert(
154154
"sentry.metric_name".to_owned(),
155155
AnyValue {
156-
value: Some(any_value::Value::StringValue(metric_name)),
156+
value: Some(any_value::Value::StringValue(metric_name.clone())),
157157
},
158158
);
159159

@@ -164,6 +164,20 @@ fn attributes(
164164
},
165165
);
166166

167+
// Add key names matching metric name and type to workaround current co-occuring attributes limitations.
168+
result.insert(
169+
format!("sentry._internal.cooccuring.name.{metric_name}"),
170+
AnyValue {
171+
value: Some(any_value::Value::BoolValue(true)),
172+
},
173+
);
174+
result.insert(
175+
format!("sentry._internal.cooccuring.type.{metric_type}"),
176+
AnyValue {
177+
value: Some(any_value::Value::BoolValue(true)),
178+
},
179+
);
180+
167181
result.insert(
168182
"sentry.value".to_owned(),
169183
AnyValue {

tests/integration/test_trace_metrics.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ def test_trace_metric_extraction(
9999
"sentry.browser.version": {"stringValue": mock.ANY},
100100
"http.method": {"stringValue": "GET"},
101101
"http.status_code": {"intValue": "200"},
102+
"sentry._internal.cooccuring.name.http.request.duration": {
103+
"boolValue": True
104+
},
105+
"sentry._internal.cooccuring.type.distribution": {"boolValue": True},
102106
},
103107
"clientSampleRate": 1.0,
104108
"downsampledRetentionDays": 390,
@@ -243,6 +247,8 @@ def test_trace_metric_pii_scrubbing(
243247
"sentry._meta.fields.attributes.user.ip": {
244248
"stringValue": '{"meta":{"value":{"":{"rem":[["strip_ips","x",0,0]],"len":11}}}}'
245249
},
250+
"sentry._internal.cooccuring.name.test.metric": {"boolValue": True},
251+
"sentry._internal.cooccuring.type.counter": {"boolValue": True},
246252
},
247253
"clientSampleRate": 1.0,
248254
"downsampledRetentionDays": 90,

0 commit comments

Comments
 (0)