instana / instana-java-opentracing

Instana Java OpenTracing
MIT License
20 stars 6 forks source link

Please update docs/examples to current major release on website. #5

Open JRW2252 opened 5 years ago

JRW2252 commented 5 years ago

The code on the public facing site doesn't compile with current release version. Please either update the examples on the site so it compiles with v0.33.0, or please annotate that all the examples provided will only compile/work with ~v0.31.0. The most recent major release breaks nearly all examples on the site. 👎

public static Scope startServerSpan(Tracer tracer, javax.ws.rs.core.HttpHeaders httpHeaders,
        String operationName) {
    // format the headers for extraction
    MultivaluedMap<String, String> rawHeaders = httpHeaders.getRequestHeaders();
    final HashMap<String, String> headers = new HashMap<String, String>();
    for (String key : rawHeaders.keySet()) {
        headers.put(key, rawHeaders.get(key).get(0));
    }

    Tracer.SpanBuilder spanBuilder;
    try {
        // this doesn't compile w 0.32.0 + 
        SpanContext parentSpan = tracer.extract(Format.Builtin.HTTP_HEADERS, new TextMapExtractAdapter(headers));
        if (parentSpan == null) {
            spanBuilder = tracer.buildSpan(operationName);
        } else {
            spanBuilder = tracer.buildSpan(operationName).asChildOf(parentSpan);
        }
    } catch (IllegalArgumentException e) {
        spanBuilder = tracer.buildSpan(operationName);
    }
    // this doesn't compile w 0.32.0 + 
    return spanBuilder.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER).startActive(true);
CodingFabian commented 5 years ago

Thanks for letting us know @JRW2252 - unfortunately open tracing releases do that with every minor release. We will update the examples and also mention the version.

CodingFabian commented 5 years ago

Support for version 0.32 and 0.33 has been released. Needs Java Trace Sensor 1.2.304 on the Instana Agent side