@@ -50,6 +50,22 @@ type (
5050 // - "milliseconds"
5151 // - "bytes"
5252 PerUnitHistogramBoundaries map [string ][]float64 `yaml:"perUnitHistogramBoundaries"`
53+
54+ // Following configs are added for backwards compatibility when switching from tally to opentelemetry
55+ // All configs should be set to true when using opentelemetry framework to have the same behavior as tally.
56+
57+ // WithoutUnitSuffix controls the additional of unit suffixes to metric names.
58+ // This config only takes effect when using opentelemetry framework.
59+ // Note: this config only takes effect when using prometheus via opentelemetry framework
60+ WithoutUnitSuffix bool `yaml:"withoutUnitSuffix"`
61+ // WithoutCounterSuffix controls the additional of _total suffixes to counter metric names.
62+ // This config only takes effect when using opentelemetry framework.
63+ // Note: this config only takes effect when using prometheus via opentelemetry framework
64+ WithoutCounterSuffix bool `yaml:"withoutCounterSuffix"`
65+ // RecordTimerInSeconds controls if Timer metric should be emitted as number of seconds
66+ // (instead of milliseconds).
67+ // This config only takes effect when using opentelemetry framework for both statsd and prometheus.
68+ RecordTimerInSeconds bool `yaml:"recordTimerInSeconds"`
5369 }
5470
5571 // StatsdConfig contains the config items for statsd metrics reporter
@@ -127,20 +143,6 @@ type (
127143 // specify which characters are valid and/or should be replaced before metrics
128144 // are emitted.
129145 SanitizeOptions * SanitizeOptions `yaml:"sanitizeOptions"`
130-
131- // Following configs are added for backwards compatibility when switching from tally to opentelemetry
132- // All configs should be set to true when using opentelemetry framework to have the same behavior as tally.
133-
134- // WithoutUnitSuffix controls the addition of unit suffixes to metric names.
135- // This config only takes effect when using prometheus via opentelemetry framework.
136- WithoutUnitSuffix bool `yaml:"withoutUnitSuffix"`
137- // WithoutCounterSuffix controls the additional of _total suffixes to counter metric names.
138- // This config only takes effect when using prometheus via opentelemetry framework.
139- WithoutCounterSuffix bool `yaml:"withoutCounterSuffix"`
140- // RecordTimerInSeconds controls if Timer metric should be emitted as number of seconds
141- // (instead of milliseconds).
142- // This config only takes effect when using prometheus via opentelemetry framework.
143- RecordTimerInSeconds bool `yaml:"recordTimerInSeconds"`
144146 }
145147)
146148
@@ -461,6 +463,7 @@ func MetricsHandlerFromConfig(logger log.Logger, c *Config) (Handler, error) {
461463
462464 setDefaultPerUnitHistogramBoundaries (& c .ClientConfig )
463465
466+ fatalOnListenerError := true
464467 if c .Statsd != nil && c .Statsd .Framework == FrameworkOpentelemetry {
465468 // create opentelemetry provider with just statsd
466469 otelProvider , err := NewOpenTelemetryProviderWithStatsd (logger , c .Statsd , & c .ClientConfig )
@@ -472,12 +475,11 @@ func MetricsHandlerFromConfig(logger log.Logger, c *Config) (Handler, error) {
472475
473476 if c .Prometheus != nil && c .Prometheus .Framework == FrameworkOpentelemetry {
474477 // create opentelemetry provider with just prometheus
475- fatalOnListenerError := true
476478 otelProvider , err := NewOpenTelemetryProviderWithPrometheus (logger , c .Prometheus , & c .ClientConfig , fatalOnListenerError )
477479 if err != nil {
478480 logger .Fatal (err .Error ())
479481 }
480- return NewOtelMetricsHandler (logger , otelProvider , c .ClientConfig , c .Prometheus .RecordTimerInSeconds )
482+ return NewOtelMetricsHandler (logger , otelProvider , c .ClientConfig , c .ClientConfig .RecordTimerInSeconds )
481483 }
482484
483485 // fallback to tally if no framework is specified
0 commit comments