Skip to content

Commit

Permalink
fix: jaeger traces not persisted across container restarts (#82)
Browse files Browse the repository at this point in the history
Closes: WORLD-1208

## Overview

Previously the Jaeger container only stores the spans in memory, which
is lost when the container is restarted. This PR fixes this by
[configuring Jaeger to use
Badger](https://www.jaegertracing.io/docs/1.62/deployment/#span-storage-backends)
as the span storage engine with a Docker volume.

## Brief Changelog

- Updated the Jaeger container config to use badger

## Testing and Verifying

Manually tested and verified.

---------

Co-authored-by: Ryan Martin <[email protected]>
  • Loading branch information
rmrt1n and rmrt1n authored Oct 25, 2024
1 parent 84f5fb5 commit 6abf03c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ dist/
/starter-game

# Built binary
world
./world
2 changes: 1 addition & 1 deletion common/docker/service/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
21 changes: 21 additions & 0 deletions common/docker/service/jaeger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -19,10 +20,30 @@ 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",
"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),
NetworkMode: container.NetworkMode(cfg.DockerEnv["CARDINAL_NAMESPACE"]),
Mounts: []mount.Mount{{Type: mount.TypeVolume,
Source: cfg.DockerEnv["CARDINAL_NAMESPACE"], Target: "/badger"}},
},
}
}
4 changes: 2 additions & 2 deletions common/docker/service/nakama.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ 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"]
if traceSampleRate == "" {
traceSampleRate = "0.6"
}

metricsEnabled := false
metricsEnabled := true
if cfg.Telemetry {
cfgMetricsEnabled, err := strconv.ParseBool(cfg.DockerEnv["NAKAMA_METRICS_ENABLED"])
if err == nil {
Expand Down

0 comments on commit 6abf03c

Please sign in to comment.