Skip to content

Commit b9c91dc

Browse files
committed
ref(server): Remove internal dynamic sampling metrics
1 parent 619d3b8 commit b9c91dc

File tree

2 files changed

+3
-187
lines changed

2 files changed

+3
-187
lines changed

relay-server/src/actors/processor.rs

Lines changed: 3 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use relay_log::LogError;
3232
use relay_metrics::{Bucket, InsertMetrics, MergeBuckets, Metric};
3333
use relay_quotas::{DataCategory, ReasonCode};
3434
use relay_redis::RedisPool;
35-
use relay_sampling::{DynamicSamplingContext, RuleId};
35+
use relay_sampling::RuleId;
3636
use relay_statsd::metric;
3737
use relay_system::{Addr, FromMessage, NoResponse, Service};
3838

@@ -45,7 +45,7 @@ use crate::envelope::{AttachmentType, ContentType, Envelope, Item, ItemType};
4545
use crate::metrics_extraction::sessions::{extract_session_metrics, SessionMetricsConfig};
4646
use crate::metrics_extraction::transactions::{extract_transaction_metrics, ExtractMetricsError};
4747
use crate::service::REGISTRY;
48-
use crate::statsd::{RelayCounters, RelayHistograms, RelayTimers};
48+
use crate::statsd::{RelayCounters, RelayTimers};
4949
use crate::utils::{
5050
self, ChunkedFormDataAggregator, EnvelopeContext, ErrorBoundary, FormDataIter, SamplingResult,
5151
};
@@ -358,109 +358,6 @@ fn outcome_from_profile_error(err: relay_profiling::ProfileError) -> Outcome {
358358
Outcome::Invalid(discard_reason)
359359
}
360360

361-
fn track_sampling_metrics(
362-
project_state: &ProjectState,
363-
context: &DynamicSamplingContext,
364-
event: &Event,
365-
) {
366-
// We only collect this metric for the root transaction event, so ignore secondary projects.
367-
if !project_state.is_matching_key(context.public_key) {
368-
return;
369-
}
370-
371-
let transaction_info = match event.transaction_info.value() {
372-
Some(info) => info,
373-
None => return,
374-
};
375-
376-
let changes = match transaction_info.changes.value() {
377-
Some(value) => value.as_slice(),
378-
None => return,
379-
};
380-
381-
let last_change = changes
382-
.iter()
383-
.rev()
384-
// skip all broken change records
385-
.filter_map(|a| a.value())
386-
// skip records without a timestamp
387-
.filter(|c| c.timestamp.value().is_some())
388-
// take the last that did not occur when the event was sent
389-
.find(|c| c.timestamp.value() != event.timestamp.value());
390-
391-
let source = event.get_transaction_source().as_str();
392-
let platform = event.platform.as_str().unwrap_or("other");
393-
let sdk_name = event.sdk_name();
394-
let sdk_version = event.sdk_version();
395-
396-
metric!(
397-
histogram(RelayHistograms::DynamicSamplingChanges) = changes.len() as u64,
398-
source = source,
399-
platform = platform,
400-
sdk_name = sdk_name,
401-
sdk_version = sdk_version,
402-
);
403-
404-
if let Some(&total) = transaction_info.propagations.value() {
405-
// If there was no change, there were no propagations that happened with a wrong name.
406-
let change = last_change
407-
.and_then(|c| c.propagations.value())
408-
.map_or(0, |v| *v);
409-
410-
metric!(
411-
histogram(RelayHistograms::DynamicSamplingPropagationCount) = change,
412-
source = source,
413-
platform = platform,
414-
sdk_name = sdk_name,
415-
sdk_version = sdk_version,
416-
);
417-
418-
let percentage = match (change, total) {
419-
(0, 0) => 0.0, // 0% indicates no premature changes.
420-
_ => ((change as f64) / (total as f64)).min(1.0) * 100.0,
421-
};
422-
423-
metric!(
424-
histogram(RelayHistograms::DynamicSamplingPropagationPercentage) = percentage,
425-
source = source,
426-
platform = platform,
427-
sdk_name = sdk_name,
428-
sdk_version = sdk_version,
429-
);
430-
}
431-
432-
if let (Some(&start), Some(&change), Some(&end)) = (
433-
event.start_timestamp.value(),
434-
last_change
435-
.and_then(|c| c.timestamp.value())
436-
.or_else(|| event.start_timestamp.value()), // default to start if there was no change
437-
event.timestamp.value(),
438-
) {
439-
let delay_ms = (change - start).num_milliseconds();
440-
if delay_ms >= 0 {
441-
metric!(
442-
histogram(RelayHistograms::DynamicSamplingChangeDuration) = delay_ms as u64,
443-
source = source,
444-
platform = platform,
445-
sdk_name = sdk_name,
446-
sdk_version = sdk_version,
447-
);
448-
}
449-
450-
let duration_ms = (end - start).num_milliseconds() as f64;
451-
if delay_ms >= 0 && duration_ms >= 0.0 {
452-
let percentage = ((delay_ms as f64) / duration_ms).min(1.0) * 100.0;
453-
metric!(
454-
histogram(RelayHistograms::DynamicSamplingChangePercentage) = percentage,
455-
source = source,
456-
platform = platform,
457-
sdk_name = sdk_name,
458-
sdk_version = sdk_version,
459-
);
460-
}
461-
}
462-
}
463-
464361
/// Response of the [`ProcessEnvelope`] message.
465362
#[cfg_attr(not(feature = "processing"), allow(dead_code))]
466363
pub struct ProcessEnvelopeResponse {
@@ -1859,11 +1756,8 @@ impl EnvelopeProcessorService {
18591756

18601757
state.transaction_metrics_extracted = true;
18611758
state.envelope_context.set_event_metrics_extracted();
1862-
1863-
if let Some(context) = state.envelope.sampling_context() {
1864-
track_sampling_metrics(&state.project_state, context, event);
1865-
}
18661759
}
1760+
18671761
Ok(())
18681762
}
18691763

relay-server/src/statsd.rs

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -134,77 +134,6 @@ pub enum RelayHistograms {
134134
/// Size of queries (projectconfig queries, i.e. the request payload, not the response) sent by
135135
/// Relay over HTTP in bytes.
136136
UpstreamEnvelopeBodySize,
137-
138-
/// Counts how often a transaction name was changed before submitting the final transaction.
139-
///
140-
/// A value of `0` indicates that the transaction was created with the final transaction name.
141-
/// In this case, the DSC will have the correct transaction name guaranteed. However, to
142-
/// determine how many traces had wrong transaction names propagated, check the
143-
/// `dynamic_sampling.propagations`.
144-
///
145-
/// This metric is tagged with:
146-
///
147-
/// - `source`: The transaction source value in the final event payload.
148-
/// - `platform`: The SDK platform value of the event payload.
149-
/// - `sdk_name`: The name of the client SDK as reported in the event payload.
150-
/// - `sdk_version`: The version of the client SDK as reported in the event payload.
151-
DynamicSamplingChanges,
152-
153-
/// Counts the number of propagations before the final transaction name has been determined.
154-
///
155-
/// A value of `0` indicates that the entire trace had identical transaction names in the
156-
/// Dynamic Sampling Context (DSC). This means that the entire trace is sampled consistently.
157-
///
158-
/// Note that this differs from `dynamic_sampling.changes`, which indicates changes even in the
159-
/// absence of propagations.
160-
///
161-
/// This metric is tagged with:
162-
///
163-
/// - `source`: The transaction source value in the final event payload.
164-
/// - `platform`: The SDK platform value of the event payload.
165-
/// - `sdk_name`: The name of the client SDK as reported in the event payload.
166-
/// - `sdk_version`: The version of the client SDK as reported in the event payload.
167-
DynamicSamplingPropagationCount,
168-
169-
/// The number of propagations before the final transaction name change relative to the total
170-
/// number of propagations.
171-
///
172-
/// Tracks the same as `dynamic_sampling.propagations`, except that the value of this metric is
173-
/// a percentage between `0.0` and `100.0`. A value of `0` means that no propagations occurred,
174-
/// and `100` means that all propagations occurred with the wrong transaction name.
175-
///
176-
/// This metric is tagged with:
177-
///
178-
/// - `source`: The transaction source value in the final event payload.
179-
/// - `platform`: The SDK platform value of the event payload.
180-
/// - `sdk_name`: The name of the client SDK as reported in the event payload.
181-
/// - `sdk_version`: The version of the client SDK as reported in the event payload.
182-
DynamicSamplingPropagationPercentage,
183-
184-
/// Time in milliseconds from the start of transaction until the final name is determined.
185-
///
186-
/// If the transaction name changes multiple times, this records only the last instance. This
187-
/// metric is not logged if there were no changes to the transaction name.
188-
///
189-
/// This metric is tagged with:
190-
///
191-
/// - `source`: The transaction source value in the final event payload.
192-
/// - `platform`: The SDK platform value of the event payload.
193-
/// - `sdk_name`: The name of the client SDK as reported in the event payload.
194-
/// - `sdk_version`: The version of the client SDK as reported in the event payload.
195-
DynamicSamplingChangeDuration,
196-
197-
/// Timing relative to the transaction duration until the final name is determined.
198-
///
199-
/// This is a percentage between `0.0` and `100.0`.
200-
///
201-
/// This metric is tagged with:
202-
///
203-
/// - `source`: The transaction source value in the final event payload.
204-
/// - `platform`: The SDK platform value of the event payload.
205-
/// - `sdk_name`: The name of the client SDK as reported in the event payload.
206-
/// - `sdk_version`: The version of the client SDK as reported in the event payload.
207-
DynamicSamplingChangePercentage,
208137
}
209138

210139
impl HistogramMetric for RelayHistograms {
@@ -231,13 +160,6 @@ impl HistogramMetric for RelayHistograms {
231160
RelayHistograms::UpstreamRetries => "upstream.retries",
232161
RelayHistograms::UpstreamQueryBodySize => "upstream.query.body_size",
233162
RelayHistograms::UpstreamEnvelopeBodySize => "upstream.envelope.body_size",
234-
RelayHistograms::DynamicSamplingChanges => "dynamic_sampling.changes",
235-
RelayHistograms::DynamicSamplingPropagationCount => "dynamic_sampling.propagations",
236-
RelayHistograms::DynamicSamplingPropagationPercentage => {
237-
"dynamic_sampling.propagation_pct"
238-
}
239-
RelayHistograms::DynamicSamplingChangeDuration => "dynamic_sampling.change_duration",
240-
RelayHistograms::DynamicSamplingChangePercentage => "dynamic_sampling.change_pct",
241163
}
242164
}
243165
}

0 commit comments

Comments
 (0)