Skip to content

Commit

Permalink
remove unnecessary nil check, add check for conf being nil
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Boten <aboten@lightstep.com>
  • Loading branch information
Alex Boten committed Jun 23, 2023
1 parent 05b7939 commit 72e9446
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions service/telemetry/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ type TracesConfig struct {

// Validate checks whether the current configuration is valid
func (c *Config) Validate() error {

// Check when service telemetry metric level is not none, the metrics address should not be empty
if c.Metrics.Level != configtelemetry.LevelNone && c.Metrics.Address == "" && len(c.Metrics.Readers) == 0 {
return fmt.Errorf("collector telemetry metric address should exist when metric level is not none")
Expand All @@ -135,12 +134,14 @@ func (c *Config) Validate() error {
}

func (mrs *MeterProviderJsonMetricReaders) Unmarshal(conf *confmap.Conf) error {
if conf == nil {
return nil
}

if err := conf.Unmarshal(mrs); err != nil {
return err
}
if *mrs == nil {
*mrs = make(MeterProviderJsonMetricReaders)
}

for key, reader := range *mrs {
readerType := strings.Split(key, "/")[0]
switch readerType {
Expand Down

0 comments on commit 72e9446

Please sign in to comment.