Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[extension/jaegerremotesampling] fix: wait for autoUpdateStrategies in Close function #37289

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"net/url"
"os"
"path/filepath"
"sync"
"sync/atomic"
"time"

Expand All @@ -34,6 +35,8 @@ type samplingProvider struct {
cancelFunc context.CancelFunc

options Options

wg sync.WaitGroup
}

type storedStrategies struct {
Expand Down Expand Up @@ -96,6 +99,7 @@ func (h *samplingProvider) GetSamplingStrategy(_ context.Context, serviceName st
// Close stops updating the strategies
func (h *samplingProvider) Close() error {
h.cancelFunc()
h.wg.Wait()
return nil
}

Expand Down Expand Up @@ -156,6 +160,9 @@ func (h *samplingProvider) samplingStrategyLoader(strategiesFile string) strateg
}

func (h *samplingProvider) autoUpdateStrategies(ctx context.Context, interval time.Duration, loader strategyLoader) {
h.wg.Add(1)
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
defer h.wg.Done()

lastValue := string(nullJSON)
ticker := time.NewTicker(interval)
defer ticker.Stop()
Expand Down
Loading