From 29c1ab55754d01502c3fcb7212beddabd9138132 Mon Sep 17 00:00:00 2001 From: yunmaoQu <2643354262@qq.com> Date: Fri, 13 Dec 2024 12:20:19 +0000 Subject: [PATCH] Fix: Remove hardcoded sampling-strategies.json dependency in Jaeger all-in-one binary Signed-off-by: yunmaoQu <2643354262@qq.com> --- cmd/jaeger/internal/all-in-one.yaml | 9 +++------ cmd/jaeger/main.go | 9 +++++++++ cmd/jaeger/sampling-strategies.json | 18 ------------------ 3 files changed, 12 insertions(+), 24 deletions(-) delete mode 100644 cmd/jaeger/sampling-strategies.json diff --git a/cmd/jaeger/internal/all-in-one.yaml b/cmd/jaeger/internal/all-in-one.yaml index 65a1d84e60c..8538463b6d8 100644 --- a/cmd/jaeger/internal/all-in-one.yaml +++ b/cmd/jaeger/internal/all-in-one.yaml @@ -28,12 +28,9 @@ extensions: max_traces: 100000 remote_sampling: - # We can either use file or adaptive sampling strategy in remote_sampling - file: - path: ./cmd/jaeger/sampling-strategies.json - # adaptive: - # sampling_store: some_store - # initial_sampling_probability: 0.1 + adaptive: + sampling_store: some_store + initial_sampling_probability: 0.1 http: endpoint: "${env:JAEGER_LISTEN_HOST:-localhost}:5778" grpc: diff --git a/cmd/jaeger/main.go b/cmd/jaeger/main.go index d63268845e7..fc7078824cf 100644 --- a/cmd/jaeger/main.go +++ b/cmd/jaeger/main.go @@ -5,6 +5,7 @@ package main import ( "log" + "os" "github.com/spf13/viper" @@ -24,6 +25,14 @@ func main() { command, ) + if err := command.Execute(); err != nil { + log.Fatal(err) + } + strategiesFile := "./cmd/jaeger/sampling-strategies.json" + if _, err := os.Stat(strategiesFile); os.IsNotExist(err) { + log.Printf("Warning: Sampling strategies file not found at %s. Running with default configuration.\n", strategiesFile) + } + if err := command.Execute(); err != nil { log.Fatal(err) } diff --git a/cmd/jaeger/sampling-strategies.json b/cmd/jaeger/sampling-strategies.json deleted file mode 100644 index c4645932d37..00000000000 --- a/cmd/jaeger/sampling-strategies.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "default_strategy": { - "type": "probabilistic", - "param": 1 - }, - "service_strategies": [ - { - "service": "foo", - "type": "probabilistic", - "param": 0.8 - }, - { - "service": "bar", - "type": "ratelimiting", - "param": 0.9 - } - ] -}