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(suspect-spans): Add span exclusive time #1061

Merged
merged 12 commits into from
Sep 1, 2021
2 changes: 1 addition & 1 deletion relay-general/src/protocol/contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ impl FromValue for TraceId {
}

/// A 16-character hex string as described in the W3C trace context spec.
#[derive(Clone, Debug, Default, PartialEq, Empty, IntoValue, ProcessValue)]
#[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Empty, IntoValue, ProcessValue)]
#[cfg_attr(feature = "jsonschema", derive(JsonSchema))]
pub struct SpanId(pub String);

Expand Down
4 changes: 4 additions & 0 deletions relay-general/src/protocol/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub struct Span {
#[metastructure(required = "true")]
pub start_timestamp: Annotated<Timestamp>,

pub exclusive_time: Annotated<f64>,
Zylphrex marked this conversation as resolved.
Show resolved Hide resolved

/// Human readable description of a span (e.g. method URL).
#[metastructure(pii = "maybe")]
pub description: Annotated<String>,
Expand Down Expand Up @@ -59,6 +61,7 @@ mod tests {
let json = r#"{
"timestamp": 0.0,
"start_timestamp": -63158400.0,
"exclusive_time": 1.23,
"description": "desc",
"op": "operation",
"span_id": "fa90fdead5f74052",
Expand All @@ -69,6 +72,7 @@ mod tests {
let span = Annotated::new(Span {
timestamp: Annotated::new(Utc.ymd(1970, 1, 1).and_hms_nano(0, 0, 0, 0).into()),
start_timestamp: Annotated::new(Utc.ymd(1968, 1, 1).and_hms_nano(0, 0, 0, 0).into()),
exclusive_time: Annotated::new(1.23),
description: Annotated::new("desc".to_owned()),
op: Annotated::new("operation".to_owned()),
trace_id: Annotated::new(TraceId("4c79f60c11214eb38604f4ae0781bfb2".into())),
Expand Down
3 changes: 3 additions & 0 deletions relay-general/src/store/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Utility code for sentry's internal store.
use std::collections::BTreeSet;
use std::sync::Arc;

use chrono::{DateTime, Utc};
Expand Down Expand Up @@ -53,6 +54,8 @@ pub struct StoreConfig {

/// Emit breakdowns based on given configuration.
pub breakdowns: Option<normalize::breakdowns::BreakdownsConfig>,

pub span_attributes: BTreeSet<String>,
dashed marked this conversation as resolved.
Show resolved Hide resolved
}

/// The processor that normalizes events for store.
Expand Down
8 changes: 8 additions & 0 deletions relay-general/src/store/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ mod contexts;
mod logentry;
mod mechanism;
mod request;
mod spans;
mod stacktrace;

#[cfg(feature = "uaparser")]
Expand Down Expand Up @@ -111,6 +112,12 @@ impl<'a> NormalizeProcessor<'a> {
}
}

fn normalize_spans(&self, event: &mut Event) {
if event.ty.value() == Some(&EventType::Transaction) {
spans::normalize_spans(event, &self.config.span_attributes);
}
}

/// Ensures that the `release` and `dist` fields match up.
fn normalize_release_dist(&self, event: &mut Event) {
if event.dist.value().is_some() && event.release.value().is_empty() {
Expand Down Expand Up @@ -493,6 +500,7 @@ impl<'a> Processor for NormalizeProcessor<'a> {
self.normalize_user_agent(event);
self.normalize_measurements(event);
self.normalize_breakdowns(event);
self.normalize_spans(event);

Ok(())
}
Expand Down
Loading