java-spring-cloud icon indicating copy to clipboard operation
java-spring-cloud copied to clipboard

Readme - document how to obtain the tracer

Open objectiser opened this issue 7 years ago • 5 comments
trafficstars

The readme currently shows how to configure, but not how a springboot app could obtain and use the tracer. Might be good to have a simple code snippet.

objectiser avatar Jan 10 '18 16:01 objectiser

I think this is clear for spring users. If you ask them to provide the bean, then it indicates to inject it when it is necessary.

pavolloffay avatar Jan 10 '18 16:01 pavolloffay

@pavolloffay I'm sorry to say that but this is not clear. Example to configure the jaeger or zipkin bean should be proposed such as this one with more detail about Configuration

Jaeger

    @Bean
    public Tracer jaegerTracer() {
        return new Configuration("spring-boot",
           new Configuration.SamplerConfiguration(ProbabilisticSampler.TYPE, 1),
           new Configuration.ReporterConfiguration(true,System.getenv("HOSTNAME"),null,null, null))
           .getTracer();
    }

As you can see, it is required too to pass System.getenv("HOSTNAME") otherwise Spring app where opentracing spring cloud is included will not be able to communicate with the agent

cmoulliard avatar Jan 10 '18 20:01 cmoulliard

I think Gary wants to document how to obtain the tracer bean and use it e.g.:

@Autowire
Tracer tracer;
....

public void foo() {
   Span s = tracer.buildSpan("name").start();
   // some code
   s.finish();
}

@cmoulliard there might be a lot of variations how you configure the tracer. I would rather see this section in jaeger java client repo. But I totally see your point as the tracer config is sometimes not trivial.

About the jaeger's binding to spring ecosystem we can create a separate project in snowdrop which would provide jaeger bean for this instrumentation with spring configuration capabilities. For example I would like to configure service name, sampling, reporter directly in spring yml.

pavolloffay avatar Jan 11 '18 09:01 pavolloffay

@pavolloffay I created the issue as @cmoulliard had asked about how to obtain the tracer. So depends whether he thinks this needs documenting? Otherwise can be closed.

objectiser avatar Jan 11 '18 09:01 objectiser

About the jaeger's binding to spring ecosystem we can create a separate project in snowdrop which would provide jaeger bean for this instrumentation

Ok for this proposition. If we do that than we can keep in a certain way the doc abstract here and add link to the projects where they can find how we have instrumented = implemented the Tracer (jaeger, Zipkin, ....)

cmoulliard avatar Jan 11 '18 14:01 cmoulliard