Skip to content

Commit 91d83e4

Browse files
authored
Merge branch 'master' into pierre/metrics-summaries-push-to-separate-topic
2 parents 4590215 + 6f99788 commit 91d83e4

File tree

27 files changed

+736
-434
lines changed

27 files changed

+736
-434
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
## Unreleased
44

5+
**Features**:
6+
7+
- Add protobuf support for ingesting OpenTelemetry spans and use official `opentelemetry-proto` generated structs. ([#3044](https://github.com/getsentry/relay/pull/3044))
8+
59
**Internal**:
610

11+
- Set the span op on segments. ([#3082](https://github.com/getsentry/relay/pull/3082))
712
- Push metrics summaries to their own topic. ([#3045](https://github.com/getsentry/relay/pull/3045))
813

914
## 24.1.2
@@ -14,7 +19,6 @@
1419
- Obtain `span.domain` field from the span data's `url.scheme` and `server.address` properties when applicable. ([#2975](https://github.com/getsentry/relay/pull/2975))
1520
- Do not truncate simplified SQL expressions. ([#3003](https://github.com/getsentry/relay/pull/3003))
1621
- Add `app_start_type` as a tag for self time and duration for app start spans. ([#3027](https://github.com/getsentry/relay/pull/3027)), ([#3066](https://github.com/getsentry/relay/pull/3066))
17-
- Add protobuf support for ingesting OpenTelemetry spans and use official `opentelemetry-proto` generated structs. ([#3044](https://github.com/getsentry/relay/pull/3044))
1822

1923
**Internal**:
2024

Cargo.lock

+43-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ criterion = "0.5"
2424
futures = { version = "0.3", default-features = false, features = ["std"] }
2525
insta = { version = "1.31.0", features = ["json", "redactions", "ron"] }
2626
hash32 = "0.3.1"
27-
hashbrown = "0.13.2"
27+
hashbrown = "0.14.3"
2828
itertools = "0.10.5"
2929
once_cell = "1.13.1"
3030
parking_lot = "0.12.1"

relay-cardinality/src/redis/cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl Inner {
150150

151151
let expired = metric!(timer(CardinalityLimiterTimers::CacheVacuum), {
152152
self.cache
153-
.drain_filter(|scope, cache| cache.current_slot < scope.active_slot(ts))
153+
.extract_if(|scope, cache| cache.current_slot < scope.active_slot(ts))
154154
.count()
155155
});
156156
metric!(counter(CardinalityLimiterCounters::RedisCacheVacuum) += expired as i64);

relay-cardinality/src/redis/limiter.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ pub struct RedisSetLimiter {
3232
script: CardinalityScript,
3333
cache: Cache,
3434
#[cfg(test)]
35+
timestamp: UnixTimestamp,
36+
#[cfg(test)]
3537
time_offset: std::time::Duration,
3638
}
3739

@@ -44,6 +46,8 @@ impl RedisSetLimiter {
4446
script: CardinalityScript::load(),
4547
cache: Cache::new(options.cache_vacuum_interval),
4648
#[cfg(test)]
49+
timestamp: UnixTimestamp::now(),
50+
#[cfg(test)]
4751
time_offset: std::time::Duration::from_secs(0),
4852
}
4953
}
@@ -101,10 +105,11 @@ impl Limiter for RedisSetLimiter {
101105
E: IntoIterator<Item = Entry>,
102106
R: Rejections<'a>,
103107
{
108+
#[cfg(not(test))]
104109
let timestamp = UnixTimestamp::now();
105-
// Allows to fast forward time in tests.
110+
// Allows to fast forward time in tests using a fixed offset.
106111
#[cfg(test)]
107-
let timestamp = timestamp + self.time_offset;
112+
let timestamp = self.timestamp + self.time_offset;
108113

109114
let mut states = LimitState::from_limits(scoping, limits);
110115

relay-event-derive/src/lib.rs

-25
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
)]
1111
#![recursion_limit = "256"]
1212

13-
use std::str::FromStr;
14-
1513
use proc_macro2::{Span, TokenStream};
1614
use quote::{quote, ToTokens};
1715
use syn::{Ident, Lit, Meta, NestedMeta};
@@ -439,29 +437,6 @@ impl FieldAttrs {
439437
}
440438
}
441439

442-
#[derive(Copy, Clone, Default)]
443-
enum SkipSerialization {
444-
#[default]
445-
Never,
446-
Null(bool),
447-
Empty(bool),
448-
}
449-
450-
impl FromStr for SkipSerialization {
451-
type Err = ();
452-
453-
fn from_str(s: &str) -> Result<Self, ()> {
454-
Ok(match s {
455-
"never" => SkipSerialization::Never,
456-
"null" => SkipSerialization::Null(false),
457-
"null_deep" => SkipSerialization::Null(true),
458-
"empty" => SkipSerialization::Empty(false),
459-
"empty_deep" => SkipSerialization::Empty(true),
460-
_ => return Err(()),
461-
})
462-
}
463-
}
464-
465440
fn parse_field_attributes(
466441
index: usize,
467442
bi_ast: &syn::Field,

relay-event-normalization/src/normalize/span/description/mod.rs

+24-13
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ const MAX_EXTENSION_LENGTH: usize = 10;
3131
/// Attempts to replace identifiers in the span description with placeholders.
3232
///
3333
/// Returns `None` if no scrubbing can be performed.
34-
pub(crate) fn scrub_span_description(span: &Span) -> Option<String> {
35-
let description = span.description.as_str()?;
34+
pub(crate) fn scrub_span_description(
35+
span: &Span,
36+
) -> (Option<String>, Option<Vec<sqlparser::ast::Statement>>) {
37+
let Some(description) = span.description.as_str() else {
38+
return (None, None);
39+
};
3640

3741
let data = span.data.value();
3842

@@ -41,7 +45,9 @@ pub(crate) fn scrub_span_description(span: &Span) -> Option<String> {
4145
.and_then(|system| system.as_str());
4246
let span_origin = span.origin.as_str();
4347

44-
span.op
48+
let mut parsed_sql = None;
49+
let scrubbed_description = span
50+
.op
4551
.as_str()
4652
.map(|op| op.split_once('.').unwrap_or((op, "")))
4753
.and_then(|(op, sub)| match (op, sub) {
@@ -64,7 +70,11 @@ pub(crate) fn scrub_span_description(span: &Span) -> Option<String> {
6470
// the query type ("User find" for example).
6571
Some(description.to_owned())
6672
} else {
67-
sql::scrub_queries(db_system, description)
73+
let (scrubbed, mode) = sql::scrub_queries(db_system, description);
74+
if let sql::Mode::Parsed(ast) = mode {
75+
parsed_sql = Some(ast);
76+
}
77+
scrubbed
6878
}
6979
}
7080
("resource", ty) => scrub_resource(ty, description),
@@ -105,7 +115,8 @@ pub(crate) fn scrub_span_description(span: &Span) -> Option<String> {
105115
}
106116
("file", _) => scrub_file(description),
107117
_ => None,
108-
})
118+
});
119+
(scrubbed_description, parsed_sql)
109120
}
110121

111122
/// A span declares `op: db.sql.query`, but contains mongodb.
@@ -437,9 +448,9 @@ mod tests {
437448
let scrubbed = scrub_span_description(span.value_mut().as_mut().unwrap());
438449

439450
if $expected == "" {
440-
assert!(scrubbed.is_none());
451+
assert!(scrubbed.0.is_none());
441452
} else {
442-
assert_eq!($expected, scrubbed.unwrap());
453+
assert_eq!($expected, scrubbed.0.unwrap());
443454
}
444455
}
445456
};
@@ -917,7 +928,7 @@ mod tests {
917928
let mut span = Annotated::<Span>::from_json(json).unwrap();
918929
let span = span.value_mut().as_mut().unwrap();
919930
let scrubbed = scrub_span_description(span);
920-
assert_eq!(scrubbed.as_deref(), Some("SELECT %s"));
931+
assert_eq!(scrubbed.0.as_deref(), Some("SELECT %s"));
921932
}
922933

923934
#[test]
@@ -932,7 +943,7 @@ mod tests {
932943
let scrubbed = scrub_span_description(span.value_mut().as_mut().unwrap());
933944

934945
// When db.system is missing, no scrubbed description (i.e. no group) is set.
935-
assert!(scrubbed.is_none());
946+
assert!(scrubbed.0.is_none());
936947
}
937948

938949
#[test]
@@ -950,7 +961,7 @@ mod tests {
950961
let scrubbed = scrub_span_description(span.value_mut().as_mut().unwrap());
951962

952963
// Can be scrubbed with db system.
953-
assert_eq!(scrubbed.as_deref(), Some("SELECT a FROM b"));
964+
assert_eq!(scrubbed.0.as_deref(), Some("SELECT a FROM b"));
954965
}
955966

956967
#[test]
@@ -965,7 +976,7 @@ mod tests {
965976

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

968-
assert_eq!(scrubbed.as_deref(), Some("INSERTED * 'UAEventData'"));
979+
assert_eq!(scrubbed.0.as_deref(), Some("INSERTED * 'UAEventData'"));
969980
}
970981

971982
#[test]
@@ -981,7 +992,7 @@ mod tests {
981992
let scrubbed = scrub_span_description(span.value_mut().as_mut().unwrap());
982993

983994
assert_eq!(
984-
scrubbed.as_deref(),
995+
scrubbed.0.as_deref(),
985996
Some("UPDATED * 'QueuedRequest', DELETED * 'QueuedRequest'")
986997
);
987998
}
@@ -1001,6 +1012,6 @@ mod tests {
10011012
let scrubbed = scrub_span_description(span.value_mut().as_mut().unwrap());
10021013

10031014
// Can be scrubbed with db system.
1004-
assert_eq!(scrubbed.as_deref(), Some("my-component-name"));
1015+
assert_eq!(scrubbed.0.as_deref(), Some("my-component-name"));
10051016
}
10061017
}

0 commit comments

Comments
 (0)