@@ -914,11 +914,6 @@ impl StoreService {
914
914
}
915
915
} ;
916
916
917
- if let Some ( measurements) = & mut span. measurements {
918
- measurements
919
- . retain ( |_, v| v. as_ref ( ) . and_then ( |v| v. value ) . is_some_and ( f64:: is_finite) ) ;
920
- }
921
-
922
917
span. backfill_data ( ) ;
923
918
span. duration_ms =
924
919
( ( span. end_timestamp_precise - span. start_timestamp_precise ) * 1e3 ) as u32 ;
@@ -1007,7 +1002,8 @@ impl StoreService {
1007
1002
1008
1003
if let Some ( data) = span. data {
1009
1004
for ( key, raw_value) in data {
1010
- let Some ( json_value) = raw_value else {
1005
+ let Some ( json_value) = raw_value. and_then ( |raw| Deserialize :: deserialize ( raw) . ok ( ) )
1006
+ else {
1011
1007
continue ;
1012
1008
} ;
1013
1009
let any_value = match json_value {
@@ -1051,7 +1047,7 @@ impl StoreService {
1051
1047
trace_item. attributes . insert (
1052
1048
"sentry.raw_description" . into ( ) ,
1053
1049
AnyValue {
1054
- value : Some ( Value :: StringValue ( description) ) ,
1050
+ value : Some ( Value :: StringValue ( description. to_owned ( ) ) ) ,
1055
1051
} ,
1056
1052
) ;
1057
1053
}
@@ -1624,15 +1620,15 @@ struct SpanLink<'a> {
1624
1620
}
1625
1621
1626
1622
#[ derive( Debug , Deserialize , Serialize , Clone ) ]
1627
- struct SpanMeasurement {
1628
- #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
1629
- value : Option < f64 > ,
1623
+ struct SpanMeasurement < ' a > {
1624
+ #[ serde( skip_serializing_if = "Option::is_none" , borrow ) ]
1625
+ value : Option < & ' a RawValue > ,
1630
1626
}
1631
1627
1632
1628
#[ derive( Debug , Deserialize , Serialize , Clone ) ]
1633
1629
struct SpanKafkaMessage < ' a > {
1634
1630
#[ serde( default , skip_serializing_if = "Option::is_none" ) ]
1635
- description : Option < String > ,
1631
+ description : Option < & ' a str > ,
1636
1632
#[ serde( default ) ]
1637
1633
duration_ms : u32 ,
1638
1634
/// The ID of the transaction event associated to this span, if any.
@@ -1646,17 +1642,17 @@ struct SpanKafkaMessage<'a> {
1646
1642
is_remote : bool ,
1647
1643
1648
1644
#[ serde( skip_serializing_if = "none_or_empty_map" , borrow) ]
1649
- data : Option < BTreeMap < Cow < ' a , str > , Option < serde_json :: Value > > > ,
1645
+ data : Option < BTreeMap < Cow < ' a , str > , Option < & ' a RawValue > > > ,
1650
1646
#[ serde( default , skip_serializing_if = "Option::is_none" ) ]
1651
1647
kind : Option < & ' a str > ,
1652
1648
#[ serde( default , skip_serializing_if = "none_or_empty_vec" ) ]
1653
1649
links : Option < Vec < SpanLink < ' a > > > ,
1654
1650
#[ serde( borrow, default , skip_serializing_if = "Option::is_none" ) ]
1655
- measurements : Option < BTreeMap < Cow < ' a , str > , Option < SpanMeasurement > > > ,
1651
+ measurements : Option < BTreeMap < & ' a str , Option < SpanMeasurement < ' a > > > > ,
1656
1652
#[ serde( default ) ]
1657
1653
organization_id : u64 ,
1658
1654
#[ serde( borrow, default , skip_serializing_if = "Option::is_none" ) ]
1659
- origin : Option < Cow < ' a , str > > ,
1655
+ origin : Option < & ' a str > ,
1660
1656
#[ serde( default , skip_serializing_if = "Option::is_none" ) ]
1661
1657
parent_span_id : Option < & ' a str > ,
1662
1658
#[ serde( default , skip_serializing_if = "Option::is_none" ) ]
@@ -1677,10 +1673,10 @@ struct SpanKafkaMessage<'a> {
1677
1673
serialize_with = "serialize_btreemap_skip_nulls"
1678
1674
) ]
1679
1675
#[ serde( borrow) ]
1680
- sentry_tags : Option < BTreeMap < & ' a str , Option < serde_json :: Value > > > ,
1676
+ sentry_tags : Option < BTreeMap < & ' a str , Option < & ' a RawValue > > > ,
1681
1677
span_id : & ' a str ,
1682
1678
#[ serde( skip_serializing_if = "none_or_empty_map" , borrow) ]
1683
- tags : Option < BTreeMap < & ' a str , Option < serde_json :: Value > > > ,
1679
+ tags : Option < BTreeMap < & ' a str , Option < & ' a RawValue > > > ,
1684
1680
trace_id : EventId ,
1685
1681
1686
1682
#[ serde( default ) ]
@@ -1691,7 +1687,7 @@ struct SpanKafkaMessage<'a> {
1691
1687
end_timestamp_precise : f64 ,
1692
1688
1693
1689
#[ serde( borrow, default , skip_serializing) ]
1694
- platform : Cow < ' a , str > , // We only use this for logging for now
1690
+ platform : & ' a str , // We only use this for logging for now
1695
1691
1696
1692
#[ serde( default , skip_serializing_if = "Option::is_none" ) ]
1697
1693
client_sample_rate : Option < f64 > ,
@@ -1737,11 +1733,18 @@ impl SpanKafkaMessage<'_> {
1737
1733
} ;
1738
1734
1739
1735
match & key[ ..] {
1740
- "client_sample_rate" => self . client_sample_rate = Some ( value) ,
1741
- "server_sample_rate" => self . server_sample_rate = Some ( value) ,
1736
+ "client_sample_rate" => {
1737
+ if let Ok ( client_sample_rate) = Deserialize :: deserialize ( value) {
1738
+ self . client_sample_rate = Some ( client_sample_rate) ;
1739
+ }
1740
+ }
1741
+ "server_sample_rate" => {
1742
+ if let Ok ( server_sample_rate) = Deserialize :: deserialize ( value) {
1743
+ self . server_sample_rate = Some ( server_sample_rate) ;
1744
+ }
1745
+ }
1742
1746
_ => {
1743
- data. entry ( key. clone ( ) )
1744
- . or_insert_with ( || Some ( value. into ( ) ) ) ;
1747
+ data. entry ( Cow :: Borrowed ( key) ) . or_insert ( Some ( value) ) ;
1745
1748
}
1746
1749
}
1747
1750
}
@@ -1759,8 +1762,7 @@ impl SpanKafkaMessage<'_> {
1759
1762
key
1760
1763
} ;
1761
1764
1762
- data. entry ( Cow :: Borrowed ( key) )
1763
- . or_insert_with ( || Some ( value. clone ( ) ) ) ;
1765
+ data. entry ( Cow :: Borrowed ( key) ) . or_insert ( Some ( value) ) ;
1764
1766
}
1765
1767
}
1766
1768
@@ -1771,13 +1773,12 @@ impl SpanKafkaMessage<'_> {
1771
1773
} ;
1772
1774
1773
1775
let key = if * key == "description" {
1774
- "sentry.normalized_description" . to_owned ( )
1776
+ Cow :: Borrowed ( "sentry.normalized_description" )
1775
1777
} else {
1776
- format ! ( "sentry.{key}" )
1778
+ Cow :: Owned ( format ! ( "sentry.{key}" ) )
1777
1779
} ;
1778
1780
1779
- data. entry ( Cow :: Owned ( key) )
1780
- . or_insert_with ( || Some ( value. clone ( ) ) ) ;
1781
+ data. entry ( key) . or_insert ( Some ( value) ) ;
1781
1782
}
1782
1783
}
1783
1784
}
0 commit comments