@@ -62,14 +62,17 @@ func testLoadConfigFile_topLevel(t *testing.T, entropy *configutil.Entropy) {
62
62
},
63
63
64
64
Telemetry : & configutil.Telemetry {
65
- StatsdAddr : "bar" ,
66
- StatsiteAddr : "foo" ,
67
- DisableHostname : false ,
68
- DogStatsDAddr : "127.0.0.1:7254" ,
69
- DogStatsDTags : []string {"tag_1:val_1" , "tag_2:val_2" },
70
- PrometheusRetentionTime : 30 * time .Second ,
71
- UsageGaugePeriod : 5 * time .Minute ,
72
- MaximumGaugeCardinality : 125 ,
65
+ StatsdAddr : "bar" ,
66
+ StatsiteAddr : "foo" ,
67
+ DisableHostname : false ,
68
+ DogStatsDAddr : "127.0.0.1:7254" ,
69
+ DogStatsDTags : []string {"tag_1:val_1" , "tag_2:val_2" },
70
+ PrometheusRetentionTime : 30 * time .Second ,
71
+ UsageGaugePeriod : 5 * time .Minute ,
72
+ MaximumGaugeCardinality : 125 ,
73
+ LeaseMetricsEpsilon : time .Hour ,
74
+ NumLeaseMetricsTimeBuckets : 168 ,
75
+ LeaseMetricsNameSpaceLabels : false ,
73
76
},
74
77
75
78
DisableMlock : true ,
@@ -192,6 +195,9 @@ func testLoadConfigFile_json2(t *testing.T, entropy *configutil.Entropy) {
192
195
CirconusBrokerID : "0" ,
193
196
CirconusBrokerSelectTag : "dc:sfo" ,
194
197
PrometheusRetentionTime : 30 * time .Second ,
198
+ LeaseMetricsEpsilon : time .Hour ,
199
+ NumLeaseMetricsTimeBuckets : 168 ,
200
+ LeaseMetricsNameSpaceLabels : false ,
195
201
},
196
202
},
197
203
@@ -371,15 +377,18 @@ func testLoadConfigFile(t *testing.T) {
371
377
},
372
378
373
379
Telemetry : & configutil.Telemetry {
374
- StatsdAddr : "bar" ,
375
- StatsiteAddr : "foo" ,
376
- DisableHostname : false ,
377
- UsageGaugePeriod : 5 * time .Minute ,
378
- MaximumGaugeCardinality : 100 ,
379
- DogStatsDAddr : "127.0.0.1:7254" ,
380
- DogStatsDTags : []string {"tag_1:val_1" , "tag_2:val_2" },
381
- PrometheusRetentionTime : configutil .PrometheusDefaultRetentionTime ,
382
- MetricsPrefix : "myprefix" ,
380
+ StatsdAddr : "bar" ,
381
+ StatsiteAddr : "foo" ,
382
+ DisableHostname : false ,
383
+ UsageGaugePeriod : 5 * time .Minute ,
384
+ MaximumGaugeCardinality : 100 ,
385
+ DogStatsDAddr : "127.0.0.1:7254" ,
386
+ DogStatsDTags : []string {"tag_1:val_1" , "tag_2:val_2" },
387
+ PrometheusRetentionTime : configutil .PrometheusDefaultRetentionTime ,
388
+ MetricsPrefix : "myprefix" ,
389
+ LeaseMetricsEpsilon : time .Hour ,
390
+ NumLeaseMetricsTimeBuckets : 168 ,
391
+ LeaseMetricsNameSpaceLabels : false ,
383
392
},
384
393
385
394
DisableMlock : true ,
@@ -477,6 +486,9 @@ func testLoadConfigFile_json(t *testing.T) {
477
486
CirconusBrokerID : "" ,
478
487
CirconusBrokerSelectTag : "" ,
479
488
PrometheusRetentionTime : configutil .PrometheusDefaultRetentionTime ,
489
+ LeaseMetricsEpsilon : time .Hour ,
490
+ NumLeaseMetricsTimeBuckets : 168 ,
491
+ LeaseMetricsNameSpaceLabels : false ,
480
492
},
481
493
482
494
PidFile : "./pidfile" ,
@@ -540,12 +552,15 @@ func testLoadConfigDir(t *testing.T) {
540
552
},
541
553
542
554
Telemetry : & configutil.Telemetry {
543
- StatsiteAddr : "qux" ,
544
- StatsdAddr : "baz" ,
545
- DisableHostname : true ,
546
- UsageGaugePeriod : 5 * time .Minute ,
547
- MaximumGaugeCardinality : 100 ,
548
- PrometheusRetentionTime : configutil .PrometheusDefaultRetentionTime ,
555
+ StatsiteAddr : "qux" ,
556
+ StatsdAddr : "baz" ,
557
+ DisableHostname : true ,
558
+ UsageGaugePeriod : 5 * time .Minute ,
559
+ MaximumGaugeCardinality : 100 ,
560
+ PrometheusRetentionTime : configutil .PrometheusDefaultRetentionTime ,
561
+ LeaseMetricsEpsilon : time .Hour ,
562
+ NumLeaseMetricsTimeBuckets : 168 ,
563
+ LeaseMetricsNameSpaceLabels : false ,
549
564
},
550
565
ClusterName : "testcluster" ,
551
566
},
@@ -668,6 +683,9 @@ func testConfig_Sanitized(t *testing.T) {
668
683
"stackdriver_debug_logs" : false ,
669
684
"statsd_address" : "bar" ,
670
685
"statsite_address" : "" ,
686
+ "lease_metrics_epsilon" : time .Hour ,
687
+ "num_lease_metrics_buckets" : 168 ,
688
+ "add_lease_metrics_namespace_labels" : false ,
671
689
},
672
690
}
673
691
@@ -787,3 +805,93 @@ func testParseSeals(t *testing.T) {
787
805
}
788
806
require .Equal (t , config , expected )
789
807
}
808
+
809
+ func testLoadConfigFileLeaseMetrics (t * testing.T ) {
810
+ config , err := LoadConfigFile ("./test-fixtures/config5.hcl" )
811
+ if err != nil {
812
+ t .Fatalf ("err: %s" , err )
813
+ }
814
+
815
+ expected := & Config {
816
+ SharedConfig : & configutil.SharedConfig {
817
+ Listeners : []* configutil.Listener {
818
+ {
819
+ Type : "tcp" ,
820
+ Address : "127.0.0.1:443" ,
821
+ },
822
+ },
823
+
824
+ Telemetry : & configutil.Telemetry {
825
+ StatsdAddr : "bar" ,
826
+ StatsiteAddr : "foo" ,
827
+ DisableHostname : false ,
828
+ UsageGaugePeriod : 5 * time .Minute ,
829
+ MaximumGaugeCardinality : 100 ,
830
+ DogStatsDAddr : "127.0.0.1:7254" ,
831
+ DogStatsDTags : []string {"tag_1:val_1" , "tag_2:val_2" },
832
+ PrometheusRetentionTime : configutil .PrometheusDefaultRetentionTime ,
833
+ MetricsPrefix : "myprefix" ,
834
+ LeaseMetricsEpsilon : time .Hour ,
835
+ NumLeaseMetricsTimeBuckets : 2 ,
836
+ LeaseMetricsNameSpaceLabels : true ,
837
+ },
838
+
839
+ DisableMlock : true ,
840
+
841
+ Entropy : nil ,
842
+
843
+ PidFile : "./pidfile" ,
844
+
845
+ ClusterName : "testcluster" ,
846
+ },
847
+
848
+ Storage : & Storage {
849
+ Type : "consul" ,
850
+ RedirectAddr : "foo" ,
851
+ Config : map [string ]string {
852
+ "foo" : "bar" ,
853
+ },
854
+ },
855
+
856
+ HAStorage : & Storage {
857
+ Type : "consul" ,
858
+ RedirectAddr : "snafu" ,
859
+ Config : map [string ]string {
860
+ "bar" : "baz" ,
861
+ },
862
+ DisableClustering : true ,
863
+ },
864
+
865
+ ServiceRegistration : & ServiceRegistration {
866
+ Type : "consul" ,
867
+ Config : map [string ]string {
868
+ "foo" : "bar" ,
869
+ },
870
+ },
871
+
872
+ DisableCache : true ,
873
+ DisableCacheRaw : true ,
874
+ DisablePrintableCheckRaw : true ,
875
+ DisablePrintableCheck : true ,
876
+ EnableUI : true ,
877
+ EnableUIRaw : true ,
878
+
879
+ EnableRawEndpoint : true ,
880
+ EnableRawEndpointRaw : true ,
881
+
882
+ DisableSealWrap : true ,
883
+ DisableSealWrapRaw : true ,
884
+
885
+ MaxLeaseTTL : 10 * time .Hour ,
886
+ MaxLeaseTTLRaw : "10h" ,
887
+ DefaultLeaseTTL : 10 * time .Hour ,
888
+ DefaultLeaseTTLRaw : "10h" ,
889
+ }
890
+
891
+ addExpectedEntConfig (expected , []string {})
892
+
893
+ config .Listeners [0 ].RawConfig = nil
894
+ if diff := deep .Equal (config , expected ); diff != nil {
895
+ t .Fatal (diff )
896
+ }
897
+ }
0 commit comments