diff --git a/cmd/collector/app/metrics.go b/cmd/collector/app/metrics.go index b3482fadb97..3b725385aad 100644 --- a/cmd/collector/app/metrics.go +++ b/cmd/collector/app/metrics.go @@ -41,11 +41,11 @@ type SpanProcessorMetrics struct { //TODO - initialize metrics in the traditiona QueueLength metrics.Gauge // ErrorBusy counts number of return ErrServerBusy ErrorBusy metrics.Counter - // SavedBySvc contains span and trace counts by service - SavedBySvc metricsBySvc // spans actually saved - SaveFailedBySvc metricsBySvc // spans failed to save - serviceNames metrics.Gauge // total number of unique service name metrics reported by this collector - spanCounts map[string]CountsBySpanType + // SavedOkBySvc contains span and trace counts by service + SavedOkBySvc metricsBySvc // spans actually saved + SavedErrBySvc metricsBySvc // spans failed to save + serviceNames metrics.Gauge // total number of unique service name metrics reported by this collector + spanCounts map[string]CountsBySpanType } type countsBySvc struct { @@ -81,16 +81,16 @@ func NewSpanProcessorMetrics(serviceMetrics metrics.Factory, hostMetrics metrics spanCounts[otherFormatType] = newCountsBySpanType(serviceMetrics.Namespace("", map[string]string{"format": otherFormatType})) } m := &SpanProcessorMetrics{ - SaveLatency: hostMetrics.Timer("save-latency", nil), - InQueueLatency: hostMetrics.Timer("in-queue-latency", nil), - SpansDropped: hostMetrics.Counter("spans.dropped", nil), - BatchSize: hostMetrics.Gauge("batch-size", nil), - QueueLength: hostMetrics.Gauge("queue-length", nil), - ErrorBusy: hostMetrics.Counter("error.busy", nil), - SavedBySvc: newMetricsBySvc(serviceMetrics, "saved-by-svc"), - SaveFailedBySvc: newMetricsBySvc(serviceMetrics, "save-failed-by-svc"), - spanCounts: spanCounts, - serviceNames: hostMetrics.Gauge("spans.serviceNames", nil), + SaveLatency: hostMetrics.Timer("save-latency", nil), + InQueueLatency: hostMetrics.Timer("in-queue-latency", nil), + SpansDropped: hostMetrics.Counter("spans.dropped", nil), + BatchSize: hostMetrics.Gauge("batch-size", nil), + QueueLength: hostMetrics.Gauge("queue-length", nil), + ErrorBusy: hostMetrics.Counter("error.busy", nil), + SavedOkBySvc: newMetricsBySvc(serviceMetrics.Namespace("", map[string]string{"result": "ok"}), "saved-by-svc"), + SavedErrBySvc: newMetricsBySvc(serviceMetrics.Namespace("", map[string]string{"result": "err"}), "saved-by-svc"), + spanCounts: spanCounts, + serviceNames: hostMetrics.Gauge("spans.serviceNames", nil), } return m diff --git a/cmd/collector/app/span_processor.go b/cmd/collector/app/span_processor.go index b560d6357e9..faf59b04060 100644 --- a/cmd/collector/app/span_processor.go +++ b/cmd/collector/app/span_processor.go @@ -100,11 +100,11 @@ func (sp *spanProcessor) saveSpan(span *model.Span) { startTime := time.Now() if err := sp.spanWriter.WriteSpan(span); err != nil { sp.logger.Error("Failed to save span", zap.Error(err)) - sp.metrics.SaveFailedBySvc.ReportServiceNameForSpan(span) + sp.metrics.SavedErrBySvc.ReportServiceNameForSpan(span) } else { sp.logger.Debug("Span written to the storage by the collector", zap.Stringer("trace-id", span.TraceID), zap.Stringer("span-id", span.SpanID)) - sp.metrics.SavedBySvc.ReportServiceNameForSpan(span) + sp.metrics.SavedOkBySvc.ReportServiceNameForSpan(span) } sp.metrics.SaveLatency.Record(time.Since(startTime)) } diff --git a/cmd/collector/app/span_processor_test.go b/cmd/collector/app/span_processor_test.go index 099069d88ba..d1700f27f4d 100644 --- a/cmd/collector/app/span_processor_test.go +++ b/cmd/collector/app/span_processor_test.go @@ -255,7 +255,7 @@ func TestSpanProcessorErrors(t *testing.T) { }, logBuf.JSONLine(0)) expected := []metricsTest.ExpectedMetric{{ - Name: "service.spans.save-failed-by-svc|debug=false|svc=x", Value: 1, + Name: "service.spans.saved-by-svc|debug=false|result=err|svc=x", Value: 1, }} metricsTest.AssertCounterMetrics(t, mb, expected...) }