33use prost:: Message ;
44use relay_dynamic_config:: Feature ;
55use relay_event_normalization:: span:: tag_extraction;
6- use relay_event_schema:: protocol:: { Event , Span , SpanV2 } ;
6+ use relay_event_schema:: protocol:: { Event , Span } ;
77use relay_protocol:: Annotated ;
88use relay_quotas:: DataCategory ;
99use relay_spans:: otel_trace:: TracesData ;
1010
11- use crate :: envelope:: { ContentType , Item , ItemContainer , ItemType } ;
11+ use crate :: envelope:: { ContentType , Item , ItemType } ;
1212use crate :: integrations:: { Integration , OtelFormat , SpansIntegration } ;
1313use crate :: managed:: { ItemAction , TypedEnvelope } ;
1414use crate :: services:: outcome:: { DiscardReason , Outcome } ;
1515use crate :: services:: processor:: { SpanGroup , should_filter} ;
16- use crate :: statsd:: RelayTimers ;
1716
1817#[ cfg( feature = "processing" ) ]
1918mod processing;
@@ -22,8 +21,6 @@ use crate::services::projects::project::ProjectInfo;
2221pub use processing:: * ;
2322use relay_config:: Config ;
2423
25- use super :: ProcessingError ;
26-
2724pub fn filter (
2825 managed_envelope : & mut TypedEnvelope < SpanGroup > ,
2926 config : & Config ,
@@ -48,70 +45,6 @@ pub fn filter(
4845 } ) ;
4946}
5047
51- /// Expands V2 spans to V1 spans.
52- ///
53- /// This expands one item (contanining multiple V2 spans) into several
54- /// (containing one V1 span each).
55- pub fn expand_v2_spans (
56- managed_envelope : & mut TypedEnvelope < SpanGroup > ,
57- ) -> Result < ( ) , ProcessingError > {
58- let span_v2_items = managed_envelope
59- . envelope_mut ( )
60- . take_items_by ( ItemContainer :: < SpanV2 > :: is_container) ;
61-
62- // V2 spans must always be sent as an `ItemContainer`, currently it is not allowed to
63- // send multiple containers for V2 spans.
64- //
65- // This restriction may be lifted in the future, this is why this validation only happens
66- // when processing is enabled, allowing it to be changed easily in the future.
67- //
68- // This limit mostly exists to incentivise SDKs to batch multiple spans into a single container,
69- // technically it can be removed without issues.
70- if span_v2_items. len ( ) > 1 {
71- return Err ( ProcessingError :: DuplicateItem ( ItemType :: Span ) ) ;
72- }
73-
74- if span_v2_items. is_empty ( ) {
75- return Ok ( ( ) ) ;
76- }
77-
78- let now = std:: time:: Instant :: now ( ) ;
79-
80- for span_v2_item in span_v2_items {
81- let spans_v2 = match ItemContainer :: parse ( & span_v2_item) {
82- Ok ( spans_v2) => spans_v2,
83- Err ( err) => {
84- relay_log:: debug!( "failed to parse V2 spans: {err}" ) ;
85- track_invalid (
86- managed_envelope,
87- DiscardReason :: InvalidSpan ,
88- span_v2_item. item_count ( ) . unwrap_or ( 1 ) as usize ,
89- ) ;
90- continue ;
91- }
92- } ;
93-
94- for span_v2 in spans_v2. into_items ( ) {
95- let span_v1 = span_v2. value . map_value ( relay_spans:: span_v2_to_span_v1) ;
96- match span_v1. to_json ( ) {
97- Ok ( payload) => {
98- let mut new_item = Item :: new ( ItemType :: Span ) ;
99- new_item. set_payload ( ContentType :: Json , payload) ;
100- managed_envelope. envelope_mut ( ) . add_item ( new_item) ;
101- }
102- Err ( err) => {
103- relay_log:: debug!( "failed to serialize span: {}" , err) ;
104- track_invalid ( managed_envelope, DiscardReason :: Internal , 1 ) ;
105- }
106- }
107- }
108- }
109-
110- relay_statsd:: metric!( timer( RelayTimers :: SpanV2Expansion ) = now. elapsed( ) ) ;
111-
112- Ok ( ( ) )
113- }
114-
11548pub fn convert_otel_traces_data ( managed_envelope : & mut TypedEnvelope < SpanGroup > ) {
11649 let envelope = managed_envelope. envelope_mut ( ) ;
11750
0 commit comments