Skip to content

Commit cabbc51

Browse files
committed
feat(router): permit log service name to be configured via env var
1 parent e7c05cb commit cabbc51

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

router/cmd/main.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ import (
2626
)
2727

2828
var (
29-
overrideEnvFlag = flag.String("override-env", os.Getenv("OVERRIDE_ENV"), "Path to .env file to override environment variables")
30-
routerVersion = flag.Bool("version", false, "Prints the version and dependency information")
31-
pprofListenAddr = flag.String("pprof-addr", os.Getenv("PPROF_ADDR"), "Address to listen for pprof requests. e.g. :6060 for localhost:6060")
32-
pyroscopeAddr = flag.String("pyroscope-addr", os.Getenv("PYROSCOPE_ADDR"), "Address to use for pyroscope continuous profiling. e.g. http://localhost:4040")
29+
overrideEnvFlag = flag.String("override-env", os.Getenv("OVERRIDE_ENV"), "Path to .env file to override environment variables")
30+
routerVersion = flag.Bool("version", false, "Prints the version and dependency information")
31+
pprofListenAddr = flag.String("pprof-addr", os.Getenv("PPROF_ADDR"), "Address to listen for pprof requests. e.g. :6060 for localhost:6060")
32+
pyroscopeAddr = flag.String("pyroscope-addr", os.Getenv("PYROSCOPE_ADDR"), "Address to use for pyroscope continuous profiling. e.g. http://localhost:4040")
33+
logServiceName = flag.String("log-service-name", os.Getenv("LOG_SERVICE_NAME"), "Service name to use in logs, defaults to @wundergraph/router")
3334

3435
memProfilePath = flag.String("memprofile", "", "Path to write memory profile. Memory is a snapshot taken at the time the program exits")
3536
cpuProfilePath = flag.String("cpuprofile", "", "Path to write cpu profile. CPU is measured from when the program starts until the program exits")
@@ -90,9 +91,14 @@ func Main() {
9091

9192
logLevelAtomic := zap.NewAtomicLevelAt(result.Config.LogLevel)
9293

94+
serviceName := *logServiceName
95+
if serviceName == "" {
96+
serviceName = "@wundergraph/router"
97+
}
98+
9399
baseLogger := logging.New(!result.Config.JSONLog, result.Config.DevelopmentMode, result.Config.AccessLogs.AddStacktrace, logLevelAtomic).
94100
With(
95-
zap.String("service", "@wundergraph/router"),
101+
zap.String("service", serviceName),
96102
zap.String("service_version", core.Version),
97103
)
98104

0 commit comments

Comments
 (0)