Skip to content

Commit

Permalink
Fix New Relic default metric URL. (#2739)
Browse files Browse the repository at this point in the history
* Fix metric url default value.

* Add regression testing for bug in override URL.
  • Loading branch information
a-feld authored Mar 19, 2021
1 parent 48cbeb5 commit 3bdf190
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 7 additions & 5 deletions exporter/newrelicexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ func (c Config) HarvestOption(cfg *telemetry.Config) {
cfg.Product = product
cfg.ProductVersion = version
var prefix string
if c.metricsInsecure {
prefix = "http://"
} else {
prefix = "https://"
if c.MetricsHostOverride != "" {
if c.metricsInsecure {
prefix = "http://"
} else {
prefix = "https://"
}
cfg.MetricsURLOverride = prefix + c.MetricsHostOverride
}
cfg.MetricsURLOverride = prefix + c.MetricsHostOverride
}
8 changes: 7 additions & 1 deletion exporter/newrelicexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ func TestLoadConfig(t *testing.T) {
assert.Equal(t, len(cfg.Exporters), 2)

r0 := cfg.Exporters["newrelic"]
assert.Equal(t, r0, factory.CreateDefaultConfig())
defaultConfig := factory.CreateDefaultConfig().(*Config)
assert.Equal(t, r0, defaultConfig)

defaultNrConfig := new(telemetry.Config)
defaultConfig.HarvestOption(defaultNrConfig)
assert.Empty(t, defaultNrConfig.MetricsURLOverride)
assert.Empty(t, defaultNrConfig.SpansURLOverride)

r1 := cfg.Exporters["newrelic/alt"].(*Config)
assert.Equal(t, r1, &Config{
Expand Down

0 comments on commit 3bdf190

Please sign in to comment.