Skip to content

Commit

Permalink
Emit metric to count unique traces (root spans) (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChimeraCoder committed Oct 29, 2018
1 parent f77a9da commit 9ccc474
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions flusher.go
Expand Up @@ -434,7 +434,9 @@ func (s *Server) flushTraces(ctx context.Context) {
}

spansReceivedTotal := atomic.SwapInt64(&value.ssfSpansReceivedTotal, 0)
spansRootReceivedTotal := atomic.SwapInt64(&value.ssfRootSpansReceivedTotal, 0)
s.Statsd.Count("ssf.spans.received_total", spansReceivedTotal, tags, 1.0)
s.Statsd.Count("ssf.spans.root.received_total", spansRootReceivedTotal, append(tags, "veneurglobalonly:true"), 1.0)
return true
})

Expand Down
7 changes: 6 additions & 1 deletion server.go
Expand Up @@ -142,7 +142,8 @@ type Server struct {
// It is expected the values on the struct will only be handled
// using atomic operations
type ssfServiceSpanMetrics struct {
ssfSpansReceivedTotal int64
ssfSpansReceivedTotal int64
ssfRootSpansReceivedTotal int64
}

// SetLogger sets the default logger in veneur to the passed value.
Expand Down Expand Up @@ -834,6 +835,10 @@ func (s *Server) handleSSF(span *ssf.SSFSpan, ssfFormat string) {

atomic.AddInt64(&metricsStruct.ssfSpansReceivedTotal, 1)

if span.Id == span.TraceId {
atomic.AddInt64(&metricsStruct.ssfRootSpansReceivedTotal, 1)
}

s.SpanChan <- span
}

Expand Down

0 comments on commit 9ccc474

Please sign in to comment.