@@ -412,7 +412,7 @@ pub struct ExponentialHistogramDataPoint {
412
412
/// count is the number of values in the population. Must be
413
413
/// non-negative. This value must be equal to the sum of the "bucket_counts"
414
414
/// values in the positive and negative Buckets plus the "zero_count" field.
415
- pub count : Option < u64 > ,
415
+ pub count : Option < String > ,
416
416
/// sum of the values in the population. If count is zero then this field
417
417
/// must be zero.
418
418
///
@@ -516,7 +516,7 @@ pub struct SummaryDataPoint {
516
516
/// 1970.
517
517
pub time_unix_nano : Option < String > ,
518
518
/// count is the number of values in the population. Must be non-negative.
519
- pub count : Option < u64 > ,
519
+ pub count : Option < String > ,
520
520
/// sum of the values in the population. If count is zero then this field
521
521
/// must be zero.
522
522
///
@@ -535,7 +535,7 @@ pub struct SummaryDataPoint {
535
535
}
536
536
/// Nested message and enum types in `SummaryDataPoint`.
537
537
pub mod summary_data_point {
538
- use serde:: { Deserialize , Serialize } ;
538
+ use serde:: { Deserialize , Deserializer , Serialize } ;
539
539
/// Represents the value at a given quantile of a distribution.
540
540
///
541
541
/// To record Min and Max values following conventions are used:
@@ -553,8 +553,34 @@ pub mod summary_data_point {
553
553
/// The value at the given quantile of a distribution.
554
554
///
555
555
/// Quantile values must NOT be negative.
556
+ #[ serde( deserialize_with = "deserialize_f64_or_nan" ) ]
556
557
pub value : Option < f64 > ,
557
558
}
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 ) }
558
584
}
559
585
/// A representation of an exemplar, which is a sample input measurement.
560
586
/// Exemplars also hold information about the environment when the measurement
0 commit comments