brave icon indicating copy to clipboard operation
brave copied to clipboard

Resurrect "default tags" feature

Open codefromthecrypt opened this issue 8 years ago • 7 comments

The old Collector component in brave had the ability to set default tags. The use cases for this weren't foreground, and we deprecated it a while back with no-one noticing (or at least complaining).

There is a use case for "default tags", particularly for platform details like runtime information. For example, in https://github.com/openzipkin/zipkin-reporter-java/issues/33 docker and aws info were mentioned, hinting at a Platform Tags provider.

This is tricky to do at the current abstraction of zipkin-reporter for reasons including its interference with size information and even knowing the type of the span that's in use. Most importantly, zipkin-reporter has no idea what the local endpoint is, and this is a required parameter for tags (binary annotations). Hence, it is best to implement this here, at least for now.

codefromthecrypt avatar Feb 28 '17 04:02 codefromthecrypt

This is a necessary feature for us in the apps that are on plain brave, my work on opentracing has lead me toward creating a Tracer that applies our metadata to each span at creation time. I can gist that up if you'd like to see what that looked like.

devinsba avatar Feb 28 '17 16:02 devinsba

This is a necessary feature for us in the apps that are on plain brave, my work on opentracing has lead me toward creating a Tracer that applies our metadata to each span at creation time. I can gist that up if you'd like to see what that looked like.

Thanks. especially I'd like to see if you can get by with supplying KV, or if you need to defer resolution with some supplier function.

codefromthecrypt avatar Mar 01 '17 01:03 codefromthecrypt

anyone want to give this a try? Maybe Tracer.Builder.Tags?

codefromthecrypt avatar May 11 '17 03:05 codefromthecrypt

incidentally, this can be accomplished with https://github.com/openzipkin/brave/blob/master/brave/src/main/java/brave/handler/FinishedSpanHandler.java

codefromthecrypt avatar Nov 29 '18 22:11 codefromthecrypt

In https://github.com/openzipkin/brave/pull/801 show how to do this, especially only once per-hop:

/**
 * This shows how you can add a tag once per span as it enters a process. This is helpful for
 * environment details that are not request-specific, such as region.
 */
public class DefaultTagsTest {
  List<zipkin2.Span> spans = new ArrayList<>();
  Tracing tracing = Tracing.newBuilder()
      .addFinishedSpanHandler(new FinishedSpanHandler() {
        @Override public boolean handle(TraceContext context, MutableSpan span) {
          if (context.isLocalRoot()) {
            // pretend these are sourced from the environment
            span.tag("env", "prod");
            span.tag("region", "east");
          }
          return true;
        }
      })
--snip--

codefromthecrypt avatar Dec 11 '18 07:12 codefromthecrypt

Excellent Adrian, I'll be playing with this in our starter. I think this would work really nicely alongside the pattern soundcloud uses: https://developers.soundcloud.com/blog/using-kubernetes-pod-metadata-to-improve-zipkin-traces

I would recommend adding as little to the span as you can, and then extending it at collection time if you have that ability

devinsba avatar Dec 11 '18 15:12 devinsba

haven't implemented this yet, but will for 5.12 coming out soon, as we now have a template MutableSpan which is easy to add stuff to

codefromthecrypt avatar May 07 '20 00:05 codefromthecrypt