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

Add processor for new spans schema #6123

Merged
merged 17 commits into from
Jul 22, 2024
2 changes: 2 additions & 0 deletions rust_snuba/src/processors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod querylog;
mod release_health_metrics;
mod replays;
mod spans;
mod spans_v2;
mod utils;

use crate::config::ProcessorConfig;
Expand Down Expand Up @@ -55,6 +56,7 @@ define_processing_functions! {
("QuerylogProcessor", "snuba-queries", ProcessingFunctionType::ProcessingFunction(querylog::process_message)),
("ReplaysProcessor", "ingest-replay-events", ProcessingFunctionType::ProcessingFunction(replays::process_message)),
("SpansMessageProcessor", "snuba-spans", ProcessingFunctionType::ProcessingFunction(spans::process_message)),
("SpansV2MessageProcessor", "snuba-spans", ProcessingFunctionType::ProcessingFunction(spans_v2::process_message)),
colin-sentry marked this conversation as resolved.
Show resolved Hide resolved
("MetricsSummariesMessageProcessor", "snuba-metrics-summaries", ProcessingFunctionType::ProcessingFunction(metrics_summaries::process_message)),
("OutcomesProcessor", "outcomes", ProcessingFunctionType::ProcessingFunction(outcomes::process_message)),
("GenericCountersMetricsProcessor", "snuba-generic-metrics", ProcessingFunctionType::ProcessingFunction(generic_metrics::process_counter_message)),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
source: src/processors/spans_v2.rs
expression: span
---
{
"organization_id": 1,
"project_id": 1,
"trace_id": "d099bf9a-d5a1-43cf-8f83-a98081d0ed3b",
"span_id": 9832388815107059821,
"parent_span_id": 0,
"segment_id": 9832388815107059821,
"segment_name": "/api/0/relays/projectconfigs/",
"is_segment": true,
"_sort_timestamp": 1721319572,
"start_timestamp": 1721319572616,
"end_timestamp": 1721319572768,
"duration_ms": 152,
"exclusive_time_ms": 0.228,
"retention_days": 90,
"name": "/api/0/relays/projectconfigs/",
"sampling_factor": 1.0,
"sampling_weight": 1.0,
"sign": 1,
"attr_str_3": {
"server_name": "D23CXQ4GK2.local"
},
"attr_str_7": {
"relay_use_post_or_schedule_rejected": "version"
},
"attr_str_10": {
"transaction": "/api/0/relays/projectconfigs/"
},
"attr_str_11": {
"thread.id": "8522009600"
},
"attr_str_12": {
"relay_use_post_or_schedule": "True"
},
"attr_str_17": {
"release": "backend@24.7.0.dev0+c45b49caed1e5fcbf70097ab3f434b487c359b6b"
},
"attr_str_19": {
"environment": "development",
"platform": "python"
},
"attr_str_21": {
"relay_endpoint_version": "3"
},
"attr_str_23": {
"status_code": "200"
},
"attr_str_24": {
"http.status_code": "200"
},
"attr_str_25": {
"user": "ip:127.0.0.1"
},
"attr_str_30": {
"sdk.version": "2.7.0",
"trace.status": "ok"
},
"attr_str_31": {
"category": "http",
"thread.name": "uWSGIWorker1Core0"
},
"attr_str_33": {
"transaction.method": "POST"
},
"attr_str_34": {
"relay_id": "88888888-4444-4444-8444-cccccccccccc",
"spans_over_limit": "False",
"status": "ok"
},
"attr_str_38": {
"relay_no_cache": "False",
"sdk.name": "sentry.python.django"
},
"attr_str_40": {
"op": "http.server"
},
"attr_str_48": {
"transaction.op": "http.server"
},
"attr_str_49": {
"relay_protocol_version": "3"
},
"attr_num_17": {
"num_of_spans": 50.0
}
}
48 changes: 24 additions & 24 deletions rust_snuba/src/processors/spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,33 @@ pub fn process_message(
}

#[derive(Debug, Default, Deserialize, JsonSchema)]
struct FromSpanMessage {
description: Option<String>,
duration_ms: u32,
#[serde(alias = "end_timestamp_micro")]
colin-sentry marked this conversation as resolved.
Show resolved Hide resolved
end_timestamp_precise: Option<f64>,
event_id: Option<Uuid>,
exclusive_time_ms: f64,
is_segment: bool,
measurements: Option<BTreeMap<String, FromMeasurementValue>>,
parent_span_id: Option<String>,
profile_id: Option<Uuid>,
project_id: u64,
received: f64,
retention_days: Option<u16>,
segment_id: Option<String>,
sentry_tags: Option<BTreeMap<String, String>>,
span_id: String,
pub(crate) struct FromSpanMessage {
colin-sentry marked this conversation as resolved.
Show resolved Hide resolved
pub(crate) description: Option<String>,
pub(crate) duration_ms: u32,
pub(crate) end_timestamp_precise: f64,
pub(crate) event_id: Option<Uuid>,
pub(crate) exclusive_time_ms: f64,
pub(crate) is_segment: bool,
pub(crate) measurements: Option<BTreeMap<String, FromMeasurementValue>>,
pub(crate) parent_span_id: Option<String>,
pub(crate) profile_id: Option<Uuid>,
pub(crate) organization_id: u64,
pub(crate) project_id: u64,
pub(crate) received: f64,
pub(crate) retention_days: Option<u16>,
pub(crate) segment_id: Option<String>,
pub(crate) sentry_tags: Option<BTreeMap<String, String>>,
pub(crate) span_id: String,
#[serde(alias = "start_timestamp_micro")]
start_timestamp_precise: Option<f64>,
start_timestamp_ms: u64,
tags: Option<BTreeMap<String, String>>,
trace_id: Uuid,
pub(crate) start_timestamp_precise: Option<f64>,
pub(crate) start_timestamp_ms: u64,
pub(crate) tags: Option<BTreeMap<String, String>>,
pub(crate) trace_id: Uuid,
}

#[derive(Debug, Default, Deserialize, JsonSchema)]
struct FromMeasurementValue {
value: f64,
pub(crate) struct FromMeasurementValue {
pub(crate) value: f64,
}

#[derive(Debug, Default, Serialize)]
Expand Down Expand Up @@ -153,7 +153,7 @@ impl TryFrom<FromSpanMessage> for Span {
duration: from.duration_ms,
end_ms: (end_timestamp_ms % 1000) as u16,
end_timestamp: end_timestamp_ms / 1000,
end_timestamp_precise: (from.end_timestamp_precise.unwrap_or_default() * 1e6) as u64,
end_timestamp_precise: (from.end_timestamp_precise * 1e6) as u64,
exclusive_time: from.exclusive_time_ms,
group,
is_segment: if from.is_segment { 1 } else { 0 },
Expand Down
Loading
Loading