Skip to content

Commit

Permalink
change how defaults are initialized so we don't break static resolver…
Browse files Browse the repository at this point in the history
… config parsing
  • Loading branch information
jvilhuber committed May 25, 2022
1 parent f0aecbf commit aa8095b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
12 changes: 0 additions & 12 deletions exporter/loadbalancingexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@ type ResolverSettings struct {
DNS *DNSResolver `mapstructure:"dns"`
}

func createDefaultResolverSettings() ResolverSettings {
return ResolverSettings{
Static: nil,
DNS: &DNSResolver{
Hostname: "",
Port: "",
Interval: defaultResInterval,
Timeout: defaultResTimeout,
},
}
}

// StaticResolver defines the configuration for the resolver providing a fixed list of backends
type StaticResolver struct {
Hostnames []string `mapstructure:"hostnames"`
Expand Down
2 changes: 1 addition & 1 deletion exporter/loadbalancingexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package loadbalancingexporter // import "github.com/open-telemetry/opentelemetry

import (
"context"

"go.opencensus.io/stats/view"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
Expand Down Expand Up @@ -49,7 +50,6 @@ func createDefaultConfig() config.Exporter {
Protocol: Protocol{
OTLP: *otlpDefaultCfg,
},
Resolver: createDefaultResolverSettings(),
}
}

Expand Down
6 changes: 6 additions & 0 deletions exporter/loadbalancingexporter/resolver_dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ func newDNSResolver(logger *zap.Logger, hostname string, port string, interval t
if len(hostname) == 0 {
return nil, errNoHostname
}
if interval == 0 {
interval = defaultResInterval
}
if timeout == 0 {
timeout = defaultResTimeout
}

return &dnsResolver{
logger: logger,
Expand Down

0 comments on commit aa8095b

Please sign in to comment.