diff --git a/relay-general/src/store/regexes.rs b/relay-general/src/store/regexes.rs index f0be2a7f52..7f1767d3f7 100644 --- a/relay-general/src/store/regexes.rs +++ b/relay-general/src/store/regexes.rs @@ -95,7 +95,9 @@ pub static CACHE_NORMALIZER_REGEX: Lazy = Lazy::new(|| { # Capture hex. (([\s.+:/\-])+(?P[a-fA-F0-9]+\b)+) | # Capture segments, in form of`:{hi}:` - (([\s.+:/\-])+(?P\{[^\}]*\})+) + (([\s.+:/\-])+(?P\{[^\}]*\})+) | + # Capture everything if above regex could not match. + ([\s]+(?P[^:/\-]+$)) "#, ) .unwrap() diff --git a/relay-general/src/store/transactions/processor.rs b/relay-general/src/store/transactions/processor.rs index 1a57513e50..fa2c7605e5 100644 --- a/relay-general/src/store/transactions/processor.rs +++ b/relay-general/src/store/transactions/processor.rs @@ -440,7 +440,7 @@ fn scrub_sql_queries(string: &mut Annotated) -> Result) -> Result { +fn scrub_redis_keys(string: &mut Annotated) -> Result { scrub_identifiers_with_regex(string, &CACHE_NORMALIZER_REGEX, "*") } @@ -620,8 +620,8 @@ fn scrub_span_description(span: &mut Span) -> Result<(), ProcessingAction> { let did_scrub = match span.op.value() { Some(op) if op.starts_with("http") => scrub_identifiers(&mut scrubbed)?, - Some(op) if op.starts_with("db") => scrub_sql_queries(&mut scrubbed)?, - Some(op) if op.starts_with("cache") => scrub_cache_keys(&mut scrubbed)?, + Some(op) if op.starts_with("cache") || op == "db.redis" => scrub_redis_keys(&mut scrubbed)?, + Some(op) if op.starts_with("db") && op != "db.redis" => scrub_sql_queries(&mut scrubbed)?, Some(op) if op.starts_with("resource") => scrub_resource_identifiers(&mut scrubbed)?, _ => false, }; diff --git a/relay-server/src/metrics_extraction/spans/mod.rs b/relay-server/src/metrics_extraction/spans/mod.rs index f6a14f1b10..bdd971e887 100644 --- a/relay-server/src/metrics_extraction/spans/mod.rs +++ b/relay-server/src/metrics_extraction/spans/mod.rs @@ -1001,6 +1001,28 @@ mod tests { "cache.hit": false } }, + { + "description": "GET test:123:def", + "op": "db.redis", + "parent_span_id": "8f5a2b8768cafb4e", + "span_id": "bb7af8b99e95af5f", + "start_timestamp": 1597976300.0000000, + "timestamp": 1597976302.0000000, + "trace_id": "ff62a8b040f340bda5d830223def1d81", + "status": "ok", + "data": {} + }, + { + "description": "GET lkjasdlkasjdlasjdlkasjdlkasjd", + "op": "db.redis", + "parent_span_id": "8f5a2b8768cafb4e", + "span_id": "bb7af8b99e95af5f", + "start_timestamp": 1597976300.0000000, + "timestamp": 1597976302.0000000, + "trace_id": "ff62a8b040f340bda5d830223def1d81", + "status": "ok", + "data": {} + }, { "description": "http://domain/static/myscript-v1.9.23.js", "op": "resource.script", diff --git a/relay-server/src/metrics_extraction/spans/snapshots/relay_server__metrics_extraction__spans__tests__extract_span_metrics-2.snap b/relay-server/src/metrics_extraction/spans/snapshots/relay_server__metrics_extraction__spans__tests__extract_span_metrics-2.snap index 64a03f9a6c..15c5a75df8 100644 --- a/relay-server/src/metrics_extraction/spans/snapshots/relay_server__metrics_extraction__spans__tests__extract_span_metrics-2.snap +++ b/relay-server/src/metrics_extraction/spans/snapshots/relay_server__metrics_extraction__spans__tests__extract_span_metrics-2.snap @@ -1624,6 +1624,164 @@ expression: metrics "transaction.op": "myop", }, }, + Metric { + name: "s:spans/user@none", + value: Set( + 933084975, + ), + timestamp: UnixTimestamp(1619420400), + tags: { + "environment": "fake_environment", + "http.status_code": "200", + "span.category": "db", + "span.description": "GET test:*:*", + "span.group": "2c1e35c1f77934da", + "span.module": "db", + "span.op": "db.redis", + "span.status": "ok", + "transaction": "gEt /api/:version/users/", + "transaction.method": "POST", + "transaction.op": "myop", + }, + }, + Metric { + name: "d:spans/exclusive_time@millisecond", + value: Distribution( + 2000.0, + ), + timestamp: UnixTimestamp(1619420400), + tags: { + "environment": "fake_environment", + "http.status_code": "200", + "span.category": "db", + "span.description": "GET test:*:*", + "span.group": "2c1e35c1f77934da", + "span.module": "db", + "span.op": "db.redis", + "span.status": "ok", + "transaction": "gEt /api/:version/users/", + "transaction.method": "POST", + "transaction.op": "myop", + }, + }, + Metric { + name: "d:spans/exclusive_time_light@millisecond", + value: Distribution( + 2000.0, + ), + timestamp: UnixTimestamp(1619420400), + tags: { + "environment": "fake_environment", + "http.status_code": "200", + "span.category": "db", + "span.description": "GET test:*:*", + "span.group": "2c1e35c1f77934da", + "span.module": "db", + "span.op": "db.redis", + "span.status": "ok", + "transaction.method": "POST", + "transaction.op": "myop", + }, + }, + Metric { + name: "d:spans/duration@millisecond", + value: Distribution( + 2000.0, + ), + timestamp: UnixTimestamp(1619420400), + tags: { + "environment": "fake_environment", + "http.status_code": "200", + "span.category": "db", + "span.description": "GET test:*:*", + "span.group": "2c1e35c1f77934da", + "span.module": "db", + "span.op": "db.redis", + "span.status": "ok", + "transaction": "gEt /api/:version/users/", + "transaction.method": "POST", + "transaction.op": "myop", + }, + }, + Metric { + name: "s:spans/user@none", + value: Set( + 933084975, + ), + timestamp: UnixTimestamp(1619420400), + tags: { + "environment": "fake_environment", + "http.status_code": "200", + "span.category": "db", + "span.description": "GET *", + "span.group": "37e3d9fab1ae9162", + "span.module": "db", + "span.op": "db.redis", + "span.status": "ok", + "transaction": "gEt /api/:version/users/", + "transaction.method": "POST", + "transaction.op": "myop", + }, + }, + Metric { + name: "d:spans/exclusive_time@millisecond", + value: Distribution( + 2000.0, + ), + timestamp: UnixTimestamp(1619420400), + tags: { + "environment": "fake_environment", + "http.status_code": "200", + "span.category": "db", + "span.description": "GET *", + "span.group": "37e3d9fab1ae9162", + "span.module": "db", + "span.op": "db.redis", + "span.status": "ok", + "transaction": "gEt /api/:version/users/", + "transaction.method": "POST", + "transaction.op": "myop", + }, + }, + Metric { + name: "d:spans/exclusive_time_light@millisecond", + value: Distribution( + 2000.0, + ), + timestamp: UnixTimestamp(1619420400), + tags: { + "environment": "fake_environment", + "http.status_code": "200", + "span.category": "db", + "span.description": "GET *", + "span.group": "37e3d9fab1ae9162", + "span.module": "db", + "span.op": "db.redis", + "span.status": "ok", + "transaction.method": "POST", + "transaction.op": "myop", + }, + }, + Metric { + name: "d:spans/duration@millisecond", + value: Distribution( + 2000.0, + ), + timestamp: UnixTimestamp(1619420400), + tags: { + "environment": "fake_environment", + "http.status_code": "200", + "span.category": "db", + "span.description": "GET *", + "span.group": "37e3d9fab1ae9162", + "span.module": "db", + "span.op": "db.redis", + "span.status": "ok", + "transaction": "gEt /api/:version/users/", + "transaction.method": "POST", + "transaction.op": "myop", + }, + }, Metric { name: "s:spans/user@none", value: Set( diff --git a/relay-server/src/metrics_extraction/spans/snapshots/relay_server__metrics_extraction__spans__tests__extract_span_metrics.snap b/relay-server/src/metrics_extraction/spans/snapshots/relay_server__metrics_extraction__spans__tests__extract_span_metrics.snap index f3141b2fb4..bac0937ec8 100644 --- a/relay-server/src/metrics_extraction/spans/snapshots/relay_server__metrics_extraction__spans__tests__extract_span_metrics.snap +++ b/relay-server/src/metrics_extraction/spans/snapshots/relay_server__metrics_extraction__spans__tests__extract_span_metrics.snap @@ -1441,6 +1441,142 @@ expression: event.value().unwrap().spans }, other: {}, }, + Span { + timestamp: Timestamp( + 2020-08-21T02:18:22Z, + ), + start_timestamp: Timestamp( + 2020-08-21T02:18:20Z, + ), + exclusive_time: 2000.0, + description: "GET test:123:def", + op: "db.redis", + span_id: SpanId( + "bb7af8b99e95af5f", + ), + parent_span_id: SpanId( + "8f5a2b8768cafb4e", + ), + trace_id: TraceId( + "ff62a8b040f340bda5d830223def1d81", + ), + status: Ok, + tags: ~, + origin: ~, + data: { + "description.scrubbed": String( + "GET test:*:*", + ), + "environment": String( + "fake_environment", + ), + "http.status_code": String( + "200", + ), + "release": String( + "1.2.3", + ), + "span.category": String( + "db", + ), + "span.description": String( + "GET test:*:*", + ), + "span.group": String( + "2c1e35c1f77934da", + ), + "span.module": String( + "db", + ), + "span.op": String( + "db.redis", + ), + "span.status": String( + "ok", + ), + "transaction": String( + "gEt /api/:version/users/", + ), + "transaction.method": String( + "POST", + ), + "transaction.op": String( + "myop", + ), + "user": String( + "id:user123", + ), + }, + other: {}, + }, + Span { + timestamp: Timestamp( + 2020-08-21T02:18:22Z, + ), + start_timestamp: Timestamp( + 2020-08-21T02:18:20Z, + ), + exclusive_time: 2000.0, + description: "GET lkjasdlkasjdlasjdlkasjdlkasjd", + op: "db.redis", + span_id: SpanId( + "bb7af8b99e95af5f", + ), + parent_span_id: SpanId( + "8f5a2b8768cafb4e", + ), + trace_id: TraceId( + "ff62a8b040f340bda5d830223def1d81", + ), + status: Ok, + tags: ~, + origin: ~, + data: { + "description.scrubbed": String( + "GET *", + ), + "environment": String( + "fake_environment", + ), + "http.status_code": String( + "200", + ), + "release": String( + "1.2.3", + ), + "span.category": String( + "db", + ), + "span.description": String( + "GET *", + ), + "span.group": String( + "37e3d9fab1ae9162", + ), + "span.module": String( + "db", + ), + "span.op": String( + "db.redis", + ), + "span.status": String( + "ok", + ), + "transaction": String( + "gEt /api/:version/users/", + ), + "transaction.method": String( + "POST", + ), + "transaction.op": String( + "myop", + ), + "user": String( + "id:user123", + ), + }, + other: {}, + }, Span { timestamp: Timestamp( 2020-08-21T02:18:22Z,