Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(spans): Detect db_system redis
Browse files Browse the repository at this point in the history
jjbayer committed May 24, 2024

Unverified

The committer email address is not verified.
1 parent 5dff966 commit 6c56b92
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion relay-event-normalization/src/normalize/span/description/mod.rs
Original file line number Diff line number Diff line change
@@ -57,7 +57,9 @@ pub(crate) fn scrub_span_description(
.map(|op| op.split_once('.').unwrap_or((op, "")))
.and_then(|(op, sub)| match (op, sub) {
("http", _) => scrub_http(description),
("cache", _) | ("db", "redis") => scrub_redis_keys(description),
("cache", _) | ("db", "redis") | ("db", _) if db_system == Some("redis") => {
scrub_redis_keys(description)
}
("db", sub) => {
if sub.contains("clickhouse")
|| sub.contains("mongodb")
@@ -1124,6 +1126,24 @@ mod tests {
assert_eq!(scrubbed.0.as_deref(), Some("SELECT a FROM b"));
}

#[test]
fn redis_with_db_system() {
let json = r#"{
"description": "del myveryrandomkey:123Xalsdkxfhn",
"op": "db",
"data": {
"db.system": "redis"
}
}"#;

let mut span = Annotated::<Span>::from_json(json).unwrap();

let scrubbed = scrub_span_description(span.value_mut().as_mut().unwrap());

// NOTE: this should return `DEL *`, but we cannot detect lowercase command names yet.
assert_eq!(scrubbed.0.as_deref(), Some("*"));
}

#[test]
fn core_data() {
let json = r#"{

0 comments on commit 6c56b92

Please sign in to comment.