Skip to content

Commit d19ec3a

Browse files
authored
feat(schema): Add Getter for fields commonly used in tags (#2707)
Sentry extracts the `logger` and `level` fields into tags, and both of these fields are commonly used in dashboard widgets. For this reason, on-demand metric extraction needs access to those fields. Sentry will convert queries for the tags into the corresponding fields, as the tag does not exist in Relay yet.
1 parent e296698 commit d19ec3a

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
- Group resource spans by scrubbed domain and filename. ([#2654](https://github.com/getsentry/relay/pull/2654))
1010
- Convert transactions to spans for all organizations. ([#2659](https://github.com/getsentry/relay/pull/2659))
1111
- Filter outliers (>180s) for mobile measurements. ([#2649](https://github.com/getsentry/relay/pull/2649))
12-
- Allow access to more context fields in dynamic sampling and metric extraction. ([#2607](https://github.com/getsentry/relay/pull/2607), [#2640](https://github.com/getsentry/relay/pull/2640), [#2675](https://github.com/getsentry/relay/pull/2675))
12+
- Allow access to more context fields in dynamic sampling and metric extraction. ([#2607](https://github.com/getsentry/relay/pull/2607), [#2640](https://github.com/getsentry/relay/pull/2640), [#2675](https://github.com/getsentry/relay/pull/2675), [#2707](https://github.com/getsentry/relay/pull/2707))
1313
- Allow advanced scrubbing expressions for datascrubbing safe fields. ([#2670](https://github.com/getsentry/relay/pull/2670))
1414
- Disable graphql scrubbing when datascrubbing is disabled. ([#2689](https://github.com/getsentry/relay/pull/2689))
1515
- Track when a span was received. ([#2688](https://github.com/getsentry/relay/pull/2688))

relay-event-schema/src/protocol/event.rs

+2
Original file line numberDiff line numberDiff line change
@@ -626,10 +626,12 @@ impl Getter for Event {
626626
fn get_value(&self, path: &str) -> Option<Val<'_>> {
627627
Some(match path.strip_prefix("event.")? {
628628
// Simple fields
629+
"level" => self.level.value()?.name().into(),
629630
"release" => self.release.as_str()?.into(),
630631
"dist" => self.dist.as_str()?.into(),
631632
"environment" => self.environment.as_str()?.into(),
632633
"transaction" => self.transaction.as_str()?.into(),
634+
"logger" => self.logger.as_str()?.into(),
633635
"platform" => self.platform.as_str().unwrap_or("other").into(),
634636

635637
// Fields in top level structures (called "interfaces" in Sentry)

relay-event-schema/src/protocol/types.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,16 @@ pub enum Level {
659659
}
660660

661661
impl Level {
662+
pub fn name(self) -> &'static str {
663+
match self {
664+
Level::Debug => "debug",
665+
Level::Info => "info",
666+
Level::Warning => "warning",
667+
Level::Error => "error",
668+
Level::Fatal => "fatal",
669+
}
670+
}
671+
662672
fn from_python_level(value: u64) -> Option<Level> {
663673
Some(match value {
664674
10 => Level::Debug,
@@ -688,13 +698,7 @@ impl FromStr for Level {
688698

689699
impl fmt::Display for Level {
690700
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
691-
match *self {
692-
Level::Debug => write!(f, "debug"),
693-
Level::Info => write!(f, "info"),
694-
Level::Warning => write!(f, "warning"),
695-
Level::Error => write!(f, "error"),
696-
Level::Fatal => write!(f, "fatal"),
697-
}
701+
f.write_str(self.name())
698702
}
699703
}
700704

0 commit comments

Comments
 (0)