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

chore(metrics-summaries): Remove metrics summaries Kafka config #4296

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 1 addition & 5 deletions relay-kafka/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ pub enum KafkaTopic {
Monitors,
/// Standalone spans without a transaction.
Spans,
/// Summary for metrics collected during a span.
MetricsSummaries,
/// Feedback events topic.
Feedback,
}
Expand All @@ -58,7 +56,7 @@ impl KafkaTopic {
/// It will have to be adjusted if the new variants are added.
pub fn iter() -> std::slice::Iter<'static, Self> {
use KafkaTopic::*;
static TOPICS: [KafkaTopic; 14] = [
static TOPICS: [KafkaTopic; 13] = [
Events,
Attachments,
Transactions,
Expand All @@ -71,7 +69,6 @@ impl KafkaTopic {
ReplayRecordings,
Monitors,
Spans,
MetricsSummaries,
Feedback,
];
TOPICS.iter()
Expand Down Expand Up @@ -133,7 +130,6 @@ define_topic_assignments! {
replay_recordings: (KafkaTopic::ReplayRecordings, "ingest-replay-recordings", "Recordings topic name."),
monitors: (KafkaTopic::Monitors, "ingest-monitors", "Monitor check-ins."),
spans: (KafkaTopic::Spans, "snuba-spans", "Standalone spans without a transaction."),
metrics_summaries: (KafkaTopic::MetricsSummaries, "snuba-metrics-summaries", "Summary for metrics collected during a span."),
feedback: (KafkaTopic::Feedback, "ingest-feedback-events", "Feedback events topic."),
}

Expand Down
59 changes: 2 additions & 57 deletions relay-spans/src/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ use std::str::FromStr;

use chrono::{TimeZone, Utc};
use opentelemetry_proto::tonic::common::v1::any_value::Value as OtelValue;
use opentelemetry_proto::tonic::common::v1::{AnyValue, KeyValue};

use crate::otel_trace::{status::StatusCode as OtelStatusCode, Span as OtelSpan};
use crate::status_codes;
use relay_event_schema::protocol::{
EventId, MetricSummary, MetricsSummary, Span as EventSpan, SpanData, SpanId, SpanStatus,
Timestamp, TraceId,
EventId, Span as EventSpan, SpanData, SpanId, SpanStatus, Timestamp, TraceId,
};
use relay_protocol::{Annotated, FromValue, Object};

Expand Down Expand Up @@ -73,43 +71,6 @@ fn otel_value_to_span_id(value: OtelValue) -> Option<String> {
Some(hex::encode(decoded))
}

fn otel_value_to_metric_summary(value: AnyValue) -> Option<MetricSummary> {
let value = value.value?;
let OtelValue::KvlistValue(value) = value else {
return None;
};
let mut summary = MetricSummary::default();
for KeyValue { key, value } in value.values {
let value = value?.value?;
match value {
OtelValue::IntValue(n) if key == "count" => {
summary.count = u64::try_from(n).ok()?.into();
}
OtelValue::DoubleValue(f) if key == "min" => {
summary.min = f.into();
}
OtelValue::DoubleValue(f) if key == "max" => {
summary.max = f.into();
}
OtelValue::DoubleValue(f) if key == "sum" => {
summary.sum = f.into();
}
OtelValue::KvlistValue(list) if key == "tags" => {
let tags = summary.tags.get_or_insert_with(Default::default);
for KeyValue { key, value } in list.values {
let OtelValue::StringValue(value) = value?.value? else {
return None;
};
tags.insert(key, value.into());
}
}
_ => return None,
}
}

Some(summary)
}

/// Transform an OtelSpan to a Sentry span.
pub fn otel_to_sentry_span(otel_span: OtelSpan) -> EventSpan {
let mut exclusive_time_ms = 0f64;
Expand Down Expand Up @@ -143,7 +104,6 @@ pub fn otel_to_sentry_span(otel_span: OtelSpan) -> EventSpan {
let mut platform = None;
let mut segment_id = None;
let mut profile_id = None;
let mut metrics_summary = MetricsSummary::default();
for attribute in attributes.into_iter() {
if let Some(value) = attribute.value.and_then(|v| v.value) {
match attribute.key.as_str() {
Expand Down Expand Up @@ -194,22 +154,7 @@ pub fn otel_to_sentry_span(otel_span: OtelSpan) -> EventSpan {
"sentry.profile.id" => {
profile_id = otel_value_to_string(value);
}
other => {
if let Some(metric_name) = other.strip_prefix("sentry.metrics_summary.") {
if let OtelValue::ArrayValue(entries) = value {
let summaries =
metrics_summary.0.entry(metric_name.to_owned()).or_default();
let summaries = summaries.get_or_insert_with(Default::default);
for field in entries.values {
if let Some(summary) = otel_value_to_metric_summary(field) {
summaries.push(summary.into());
}
}

continue;
}
}

_ => {
let key = attribute.key;
match value {
OtelValue::ArrayValue(_) => {}
Expand Down
Loading