@@ -412,7 +412,7 @@ pub struct ExponentialHistogramDataPoint {
412412 /// count is the number of values in the population. Must be
413413 /// non-negative. This value must be equal to the sum of the "bucket_counts"
414414 /// values in the positive and negative Buckets plus the "zero_count" field.
415- pub count : Option < u64 > ,
415+ pub count : Option < String > ,
416416 /// sum of the values in the population. If count is zero then this field
417417 /// must be zero.
418418 ///
@@ -516,7 +516,7 @@ pub struct SummaryDataPoint {
516516 /// 1970.
517517 pub time_unix_nano : Option < String > ,
518518 /// count is the number of values in the population. Must be non-negative.
519- pub count : Option < u64 > ,
519+ pub count : Option < String > ,
520520 /// sum of the values in the population. If count is zero then this field
521521 /// must be zero.
522522 ///
@@ -535,7 +535,7 @@ pub struct SummaryDataPoint {
535535}
536536/// Nested message and enum types in `SummaryDataPoint`.
537537pub mod summary_data_point {
538- use serde:: { Deserialize , Serialize } ;
538+ use serde:: { Deserialize , Deserializer , Serialize } ;
539539 /// Represents the value at a given quantile of a distribution.
540540 ///
541541 /// To record Min and Max values following conventions are used:
@@ -553,8 +553,34 @@ pub mod summary_data_point {
553553 /// The value at the given quantile of a distribution.
554554 ///
555555 /// Quantile values must NOT be negative.
556+ #[ serde( deserialize_with = "deserialize_f64_or_nan" ) ]
556557 pub value : Option < f64 > ,
557558 }
559+
560+ fn deserialize_f64_or_nan < ' de , D > ( deserializer : D ) -> Result < Option < f64 > , D :: Error > where D : Deserializer < ' de > ,
561+ {
562+ struct StringOrFloatVisitor ;
563+ impl < ' de > serde:: de:: Visitor < ' de > for StringOrFloatVisitor
564+ {
565+ type Value = Option < f64 > ;
566+ fn expecting ( & self , formatter : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result
567+ {
568+ formatter. write_str ( "a string or a floating-point number" )
569+ }
570+ fn visit_str < E > ( self , value : & str ) -> Result < Self :: Value , E > where E : serde:: de:: Error ,
571+ {
572+ if value == "NaN"
573+ {
574+ Ok ( Some ( f64:: NAN ) )
575+ } else {
576+ value. parse :: < f64 > ( ) . map ( Some ) . map_err ( E :: custom)
577+ } }
578+ fn visit_f64 < E > ( self , value : f64 ) -> Result < Self :: Value , E > where E : serde:: de:: Error ,
579+ {
580+ Ok ( Some ( value) )
581+ }
582+ }
583+ deserializer. deserialize_any ( StringOrFloatVisitor ) }
558584}
559585/// A representation of an exemplar, which is a sample input measurement.
560586/// Exemplars also hold information about the environment when the measurement
0 commit comments