@@ -26,7 +26,7 @@ interface JsonMetricBase {
2626interface MetricValue { } ;
2727
2828// Base types
29- interface PersistentIdMetricValue extends MetricValue {
29+ interface StringMetricValue extends MetricValue {
3030 type : "string" ;
3131 value : string ;
3232}
@@ -54,6 +54,11 @@ interface BytesMetricValue {
5454 value : number ;
5555}
5656
57+ interface BoolMetricValue {
58+ type : "bool" ;
59+ value : boolean ;
60+ }
61+
5762interface PercentMetricValue {
5863 type : "percent" ;
5964 value : {
@@ -110,12 +115,13 @@ interface CacheStatsValue extends MetricValue {
110115}
111116
112117type JsonMetricValue =
118+ BoolMetricValue |
113119 CountMetricValue |
114120 BytesMetricValue |
115121 PercentMetricValue |
116122 DurationMetricValue |
117123 StatsMetricValue |
118- PersistentIdMetricValue |
124+ StringMetricValue |
119125 DistributionValue |
120126 RetainmentValue |
121127 IntMetricValue |
@@ -375,6 +381,10 @@ class BooleanValue extends PropertyValue {
375381 this . value = id ;
376382 }
377383
384+ static fromBoolMetric ( value : BoolMetricValue ) : BooleanValue {
385+ return new BooleanValue ( value . value ) ;
386+ }
387+
378388 getNumericValue ( ) : Option < number > {
379389 return this . value ? Option . some ( 0 ) : Option . some ( 1 ) ;
380390 }
@@ -721,12 +731,17 @@ export class Measurement {
721731 let metric_id = metric . metric_id ;
722732 let kind = metric_id . split ( "_" ) . pop ( ) ; // count, bytes, etc
723733 if ( metric . labels ) {
724- let labels = metric . labels . map ( e => e . join ( ":" ) ) . join ( "." ) ;
725- if ( metric . labels . length !== 0 ) {
726- metric_id = metric_id + "." + labels ;
727- }
734+ let labels = metric . labels . map ( e => e . join ( ":" ) ) . join ( "." ) ;
735+ if ( metric . labels . length !== 0 ) {
736+ metric_id = metric_id + "." + labels ;
737+ }
728738 }
729739 switch ( kind ) {
740+ case "bool" : {
741+ let m = metric . value as BoolMetricValue ;
742+ let value = BooleanValue . fromBoolMetric ( m ) ;
743+ return [ new Measurement ( metric_id , Option . some ( value ) ) ] ;
744+ }
730745 case "bytes" : {
731746 let m = metric . value as BytesMetricValue ;
732747 let bytes = BytesValue . fromBytesMetric ( m ) ;
@@ -767,7 +782,7 @@ export class Measurement {
767782 ] ;
768783 }
769784 case "id" : { // persistent_id
770- let s = metric . value as PersistentIdMetricValue ;
785+ let s = metric . value as StringMetricValue ;
771786 let str = StringValue . fromString ( s . value ) ;
772787 return [ new Measurement ( metric_id , Option . some ( str ) ) ] ;
773788 }
@@ -845,6 +860,11 @@ export class Measurement {
845860 new Measurement ( metric_id + ".steps" , Option . some ( steps ) ) ,
846861 ] ;
847862 }
863+ case "policy" : {
864+ let s = metric . value as StringMetricValue ;
865+ let str = StringValue . fromString ( s . value ) ;
866+ return [ new Measurement ( metric_id , Option . some ( str ) ) ] ;
867+ }
848868 }
849869 return [ ] ;
850870 }
0 commit comments