Files
Ankit PatelandGitHub 1890a7a4c8 Log when Environment Provider tries to pull unset or empty env var (#9837)
**Description:** 
Creates a logger in the confmap.ProviderSettings and uses it to log when
there is a missing or blank environment variable referenced in config.
For now the noop logger is used everywhere except tests.

**Link to tracking Issue:**
[5615](https://github.com/open-telemetry/opentelemetry-collector/issues/5615)

**Testing:** 
I wrote unit tests that ensured 

1. logging occurred when an environment variable was unset 
2. logging occcured when the env var was empty.  
3. there was no log when an env var was used correctly

I also started the otel collector with the sample config - and added an
env var reference in the sample config. I then inserted a print
statement next to each log call to see whether my code paths were hit in
the live application. I then went through the 3 cases mentioned above
and ensured that logging behavior was accurate.
2024-04-04 14:11:16 +02:00

15 lines
349 B
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package confmaptest // import "go.opentelemetry.io/collector/confmap/confmaptest"
import (
"go.uber.org/zap"
"go.opentelemetry.io/collector/confmap"
)
func NewNopProviderSettings() confmap.ProviderSettings {
return confmap.ProviderSettings{Logger: zap.NewNop()}
}