Skip to content

Commit

Permalink
chore: do not log error when receiver has no endpoint (open-telemetry…
Browse files Browse the repository at this point in the history
…#1666)

* chore: do not log error when receiver has no endpoint

Some receivers don't have an `endpoint` config value. No need to log a
type error for these.

* chore: integrate review feedback
  • Loading branch information
jacobmarble authored Apr 24, 2023
1 parent eb78330 commit 5a68bd2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/collector/parser/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ func singlePortFromConfigEndpoint(logger logr.Logger, name string, config map[in
endpoint = getAddressFromConfig(logger, name, endpointKey, config)
}

switch endpoint := endpoint.(type) {
switch e := endpoint.(type) {
case nil:
break
case string:
port, err := portFromEndpoint(endpoint)
port, err := portFromEndpoint(e)
if err != nil {
logger.WithValues(endpointKey, endpoint).Info("couldn't parse the endpoint's port")
logger.WithValues(endpointKey, e).Error(err, "couldn't parse the endpoint's port")
return nil
}

Expand All @@ -128,7 +130,7 @@ func singlePortFromConfigEndpoint(logger logr.Logger, name string, config map[in
Port: port,
}
default:
logger.Info("receiver's endpoint isn't a string")
logger.WithValues(endpointKey, endpoint).Error(fmt.Errorf("unrecognized type %T", endpoint), "receiver's endpoint isn't a string")
}

return nil
Expand Down

0 comments on commit 5a68bd2

Please sign in to comment.