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): Route spans according to trace_id #3387

Merged
merged 5 commits into from
Apr 9, 2024
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 @@ -42,6 +42,7 @@
- Pass `retention_days` in the Kafka profile messages. ([#3362](https://github.com/getsentry/relay/pull/3362))
- Support and expose namespaces for metric rate limit propagation via the `x-sentry-rate-limits` header. ([#3347](https://github.com/getsentry/relay/pull/3347))
- Tag span duration metric by group for all ops supporting description scrubbing. ([#3370](https://github.com/getsentry/relay/pull/3370))
- Route spans according to trace_id. ([#3387](https://github.com/getsentry/relay/pull/3387))

## 24.3.0

Expand Down
6 changes: 3 additions & 3 deletions relay-server/src/services/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ struct SpanKafkaMessage<'a> {
start_timestamp_ms: u64,
#[serde(default, skip_serializing_if = "Option::is_none")]
tags: Option<&'a RawValue>,
trace_id: &'a str,
trace_id: EventId,

#[serde(borrow, default, skip_serializing)]
platform: Cow<'a, str>, // We only use this for logging for now
Expand Down Expand Up @@ -1427,7 +1427,7 @@ struct MetricsSummaryKafkaMessage<'a> {
retention_days: u16,
segment_id: &'a str,
span_id: &'a str,
trace_id: &'a str,
trace_id: EventId,

count: u64,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -1518,6 +1518,7 @@ impl Message for KafkaMessage<'_> {
Self::AttachmentChunk(message) => message.event_id.0,
Self::UserReport(message) => message.event_id.0,
Self::ReplayEvent(message) => message.replay_id.0,
Self::Span { message, .. } => message.trace_id.0,

// Monitor check-ins use the hinted UUID passed through from the Envelope.
//
Expand All @@ -1528,7 +1529,6 @@ impl Message for KafkaMessage<'_> {
// Random partitioning
Self::Profile(_)
| Self::ReplayRecordingNotChunked(_)
| Self::Span { .. }
| Self::MetricsSummary(_)
| Self::Cogs(_)
| Self::ProfileChunk(_) => Uuid::nil(),
Expand Down
18 changes: 9 additions & 9 deletions tests/integration/test_spans.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_span_extraction(
project_config["config"]["features"].append("projects:discard-transaction")

event = make_transaction({"event_id": "cbf6960622e14a45abc1f03b2055b186"})
end = datetime.utcnow().replace(tzinfo=timezone.utc) - timedelta(seconds=1)
end = datetime.now(timezone.utc) - timedelta(seconds=1)
duration = timedelta(milliseconds=500)
start = end - duration
event["spans"] = [
Expand Down Expand Up @@ -325,7 +325,7 @@ def test_span_ingestion(
]

duration = timedelta(milliseconds=500)
end = datetime.utcnow().replace(tzinfo=timezone.utc) - timedelta(seconds=1)
end = datetime.now(timezone.utc) - timedelta(seconds=1)
start = end - duration

# 1 - Send OTel span and sentry span via envelope
Expand Down Expand Up @@ -869,10 +869,10 @@ def test_span_reject_invalid_timestamps(
duration = timedelta(milliseconds=500)
yesterday_delta = timedelta(days=1)

end_yesterday = datetime.utcnow().replace(tzinfo=timezone.utc) - yesterday_delta
end_yesterday = datetime.now(timezone.utc) - yesterday_delta
start_yesterday = end_yesterday - duration

end_today = datetime.utcnow().replace(tzinfo=timezone.utc) - timedelta(seconds=1)
end_today = datetime.now(timezone.utc) - timedelta(seconds=1)
start_today = end_today - duration

envelope = Envelope()
Expand Down Expand Up @@ -978,7 +978,7 @@ def test_span_ingestion_with_performance_scores(
]

duration = timedelta(milliseconds=500)
end = datetime.utcnow().replace(tzinfo=timezone.utc) - timedelta(seconds=1)
end = datetime.now(timezone.utc) - timedelta(seconds=1)
start = end - duration

envelope = Envelope()
Expand Down Expand Up @@ -1134,7 +1134,7 @@ def test_rate_limit_indexed_consistent(
spans_consumer = spans_consumer()
outcomes_consumer = outcomes_consumer()

start = datetime.utcnow()
start = datetime.now(timezone.utc)
end = start + timedelta(seconds=1)

envelope = envelope_with_spans(start, end)
Expand Down Expand Up @@ -1182,11 +1182,11 @@ def test_rate_limit_indexed_consistent_extracted(
spans_consumer = spans_consumer()
outcomes_consumer = outcomes_consumer()

start = datetime.utcnow()
start = datetime.now(timezone.utc)
end = start + timedelta(seconds=1)

event = make_transaction({"event_id": "cbf6960622e14a45abc1f03b2055b186"})
end = datetime.utcnow().replace(tzinfo=timezone.utc) - timedelta(seconds=1)
end = datetime.now(timezone.utc) - timedelta(seconds=1)
duration = timedelta(milliseconds=500)
start = end - duration
event["spans"] = [
Expand Down Expand Up @@ -1252,7 +1252,7 @@ def test_rate_limit_metrics_consistent(
metrics_consumer = metrics_consumer()
outcomes_consumer = outcomes_consumer()

start = datetime.utcnow()
start = datetime.now(timezone.utc)
end = start + timedelta(seconds=1)

envelope = envelope_with_spans(start, end)
Expand Down
Loading