Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func Run(ctx context.Context, w io.Writer) error {
autoComplete := slices.Contains(os.Args[1:], "__complete")

if !autoComplete {
flushMetrics := metric.Initialize()
flushMetrics := metric.Initialize(f.IsTrace())
defer func() {
if err := recover(); err != nil {
handlePanic(err)
Expand Down
8 changes: 7 additions & 1 deletion internal/metric/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"time"

"github.com/go-logr/logr"
"github.com/nais/cli/internal/version"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp"
Expand All @@ -22,7 +23,7 @@ const (

var initialized = false

func Initialize() func(verbose bool) {
func Initialize(verbose bool) func(verbose bool) {
if os.Getenv("DO_NOT_TRACK") == "1" || initialized {
return func(verbose bool) {
if verbose {
Expand All @@ -36,6 +37,11 @@ func Initialize() func(verbose bool) {
provider := newMeterProvider()
otel.SetMeterProvider(provider)

if !verbose {
// Suppress internal OpenTelemetry logs to avoid cluttering the CLI output.
otel.SetLogger(logr.Discard())
}

return func(trace bool) {
if trace {
fmt.Println("Shutdown: uploading metrics...")
Expand Down
Loading