Add instance-global tags to traces
@@ -474,6 +474,8 @@ func (s *Server) flushTraces(ctx context.Context) {
span, _ := trace.StartSpanFromContext(ctx, "")
defer span.Finish()
+ tags := s.traceTags(span.Attach(ctx))
+
traceRing := s.TraceWorker.Flush()
ssfSpans := make([]ssf.SSFSpan, 0, traceRing.Len())
@@ -500,6 +502,10 @@ func (s *Server) flushTraces(ctx context.Context) {
s.Statsd.Incr("worker.trace.sink.timestamp_error", []string{timeErr}, 1)
}
+ // this will overwrite tags already present on the span
+ for _, tag := range tags {
+ ssfSpan.Tags[tag[0]] = tag[1]
+ }
ssfSpans = append(ssfSpans, ssfSpan)
}
})
@@ -680,6 +686,19 @@ func postHelper(ctx context.Context, httpClient *http.Client, stats *statsd.Clie
return nil
}
+func (s *Server) traceTags(ctx context.Context) [][2]string {
+ tags := make([][2]string, len(s.Tags))
+ for i, tag := range s.Tags {
+ splt := strings.SplitN(tag, ":", 2)
+ if len(splt) < 2 {
+ tags[i] = [2]string{tag, ""}
+ continue
+ }
+ tags[i] = [2]string{splt[0], splt[1]}
+ }
+ return tags
+}
+
// TODO better name, also finalize type signature
type traceFlusher func(context.Context, *Server, opentracing.Tracer, []ssf.SSFSpan)
