Skip to content

Commit

Permalink
feat(general): Add SpanStatus to span struct (#603)
Browse files Browse the repository at this point in the history
According to our dev docs at https://develop.sentry.dev/sdk/event-payloads/span/, status should be an explicit field on the span struct. The JS SDK is already setting it, and it is rendered for individual spans in the UI.

Update the Span struct to have a field status. This is typed using SpanStatus, the same as the status on an event. Also updated the tests in the file.
  • Loading branch information
AbhiPrasad authored Jun 4, 2020
1 parent b64cfb2 commit bf460e6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions relay-general/src/protocol/span.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use chrono::{DateTime, Utc};

use crate::protocol::{OperationType, SpanId, TraceId};
use crate::protocol::{OperationType, SpanId, SpanStatus, TraceId};
use crate::types::{Annotated, Object, Value};

#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, ToValue, ProcessValue)]
Expand Down Expand Up @@ -34,6 +34,9 @@ pub struct Span {
#[metastructure(required = "true")]
pub trace_id: Annotated<TraceId>,

/// The status of a span
pub status: Annotated<SpanStatus>,

// TODO remove retain when the api stabilizes
/// Additional arbitrary fields for forwards compatibility.
#[metastructure(additional_properties, retain = "true", pii = "maybe")]
Expand All @@ -53,7 +56,8 @@ mod tests {
"description": "desc",
"op": "operation",
"span_id": "fa90fdead5f74052",
"trace_id": "4c79f60c11214eb38604f4ae0781bfb2"
"trace_id": "4c79f60c11214eb38604f4ae0781bfb2",
"status": "ok"
}"#;

let span = Annotated::new(Span {
Expand All @@ -63,6 +67,7 @@ mod tests {
op: Annotated::new("operation".to_owned()),
trace_id: Annotated::new(TraceId("4c79f60c11214eb38604f4ae0781bfb2".into())),
span_id: Annotated::new(SpanId("fa90fdead5f74052".into())),
status: Annotated::new(SpanStatus::Ok),
..Default::default()
});
assert_eq_str!(json, span.to_json_pretty().unwrap());
Expand Down

0 comments on commit bf460e6

Please sign in to comment.