Skip to content
Draft
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
16 changes: 11 additions & 5 deletions router/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ import (
)

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

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

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

serviceName := *logServiceName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead off having this as a flag, it would be more useful to support it in the config file. For this, you need to update

type Config struct {

There you can also enforce the default, make it available as ENV + make it required.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it make sense, ty, let me do it :)

if serviceName == "" {
serviceName = "@wundergraph/router"
}

baseLogger := logging.New(!result.Config.JSONLog, result.Config.DevelopmentMode, result.Config.AccessLogs.AddStacktrace, logLevelAtomic).
With(
zap.String("service", "@wundergraph/router"),
zap.String("service", serviceName),
zap.String("service_version", core.Version),
)

Expand Down