From dbafe64bdc62f6a76523f992443b5b04797ed579 Mon Sep 17 00:00:00 2001 From: Goutham Veeramachaneni Date: Wed, 29 Aug 2018 22:59:12 +0530 Subject: [PATCH] Print error on Sampler Query failure Signed-off-by: Goutham Veeramachaneni --- sampler.go | 1 + sampler_test.go | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/sampler.go b/sampler.go index e6a32b38..3e163095 100644 --- a/sampler.go +++ b/sampler.go @@ -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() diff --git a/sampler_test.go b/sampler_test.go index 3faea035..cf33ee84 100644 --- a/sampler_test.go +++ b/sampler_test.go @@ -18,6 +18,7 @@ import ( "errors" "fmt" "runtime" + "strings" "sync" "testing" "time" @@ -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()