From 771b1a54db7719da9a878691d05d13c00d805d5f Mon Sep 17 00:00:00 2001 From: Vitor Merencio Date: Fri, 17 May 2024 10:44:38 -0300 Subject: [PATCH] changed the behaviour on how default value is set --- cli/main.go | 6 ++++-- instrumentation.go | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cli/main.go b/cli/main.go index e7f57eb8c..3512e4195 100644 --- a/cli/main.go +++ b/cli/main.go @@ -71,7 +71,7 @@ func main() { var logLevel string flag.BoolVar(&globalImpl, "global-impl", false, "Record telemetry from the OpenTelemetry default global implementation") - flag.StringVar(&logLevel, "log-level", "info", "Define log visibility level") + flag.StringVar(&logLevel, "log-level", "", "Define log visibility level, default is `info`") flag.Usage = usage flag.Parse() @@ -102,7 +102,9 @@ func main() { instOptions = append(instOptions, auto.WithGlobal()) } - instOptions = append(instOptions, auto.WithLogLevel(logLevel)) + if logLevel != "" { + instOptions = append(instOptions, auto.WithLogLevel(logLevel)) + } inst, err := auto.NewInstrumentation(ctx, instOptions...) if err != nil { diff --git a/instrumentation.go b/instrumentation.go index 4e821b6e9..bae5a134d 100644 --- a/instrumentation.go +++ b/instrumentation.go @@ -361,9 +361,10 @@ var lookupEnv = os.LookupEnv // - OTEL_SERVICE_NAME (or OTEL_RESOURCE_ATTRIBUTES): sets the service name // - OTEL_TRACES_EXPORTER: sets the trace exporter // - OTEL_GO_AUTO_GLOBAL: enables the OpenTelemetry global implementation +// - OTEL_LOG_LEVEL: sets the log level // // This option may conflict with [WithTarget], [WithPID], [WithTraceExporter], -// [WithServiceName] and [WithGlobal] if their respective environment variable is defined. +// [WithServiceName], [WithGlobal] and [WithLogLevel] if their respective environment variable is defined. // If more than one of these options are used, the last one provided to an // [Instrumentation] will be used. //