-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trace Tag Replacer: functionality to scrub sensitive data from spans (#…
…111)
- Loading branch information
Showing
20 changed files
with
423 additions
and
14 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,6 @@ | |
|
||
#![deny(clippy::all)] | ||
|
||
pub mod pb { | ||
include!("./pb/pb.rs"); | ||
} | ||
|
||
pub mod normalizer; | ||
|
||
pub mod normalize_utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "datadog-trace-obfuscation" | ||
version = "2.0.0" | ||
authors = ["David Lee <david.lee@datadoghq.com>"] | ||
edition = "2021" | ||
|
||
[dependencies] | ||
anyhow = "1.0" | ||
regex = "1" | ||
datadog-trace-protobuf = { path = "../trace-protobuf" } | ||
|
||
[dev-dependencies] | ||
duplicate = "0.4.1" | ||
criterion = "0.4" | ||
|
||
[[bench]] | ||
name = "replace_trace_tags_bench" | ||
harness = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. This product includes software | ||
// developed at Datadog (https://www.datadoghq.com/). Copyright 2023-Present | ||
// Datadog, Inc. | ||
|
||
use std::collections::HashMap; | ||
|
||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use datadog_trace_obfuscation::replacer; | ||
use datadog_trace_protobuf::pb; | ||
|
||
fn criterion_benchmark(c: &mut Criterion) { | ||
let rules: &[replacer::ReplaceRule] = &replacer::parse_rules_from_string(&[ | ||
["http.url", "(token/)([^/]*)", "${1}?"], | ||
["http.url", "guid", "[REDACTED]"], | ||
["*", "(token/)([^/]*)", "${1}?"], | ||
["*", "this", "that"], | ||
["custom.tag", "(/foo/bar/).*", "${1}extra"], | ||
["resource.name", "prod", "stage"], | ||
]) | ||
.unwrap(); | ||
|
||
let span_1 = pb::Span { | ||
duration: 10000000, | ||
error: 0, | ||
resource: "GET /some/raclette".to_string(), | ||
service: "django".to_string(), | ||
name: "django.controller".to_string(), | ||
span_id: 123, | ||
start: 1448466874000000000, | ||
trace_id: 424242, | ||
meta: HashMap::from([ | ||
("resource.name".to_string(), "this is prod".to_string()), | ||
( | ||
"http.url".to_string(), | ||
"some/[REDACTED]/token/abcdef/abc".to_string(), | ||
), | ||
( | ||
"other.url".to_string(), | ||
"some/guid/token/abcdef/abc".to_string(), | ||
), | ||
("custom.tag".to_string(), "/foo/bar/foo".to_string()), | ||
]), | ||
metrics: HashMap::from([("cheese_weight".to_string(), 100000.0)]), | ||
parent_id: 1111, | ||
r#type: "http".to_string(), | ||
meta_struct: HashMap::new(), | ||
}; | ||
|
||
let mut trace = [span_1]; | ||
c.bench_function("replace_trace_tags_bench", |b| { | ||
b.iter(|| { | ||
replacer::replace_trace_tags(black_box(&mut trace), black_box(rules)); | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. This product includes software | ||
// developed at Datadog (https://www.datadoghq.com/). Copyright 2023-Present | ||
// Datadog, Inc. | ||
|
||
#![deny(clippy::all)] | ||
|
||
pub mod replacer; |
Oops, something went wrong.