Fix OpenConcensus backend_matches_fetched metric (#829)

* Fix open concensus backend_matches_fetched metric

* Update
This commit is contained in:
yfei1
2019-09-30 18:10:23 -07:00
committed by GitHub
parent 3617d3cdbd
commit 8933255ec2
2 changed files with 5 additions and 6 deletions

View File

@ -99,7 +99,8 @@ func (s *backendService) FetchMatches(req *pb.FetchMatchesRequest, stream pb.Bac
case <-stream.Context().Done():
return stream.Context().Err()
default:
err := stream.Send(&pb.FetchMatchesResponse{Match: result})
err = stream.Send(&pb.FetchMatchesResponse{Match: result})
telemetry.IncrementCounter(stream.Context(), mMatchesFetched)
if err != nil {
logger.WithError(err).Error("failed to stream back the response")
return err
@ -107,7 +108,6 @@ func (s *backendService) FetchMatches(req *pb.FetchMatchesRequest, stream pb.Bac
}
}
telemetry.IncrementCounterN(stream.Context(), mMatchesFetched, len(results))
return nil
}

View File

@ -40,7 +40,7 @@ func SetGauge(ctx context.Context, s *stats.Int64Measure, n int, tags ...tag.Mut
// Counter creates a counter metric.
func Counter(name string, description string, tags ...tag.Key) *stats.Int64Measure {
s := stats.Int64(name, "Count of "+description+".", "1")
s := stats.Int64(name, "Count of "+description+".", stats.UnitDimensionless)
counterView(s, tags...)
return s
}
@ -52,11 +52,10 @@ func IncrementCounter(ctx context.Context, s *stats.Int64Measure, tags ...tag.Mu
// IncrementCounterN increases a metric by n.
func IncrementCounterN(ctx context.Context, s *stats.Int64Measure, n int, tags ...tag.Mutator) {
mCtx, err := tag.New(ctx, tags...)
if err != nil {
if err := stats.RecordWithTags(ctx, tags, s.M(int64(n))); err != nil {
logger.WithError(err).Infof("cannot record stat with tags %#v", tags)
return
}
stats.Record(mCtx, s.M(int64(n)))
}
// gaugeView converts the measurement into a view for a gauge metric.