Skip to content

Commit 107e199

Browse files
authored
feat(logs): Count log envelopes with dynamic sampling context (#5420)
1 parent 31f3856 commit 107e199

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

relay-server/src/processing/logs/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ impl processing::Processor for LogsProcessor {
138138
ctx: Context<'_>,
139139
) -> Result<Output<Self::Output>, Rejected<Error>> {
140140
validate::container(&logs).reject(&logs)?;
141+
validate::dsc(&logs);
141142

142143
// Fast filters, which do not need expanded logs.
143144
filter::feature_flag(ctx).reject(&logs)?;

relay-server/src/processing/logs/validate.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::processing::Managed;
22
use crate::processing::logs::{Error, Result, SerializedLogs};
3+
use crate::statsd::RelayCounters;
34

45
/// Validates that there is only a single log container processed at a time.
56
///
@@ -18,3 +19,17 @@ pub fn container(logs: &Managed<SerializedLogs>) -> Result<()> {
1819

1920
Ok(())
2021
}
22+
23+
/// Validate that the envelope has no trace context header.
24+
///
25+
/// For now, this only emits a metric so we can verify that logs envelopes do not
26+
/// contain a trace context.
27+
pub fn dsc(logs: &Managed<SerializedLogs>) {
28+
relay_statsd::metric!(
29+
counter(RelayCounters::EnvelopeWithLogs) += 1,
30+
dsc = match logs.headers.dsc() {
31+
Some(_) => "yes",
32+
None => "no",
33+
}
34+
)
35+
}

relay-server/src/statsd.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,11 @@ pub enum RelayCounters {
936936
/// - `type`: `envelope` or `attachment_v2`
937937
#[cfg(feature = "processing")]
938938
AttachmentUpload,
939+
/// Whether a logs envelope has a trace context header or not
940+
///
941+
/// This metric is tagged with:
942+
/// - `dsc`: yes or no
943+
EnvelopeWithLogs,
939944
}
940945

941946
impl CounterMetric for RelayCounters {
@@ -992,6 +997,7 @@ impl CounterMetric for RelayCounters {
992997
RelayCounters::SamplingDecision => "sampling.decision",
993998
#[cfg(feature = "processing")]
994999
RelayCounters::AttachmentUpload => "attachment.upload",
1000+
RelayCounters::EnvelopeWithLogs => "logs.envelope",
9951001
}
9961002
}
9971003
}

0 commit comments

Comments
 (0)