Skip to content

Commit

Permalink
use correct scope constructor (#3005)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreiding committed Jun 17, 2022
1 parent 0b0fea0 commit 79844fd
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions common/metrics/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ var (
// only one of them will be used for reporting.
//
// Current priority order is:
// m3 > statsd > prometheus
// statsd > prometheus
func NewScope(logger log.Logger, c *Config) tally.Scope {
if c.Statsd != nil {
return newStatsdScope(logger, c)
Expand Down Expand Up @@ -386,31 +386,19 @@ func MetricsHandlerFromConfig(logger log.Logger, c *Config) MetricsHandler {
}

setDefaultPerUnitHistogramBoundaries(&c.ClientConfig)
if c.Prometheus != nil {
switch c.Prometheus.Framework {
case FrameworkOpentelemetry:
otelProvider, err := NewOpenTelemetryProvider(logger, c.Prometheus, &c.ClientConfig)
if err != nil {
logger.Fatal(err.Error())
}

return NewOtelMetricsHandler(logger, otelProvider, c.ClientConfig)
case FrameworkTally:
default:
return NewTallyMetricsHandler(
c.ClientConfig,
newPrometheusScope(
logger,
convertPrometheusConfigToTally(c.Prometheus),
&c.ClientConfig,
),
)

if c.Prometheus != nil && c.Prometheus.Framework == FrameworkOpentelemetry {
otelProvider, err := NewOpenTelemetryProvider(logger, c.Prometheus, &c.ClientConfig)
if err != nil {
logger.Fatal(err.Error())
}

return NewOtelMetricsHandler(logger, otelProvider, c.ClientConfig)
}

return NewTallyMetricsHandler(
c.ClientConfig,
newStatsdScope(logger, c),
NewScope(logger, c),
)
}

Expand Down

0 comments on commit 79844fd

Please sign in to comment.