Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Print error on Sampler Query failure #328

Merged
merged 1 commit into from
Sep 3, 2018
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions sampler.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ func (s *RemotelyControlledSampler) updateSampler() {
res, err := s.manager.GetSamplingStrategy(s.serviceName)
if err != nil {
s.metrics.SamplerQueryFailure.Inc(1)
s.logger.Infof("Unable to query sampling strategy: %v", err)
return
}
s.Lock()
Expand Down
13 changes: 13 additions & 0 deletions sampler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"errors"
"fmt"
"runtime"
"strings"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -649,6 +650,18 @@ func getSamplingStrategyResponse(strategyType sampling.SamplingStrategyType, val
return nil
}

func TestRemotelyControlledSampler_printErrorForBrokenUpstream(t *testing.T) {
logger := &log.BytesBufferLogger{}
sampler := NewRemotelyControlledSampler(
"client app",
SamplerOptions.Logger(logger),
)
sampler.Close() // stop timer-based updates, we want to call them manually
sampler.updateSampler()

assert.True(t, strings.Contains(logger.String(), "Unable to query sampling strategy:"))
}

func TestAdaptiveSampler_lockRaceCondition(t *testing.T) {
agent, remoteSampler, _ := initAgent(t)
defer agent.Close()
Expand Down