Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions relay-conventions/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ convention_attributes!(
IS_REMOTE => "sentry.is_remote",
MESSAGING_SYSTEM => "messaging.system",
NORMALIZED_DB_QUERY => "sentry.normalized_db_query",
NORMALIZED_DB_QUERY_HASH => "sentry.normalized_db_query.hash",
OBSERVED_TIMESTAMP_NANOS => "sentry.observed_timestamp_nanos",
OP => "sentry.op",
ORIGIN => "sentry.origin",
Expand Down
12 changes: 12 additions & 0 deletions relay-event-normalization/src/eap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,11 @@ pub fn normalize_db_attributes(annotated_attributes: &mut Annotated<Attributes>)

if let Some(attributes) = annotated_attributes.value_mut() {
if let Some(normalized_db_query) = normalized_db_query {
let mut normalized_db_query_hash = format!("{:?}", md5::compute(&normalized_db_query));
normalized_db_query_hash.truncate(16);

attributes.insert(NORMALIZED_DB_QUERY, normalized_db_query);
attributes.insert(NORMALIZED_DB_QUERY_HASH, normalized_db_query_hash);
}
if let Some(db_operation_name) = db_operation {
attributes.insert(DB_OPERATION_NAME, db_operation_name)
Expand Down Expand Up @@ -927,6 +931,10 @@ mod tests {
"type": "string",
"value": "SELECT %s"
},
"sentry.normalized_db_query.hash": {
"type": "string",
"value": "3a377dcc490b1690"
},
"sentry.op": {
"type": "string",
"value": "db.query"
Expand Down Expand Up @@ -993,6 +1001,10 @@ mod tests {
"type": "string",
"value": "{\"find\":\"documents\",\"foo\":\"?\"}"
},
"sentry.normalized_db_query.hash": {
"type": "string",
"value": "aedc5c7e8cec726b"
},
"sentry.op": {
"type": "string",
"value": "db"
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/test_spansv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,10 @@ def test_spansv2_attribute_normalization(
"type": "string",
"value": "SELECT id FROM users WHERE id = %s AND name = %s",
},
"sentry.normalized_db_query.hash": {
"type": "string",
"value": "f79af0ba3d26284c",
},
"sentry.observed_timestamp_nanos": {
"type": "string",
"value": time_within(ts, expect_resolution="ns"),
Expand Down
Loading