From 903aa17ffb10f0879baae013d200032d6cf90e7f Mon Sep 17 00:00:00 2001 From: Ryan Martin Date: Mon, 21 Oct 2024 17:25:26 +0700 Subject: [PATCH 1/6] fix: jaeger traces not persisted across container restarts --- .gitignore | 2 +- common/docker/service/jaeger.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index be28b41..87d60f2 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,4 @@ dist/ /starter-game # Built binary -world +./world diff --git a/common/docker/service/jaeger.go b/common/docker/service/jaeger.go index 4224f2d..94a19b3 100644 --- a/common/docker/service/jaeger.go +++ b/common/docker/service/jaeger.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/mount" "pkg.world.dev/world-cli/common/config" ) @@ -19,10 +20,21 @@ func Jaeger(cfg *config.Config) Service { Name: getJaegerContainerName(cfg), Config: container.Config{ Image: "jaegertracing/all-in-one:1.61.0", + // hard-coding this since it won't change much and the defaults work. users most likely + // won't need to change these. note that this storage configuration isn't recommended to + // be used for production environment, but is good enough for local development. + // for more info see: https://www.jaegertracing.io/docs/1.62/deployment/#span-storage-backends + Env: []string{ + "SPAN_STORAGE_TYPE=badger", + "BADGER_EPHEMERAL=false", + "BADGER_DIRECTORY_VALUE=/badger/data", + "BADGER_DIRECTORY_KEY=/badger/key", + }, }, HostConfig: container.HostConfig{ PortBindings: newPortMap(exposedPorts), NetworkMode: container.NetworkMode(cfg.DockerEnv["CARDINAL_NAMESPACE"]), + Mounts: []mount.Mount{{Type: mount.TypeVolume, Source: cfg.DockerEnv["CARDINAL_NAMESPACE"], Target: "/badger"}}, }, } } From 4a3dcb3995b4ba7d0c52d71e61c5ae9ec1435bbe Mon Sep 17 00:00:00 2001 From: Ryan Martin Date: Mon, 21 Oct 2024 17:42:48 +0700 Subject: [PATCH 2/6] fix: line too long --- common/docker/service/jaeger.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/docker/service/jaeger.go b/common/docker/service/jaeger.go index 94a19b3..ac42377 100644 --- a/common/docker/service/jaeger.go +++ b/common/docker/service/jaeger.go @@ -34,7 +34,8 @@ func Jaeger(cfg *config.Config) Service { HostConfig: container.HostConfig{ PortBindings: newPortMap(exposedPorts), NetworkMode: container.NetworkMode(cfg.DockerEnv["CARDINAL_NAMESPACE"]), - Mounts: []mount.Mount{{Type: mount.TypeVolume, Source: cfg.DockerEnv["CARDINAL_NAMESPACE"], Target: "/badger"}}, + Mounts: []mount.Mount{{Type: mount.TypeVolume, + Source: cfg.DockerEnv["CARDINAL_NAMESPACE"], Target: "/badger"}}, }, } } From 333902f71c12af3cd91a14a405b4548be0cc1a88 Mon Sep 17 00:00:00 2001 From: Ryan Martin Date: Tue, 22 Oct 2024 20:22:06 +0700 Subject: [PATCH 3/6] feat: add cors headers to jaeger --- common/docker/service/jaeger.go | 1 + 1 file changed, 1 insertion(+) diff --git a/common/docker/service/jaeger.go b/common/docker/service/jaeger.go index ac42377..ef72217 100644 --- a/common/docker/service/jaeger.go +++ b/common/docker/service/jaeger.go @@ -29,6 +29,7 @@ func Jaeger(cfg *config.Config) Service { "BADGER_EPHEMERAL=false", "BADGER_DIRECTORY_VALUE=/badger/data", "BADGER_DIRECTORY_KEY=/badger/key", + "QUERY_ADDITIONAL_HEADERS=Access-Control-Allow-Origin:*", }, }, HostConfig: container.HostConfig{ From 238e71026597c6ce9239f2cced1460e98bd211e5 Mon Sep 17 00:00:00 2001 From: Ryan Martin Date: Fri, 25 Oct 2024 15:21:39 +0700 Subject: [PATCH 4/6] refactor: make trace and metrics enabled by default --- common/docker/service/nakama.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/docker/service/nakama.go b/common/docker/service/nakama.go index 0372ca2..3fb60c4 100644 --- a/common/docker/service/nakama.go +++ b/common/docker/service/nakama.go @@ -37,7 +37,7 @@ func Nakama(cfg *config.Config) Service { traceEnabled := cfg.DockerEnv["NAKAMA_TRACE_ENABLED"] if traceEnabled == "" || !cfg.Telemetry { - traceEnabled = "false" + traceEnabled = "true" } traceSampleRate := cfg.DockerEnv["NAKAMA_TRACE_SAMPLE_RATE"] @@ -45,7 +45,7 @@ func Nakama(cfg *config.Config) Service { traceSampleRate = "0.6" } - metricsEnabled := false + metricsEnabled := true if cfg.Telemetry { cfgMetricsEnabled, err := strconv.ParseBool(cfg.DockerEnv["NAKAMA_METRICS_ENABLED"]) if err == nil { From 40cd9ce541855d7b42fc36ee475256d642eba9c4 Mon Sep 17 00:00:00 2001 From: Ryan Martin Date: Fri, 25 Oct 2024 15:26:10 +0700 Subject: [PATCH 5/6] chore: remove (now) unused nolint comment --- common/docker/service/evm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/docker/service/evm.go b/common/docker/service/evm.go index 391b220..a22016f 100644 --- a/common/docker/service/evm.go +++ b/common/docker/service/evm.go @@ -28,7 +28,7 @@ func EVM(cfg *config.Config) Service { faucetEnabled := cfg.DockerEnv["FAUCET_ENABLED"] if faucetEnabled == "" { - faucetEnabled = "false" //nolint:goconst // default values should be local to the service + faucetEnabled = "false" } faucetAddress := cfg.DockerEnv["FAUCET_ADDRESS"] From 8f1523400d7112561ffda3f78634e130db36a56f Mon Sep 17 00:00:00 2001 From: Ryan Martin Date: Fri, 25 Oct 2024 23:37:46 +0700 Subject: [PATCH 6/6] fix: broken jaeger container in some systems --- common/docker/service/jaeger.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/docker/service/jaeger.go b/common/docker/service/jaeger.go index ef72217..b7a7b83 100644 --- a/common/docker/service/jaeger.go +++ b/common/docker/service/jaeger.go @@ -31,6 +31,13 @@ func Jaeger(cfg *config.Config) Service { "BADGER_DIRECTORY_KEY=/badger/key", "QUERY_ADDITIONAL_HEADERS=Access-Control-Allow-Origin:*", }, + // running as the default user (uid 10001) doesn't work on mac because the volume is owned by + // root. A way to get around this is to create another container to change the owner of the + // /badger directory. since we're not able to start services following a dependency graph yet, + // we'll just run as root. world cli is also mainly used for local dev, so the security + // benefits of running as non-root doesn't really apply here. + // src: https://github.com/jaegertracing/jaeger/issues/4906 + User: "root", }, HostConfig: container.HostConfig{ PortBindings: newPortMap(exposedPorts),