@@ -20,6 +20,7 @@ use chrono::DateTime;
2020use opentelemetry_proto:: tonic:: common:: v1:: {
2121 any_value:: Value as OtelValue , AnyValue , ArrayValue , KeyValue , KeyValueList ,
2222} ;
23+ use serde:: Serialize ;
2324use serde_json:: { Map , Value } ;
2425
2526// Value can be one of types - String, Bool, Int, Double, ArrayValue, AnyValue, KeyValueList, Byte
@@ -149,7 +150,7 @@ pub fn value_to_string(value: serde_json::Value) -> String {
149150 }
150151}
151152
152- pub fn flatten_attributes ( attributes : & Vec < KeyValue > ) -> Map < String , Value > {
153+ pub fn flatten_attributes ( attributes : & [ KeyValue ] ) -> Map < String , Value > {
153154 let mut attributes_json: Map < String , Value > = Map :: new ( ) ;
154155 for attribute in attributes {
155156 let key = & attribute. key ;
@@ -182,7 +183,7 @@ pub fn insert_bool_if_some(map: &mut Map<String, Value>, key: &str, option: &Opt
182183 }
183184}
184185
185- pub fn insert_attributes ( map : & mut Map < String , Value > , attributes : & Vec < KeyValue > ) {
186+ pub fn insert_attributes ( map : & mut Map < String , Value > , attributes : & [ KeyValue ] ) {
186187 let attributes_json = flatten_attributes ( attributes) ;
187188 for ( key, value) in attributes_json {
188189 map. insert ( key, value) ;
@@ -194,7 +195,7 @@ pub fn convert_epoch_nano_to_timestamp(epoch_ns: i64) -> String {
194195 dt. format ( "%Y-%m-%dT%H:%M:%S%.6fZ" ) . to_string ( )
195196}
196197
197- #[ derive( Debug , thiserror:: Error ) ]
198+ #[ derive( Debug , thiserror:: Error , Serialize ) ]
198199pub enum OtelError {
199200 #[ error( "Ingestion failed because the attributes count {0} exceeded the threshold of {1}" ) ]
200201 AttributeCountExceeded ( usize , usize ) ,
0 commit comments