Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spans): Track when each span was received #2688

Merged
merged 5 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Filter outliers (>180s) for mobile measurements. ([#2649](https://github.com/getsentry/relay/pull/2649))
- 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))
- Allow advanced scrubbing expressions for datascrubbing safe fields. ([#2670](https://github.com/getsentry/relay/pull/2670))
- Track when a span was received. ([#2688](https://github.com/getsentry/relay/pull/2688))
- Add context for NEL (Network Error Logging) reports to the event schema. ([#2421](https://github.com/getsentry/relay/pull/2421))

**Bug Fixes**:
Expand Down
3 changes: 3 additions & 0 deletions relay-event-normalization/src/normalize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4000,6 +4000,7 @@ mod tests {
profile_id: ~,
data: ~,
sentry_tags: ~,
received: ~,
other: {},
},
]
Expand Down Expand Up @@ -4040,6 +4041,7 @@ mod tests {
profile_id: ~,
data: ~,
sentry_tags: ~,
received: ~,
other: {},
},
]
Expand Down Expand Up @@ -4080,6 +4082,7 @@ mod tests {
profile_id: ~,
data: ~,
sentry_tags: ~,
received: ~,
other: {},
},
]
Expand Down
5 changes: 5 additions & 0 deletions relay-event-schema/src/protocol/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ pub struct Span {
/// Tags generated by Relay. These tags are a superset of the tags set on span metrics.
pub sentry_tags: Annotated<Object<String>>,

/// Timestamp when the span has been received by Sentry.
pub received: Annotated<Timestamp>,

// TODO remove retain when the api stabilizes
/// Additional arbitrary fields for forwards compatibility.
#[metastructure(additional_properties, retain = "true", pii = "maybe")]
Expand All @@ -84,6 +87,7 @@ impl From<&Event> for Span {
let mut span = Self {
description: event.transaction.clone(),
is_segment: Some(true).into(),
received: event.received.clone(),
start_timestamp: event.start_timestamp.clone(),
timestamp: event.timestamp.clone(),
..Default::default()
Expand Down Expand Up @@ -253,6 +257,7 @@ mod tests {
),
data: ~,
sentry_tags: ~,
received: ~,
other: {},
}
"###);
Expand Down
3 changes: 2 additions & 1 deletion relay-server/src/actors/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2416,8 +2416,9 @@ impl EnvelopeProcessorService {
// HACK: clone the span to set the segment_id. This should happen
// as part of normalization once standalone spans reach wider adoption.
let mut new_span = inner_span.clone();
new_span.segment_id = transaction_span.segment_id.clone();
new_span.is_segment = Annotated::new(false);
new_span.received = transaction_span.received.clone();
new_span.segment_id = transaction_span.segment_id.clone();

// If a profile is associated with the transaction, also associate it with its
// child spans.
Expand Down
1 change: 1 addition & 0 deletions relay-server/src/metrics_extraction/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ mod tests {
"platform": "javascript",
"start_timestamp": "2021-04-26T07:59:01+0100",
"timestamp": "2021-04-26T08:00:00+0100",
"received": "2021-04-26T08:00:01+0100",
"server_name": "myhost",
"release": "1.2.3",
"dist": "foo ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ expression: "(&event.value().unwrap().spans, metrics)"
"transaction": "gEt /api/:version/users/",
"transaction.method": "GET",
},
received: ~,
other: {},
},
],
Expand Down
1 change: 1 addition & 0 deletions relay-server/src/metrics_extraction/transactions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ mod tests {
profile_id: ~,
data: ~,
sentry_tags: ~,
received: ~,
other: {},
},
]
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,7 @@ def test_spans(

child_span = spans_consumer.get_span()
del child_span["start_time"]
del child_span["span"]["received"]
assert child_span == {
"event_id": "cbf6960622e14a45abc1f03b2055b186",
"project_id": 42,
Expand Down Expand Up @@ -1272,6 +1273,7 @@ def test_spans(

transaction_span = spans_consumer.get_span()
del transaction_span["start_time"]
del transaction_span["span"]["received"]
assert transaction_span == {
"event_id": "cbf6960622e14a45abc1f03b2055b186",
"project_id": 42,
Expand Down
Loading