From 20c28baeeb1346ca7d0681a5d56943700f70e95f Mon Sep 17 00:00:00 2001 From: Alex Boten <223565+codeboten@users.noreply.github.com> Date: Wed, 16 Oct 2024 13:31:05 -0700 Subject: [PATCH] chore: minor code cleanup (#11472) Came across these in the work to support v0.3.0 of the configuration schema, split them into a separate PR to reduce complexity of the review. Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com> --- service/service.go | 2 +- service/telemetry/attributes.go | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/service/service.go b/service/service.go index 30cdc60ca9d..1c4d9a7dccf 100644 --- a/service/service.go +++ b/service/service.go @@ -136,7 +136,7 @@ func New(ctx context.Context, set Settings, cfg Config) (*Service, error) { mp, err := telFactory.CreateMeterProvider(ctx, telset, &cfg.Telemetry) if err != nil { - return nil, fmt.Errorf("failed to create metric provider: %w", err) + return nil, fmt.Errorf("failed to create meter provider: %w", err) } logsAboutMeterProvider(logger, cfg.Telemetry.Metrics, mp) diff --git a/service/telemetry/attributes.go b/service/telemetry/attributes.go index 7b1b3b4ed99..60b23a34591 100644 --- a/service/telemetry/attributes.go +++ b/service/telemetry/attributes.go @@ -13,10 +13,8 @@ func attributes(set Settings, cfg Config) map[string]interface{} { for k, v := range cfg.Resource { if v != nil { attrs[k] = *v - } - - // the new value is nil, delete the existing key - if _, ok := attrs[k]; ok && v == nil { + } else { + // the new value is nil, delete the existing key delete(attrs, k) } }