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

Commit

Permalink
Print error on Sampler Query failure (#328)
Browse files Browse the repository at this point in the history
Signed-off-by: Goutham Veeramachaneni <[email protected]>
  • Loading branch information
gouthamve authored and yurishkuro committed Sep 3, 2018
1 parent 252d853 commit 24c9ca5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
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

0 comments on commit 24c9ca5

Please sign in to comment.