Skip to content

Commit

Permalink
Merge pull request #2 from PB-Digital/tech/ENG-121
Browse files Browse the repository at this point in the history
ENG-121: Disable logger populating terminal
  • Loading branch information
yibrahimov authored Jul 10, 2024
2 parents 8718633 + 20a86e6 commit fcd5a35
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sensor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package instana
import (
"context"
"errors"
"io"
"log"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -104,6 +106,13 @@ func newSensor(options *Options) *sensorS {

s.setLogger(defaultLogger)

// prevent logger populating terminal
if isDisabled, ok := os.LookupEnv("DISABLE_INSTANA_LOGGING"); ok && strings.TrimSpace(isDisabled) != "" {
if isDisabled == "true" {
s.setLogger(logger.New(log.New(io.Discard, "", log.LstdFlags)))
}
}

// override service name with an env value if set
if name, ok := os.LookupEnv("INSTANA_SERVICE_NAME"); ok && strings.TrimSpace(name) != "" {
s.serviceName = name
Expand Down

0 comments on commit fcd5a35

Please sign in to comment.