Skip to content

Commit

Permalink
Add changes
Browse files Browse the repository at this point in the history
Signed-off-by: FlamingSaint <[email protected]>
  • Loading branch information
FlamingSaint committed Jul 9, 2024
1 parent 85442e8 commit 865d2ee
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 34 deletions.
23 changes: 1 addition & 22 deletions pkg/prometheus/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"time"

"github.com/asaskevich/govalidator"

"github.com/jaegertracing/jaeger/pkg/config/tlscfg"
)

Expand All @@ -39,25 +40,3 @@ func (c *Configuration) Validate() error {
_, err := govalidator.ValidateStruct(c)
return err

Check warning on line 41 in pkg/prometheus/config/config.go

View check run for this annotation

Codecov / codecov/patch

pkg/prometheus/config/config.go#L39-L41

Added lines #L39 - L41 were not covered by tests
}

// ApplyDefaults copies settings from source unless its own value is non-zero.
func (c *Configuration) ApplyDefaults(source *Configuration) {
if c.ServerURL == "" {
c.ServerURL = source.ServerURL
}
if c.ConnectTimeout == 0 {
c.ConnectTimeout = source.ConnectTimeout
}
if c.MetricNamespace == "" {
c.MetricNamespace = source.MetricNamespace
}
if c.LatencyUnit == "" {
c.LatencyUnit = source.LatencyUnit
}
if c.NormalizeCalls == false {
c.NormalizeCalls = source.NormalizeCalls
}
if c.NormalizeDuration == false {
c.NormalizeDuration = source.NormalizeDuration
}
}
11 changes: 2 additions & 9 deletions plugin/metrics/prometheus/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ func (f *Factory) CreateMetricsReader() (metricsstore.Reader, error) {
return prometheusstore.NewMetricsReader(f.options.Configuration, f.logger, f.tracer)
}

func (f *Factory) configureFromOptions(o *Options) {
f.options = o
}

func NewFactoryWithConfig(
cfg config.Configuration,
logger *zap.Logger,
Expand All @@ -80,13 +76,10 @@ func NewFactoryWithConfig(
return nil, err

Check warning on line 76 in plugin/metrics/prometheus/factory.go

View check run for this annotation

Codecov / codecov/patch

plugin/metrics/prometheus/factory.go#L74-L76

Added lines #L74 - L76 were not covered by tests
}

defaultConfig := DefaultConfig()
cfg.ApplyDefaults(&defaultConfig)

f := NewFactory()
f.configureFromOptions(&Options{
f.options = &Options{
Configuration: cfg,

Check warning on line 81 in plugin/metrics/prometheus/factory.go

View check run for this annotation

Codecov / codecov/patch

plugin/metrics/prometheus/factory.go#L79-L81

Added lines #L79 - L81 were not covered by tests
})
}
err := f.Initialize(logger)
if err != nil {
return nil, err

Check warning on line 85 in plugin/metrics/prometheus/factory.go

View check run for this annotation

Codecov / codecov/patch

plugin/metrics/prometheus/factory.go#L83-L85

Added lines #L83 - L85 were not covered by tests
Expand Down
4 changes: 1 addition & 3 deletions plugin/metrics/prometheus/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ func DefaultConfig() config.Configuration {

// NewOptions creates a new Options struct.
func NewOptions() *Options {
defaultConfig := DefaultConfig()

return &Options{
Configuration: defaultConfig,
Configuration: DefaultConfig(),
}
}

Expand Down

0 comments on commit 865d2ee

Please sign in to comment.