mirror of
https://github.com/jlengrand/helidon.git
synced 2026-03-10 08:21:17 +00:00
Upgrade tracing libraries (#1230)
* Upgrade of libraries related to tracing. (#1169) Signed-off-by: Tomas Langer <tomas.langer@oracle.com> * Upgrades OpenTracing version, Jaeger and Zipkin tracers and fixed backward incompatible calls. Signed-off-by: Tomas Langer <tomas.langer@oracle.com> * Upgrade to latest Zipkin sender. Signed-off-by: Tomas Langer <tomas.langer@oracle.com> * Updated CHANGELOG.md Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
This commit is contained in:
10
CHANGELOG.md
10
CHANGELOG.md
@@ -9,6 +9,16 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
### Backward incompatible changes
|
||||
#### Common
|
||||
- Flow API is now used from `java.util.concurrent.Flow`, Helidon specific `Flow` class is now removed
|
||||
#### Tracing
|
||||
- We have upgraded to OpenTracing version 0.33.0 that is not backward compatible, the following breaking changes exist
|
||||
(these are OpenTracing changes, not Helidon changes):
|
||||
1. `TextMapExtractAdapter` and `TextMapInjectAdapter` are now `TextMapAdapter`
|
||||
2. module name changed from `opentracing.api` to `io.opentracing.api` (same for `noop` and `util`)
|
||||
3. `SpanBuilder` no longer has `startActive` method, you need to use `Tracer.activateSpan(Span)`
|
||||
4. `ScopeManager.activate(Span, boolean)` is replaced by `ScopeManager.activate(Span)` - second parameter is now always
|
||||
`false`
|
||||
5. `Scope ScopeManager.active()` is removed - replaced by `Span Tracer.activeSpan()`
|
||||
- If you use the `TracerBuilder` abstraction in Helidon and have no custom Spans, there is no change required
|
||||
|
||||
## [1.4.0]
|
||||
|
||||
|
||||
10
dependencies/pom.xml
vendored
10
dependencies/pom.xml
vendored
@@ -39,7 +39,7 @@
|
||||
<version.lib.activation-api>1.2.0</version.lib.activation-api>
|
||||
<version.lib.annotation-api>1.3.1</version.lib.annotation-api>
|
||||
<version.lib.apache-httpclient>4.5.10</version.lib.apache-httpclient>
|
||||
<version.lib.brave-opentracing>0.31.0</version.lib.brave-opentracing>
|
||||
<version.lib.brave-opentracing>0.35.0</version.lib.brave-opentracing>
|
||||
<version.lib.cdi-api>2.0</version.lib.cdi-api>
|
||||
<version.lib.eclipselink>2.7.4</version.lib.eclipselink>
|
||||
<version.lib.el-api>3.0.0</version.lib.el-api>
|
||||
@@ -55,7 +55,7 @@
|
||||
<version.lib.hikaricp>2.7.8</version.lib.hikaricp>
|
||||
<version.lib.inject>1</version.lib.inject>
|
||||
<version.lib.jackson>2.10.0</version.lib.jackson>
|
||||
<version.lib.jaegertracing>0.34.0</version.lib.jaegertracing>
|
||||
<version.lib.jaegertracing>1.1.0</version.lib.jaegertracing>
|
||||
<version.lib.jakarta-persistence-api>2.2.2</version.lib.jakarta-persistence-api>
|
||||
<version.lib.jandex>2.1.1.Final</version.lib.jandex>
|
||||
<version.lib.jaxb-api>2.3.0</version.lib.jaxb-api>
|
||||
@@ -84,8 +84,8 @@
|
||||
<version.lib.netty>4.1.42.Final</version.lib.netty>
|
||||
<version.lib.oci-java-sdk-objectstorage>1.5.2</version.lib.oci-java-sdk-objectstorage>
|
||||
<version.lib.ojdbc8>19.3.0.0</version.lib.ojdbc8>
|
||||
<version.lib.opentracing>0.31.0</version.lib.opentracing>
|
||||
<version.lib.opentracing.grpc>0.0.12</version.lib.opentracing.grpc>
|
||||
<version.lib.opentracing>0.33.0</version.lib.opentracing>
|
||||
<version.lib.opentracing.grpc>0.2.1</version.lib.opentracing.grpc>
|
||||
<version.lib.persistence-api>2.2</version.lib.persistence-api>
|
||||
<version.lib.prometheus>0.6.0</version.lib.prometheus>
|
||||
<version.lib.protobuf.java>3.5.1</version.lib.protobuf.java>
|
||||
@@ -99,7 +99,7 @@
|
||||
<version.lib.ucp>19.3.0.0</version.lib.ucp>
|
||||
<version.lib.validation-api>2.0.1.Final</version.lib.validation-api>
|
||||
<version.lib.weld>3.1.1.Final</version.lib.weld>
|
||||
<version.lib.zipkin>2.6.0</version.lib.zipkin>
|
||||
<version.lib.zipkin>2.12.0</version.lib.zipkin>
|
||||
<version.lib.hystrix>1.5.18</version.lib.hystrix>
|
||||
<version.lib.failsafe>2.3.1</version.lib.failsafe>
|
||||
<version.lib.yasson>1.0.3</version.lib.yasson>
|
||||
|
||||
@@ -22,6 +22,6 @@ module io.helidon.grpc.client {
|
||||
|
||||
requires transitive io.helidon.grpc.core;
|
||||
|
||||
requires opentracing.api;
|
||||
requires io.opentracing.api;
|
||||
requires opentracing.grpc;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import io.opentracing.Tracer;
|
||||
import io.opentracing.contrib.grpc.OpenTracingContextKey;
|
||||
import io.opentracing.contrib.grpc.OperationNameConstructor;
|
||||
import io.opentracing.propagation.Format;
|
||||
import io.opentracing.propagation.TextMapExtractAdapter;
|
||||
import io.opentracing.propagation.TextMapAdapter;
|
||||
|
||||
/**
|
||||
* A {@link ServerInterceptor} that adds tracing to gRPC service calls.
|
||||
@@ -147,7 +147,7 @@ public class GrpcTracing
|
||||
|
||||
try {
|
||||
SpanContext parentSpanCtx = tracer.extract(Format.Builtin.HTTP_HEADERS,
|
||||
new TextMapExtractAdapter(headers));
|
||||
new TextMapAdapter(headers));
|
||||
if (parentSpanCtx == null) {
|
||||
span = tracer.buildSpan(operationName)
|
||||
.start();
|
||||
|
||||
@@ -30,7 +30,7 @@ module io.helidon.grpc.server {
|
||||
|
||||
requires transitive grpc.services;
|
||||
requires transitive microprofile.health.api;
|
||||
requires transitive opentracing.api;
|
||||
requires transitive io.opentracing.api;
|
||||
requires transitive opentracing.grpc;
|
||||
|
||||
requires java.annotation;
|
||||
|
||||
@@ -85,8 +85,9 @@ public class MpTracingInterceptor {
|
||||
|
||||
parentSpan.ifPresent(spanBuilder::asChildOf);
|
||||
|
||||
Scope scope = spanBuilder.startActive(false);
|
||||
Span span = scope.span();
|
||||
Span span = spanBuilder.start();
|
||||
Scope scope = tracer.scopeManager().activate(span);
|
||||
|
||||
try {
|
||||
return context.proceed();
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -23,7 +23,7 @@ module io.helidon.microprofile.tracing {
|
||||
|
||||
requires java.ws.rs;
|
||||
requires jersey.common;
|
||||
requires opentracing.api;
|
||||
requires io.opentracing.api;
|
||||
|
||||
requires static cdi.api;
|
||||
requires static javax.inject;
|
||||
|
||||
@@ -31,11 +31,11 @@ import io.opentracing.Span;
|
||||
import io.opentracing.SpanContext;
|
||||
import io.opentracing.Tracer;
|
||||
import io.opentracing.propagation.Format;
|
||||
import io.opentracing.propagation.TextMapInjectAdapter;
|
||||
import io.opentracing.propagation.TextMapAdapter;
|
||||
import io.opentracing.util.GlobalTracer;
|
||||
|
||||
/**
|
||||
* TODO javadoc.
|
||||
* Testing tracer provider.
|
||||
*/
|
||||
public class TestTracerProvider implements TracerProvider {
|
||||
@Override
|
||||
@@ -112,27 +112,24 @@ public class TestTracerProvider implements TracerProvider {
|
||||
public ScopeManager scopeManager() {
|
||||
return new ScopeManager() {
|
||||
private Scope active;
|
||||
private Span activeSpan;
|
||||
|
||||
@Override
|
||||
public Scope activate(Span span, boolean finishSpanOnClose) {
|
||||
public Scope activate(Span span) {
|
||||
active = new Scope() {
|
||||
@Override
|
||||
public void close() {
|
||||
if (finishSpanOnClose) {
|
||||
span.finish();
|
||||
}
|
||||
activeSpan = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Span span() {
|
||||
return span;
|
||||
}
|
||||
};
|
||||
activeSpan = span;
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scope active() {
|
||||
return active;
|
||||
public Span activeSpan() {
|
||||
return activeSpan;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -142,6 +139,16 @@ public class TestTracerProvider implements TracerProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scope activateSpan(Span span) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpanBuilder buildSpan(String operationName) {
|
||||
return new TestSpanBuilder(operationName);
|
||||
@@ -151,9 +158,9 @@ public class TestTracerProvider implements TracerProvider {
|
||||
|
||||
@Override
|
||||
public <C> void inject(SpanContext spanContext, Format<C> format, C carrier) {
|
||||
TestSpan span = ((TestSpanContext)spanContext).testSpan;
|
||||
TestSpan span = ((TestSpanContext) spanContext).testSpan;
|
||||
|
||||
TextMapInjectAdapter adapter = (TextMapInjectAdapter) carrier;
|
||||
TextMapAdapter adapter = (TextMapAdapter) carrier;
|
||||
adapter.put(OPERATION_NAME_HEADER, span.operationName);
|
||||
}
|
||||
|
||||
@@ -169,7 +176,6 @@ public class TestTracerProvider implements TracerProvider {
|
||||
|
||||
private SpanContext parent;
|
||||
|
||||
|
||||
public TestSpanBuilder(String operationName) {
|
||||
this.operationName = operationName;
|
||||
}
|
||||
@@ -219,26 +225,22 @@ public class TestTracerProvider implements TracerProvider {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scope startActive(boolean finishSpanOnClose) {
|
||||
return new TestScope((TestSpan) start());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Span startManual() {
|
||||
return start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Span start() {
|
||||
TestSpan result = new TestSpan(this);;
|
||||
TestSpan result = new TestSpan(this);
|
||||
;
|
||||
|
||||
if (null != parent) {
|
||||
((TestSpanContext)parent).testSpan.addChild(result);
|
||||
((TestSpanContext) parent).testSpan.addChild(result);
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Tracer.SpanBuilder withTag(io.opentracing.tag.Tag<T> tag, T value) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
static final class TestSpan implements Span {
|
||||
@@ -262,6 +264,11 @@ public class TestTracerProvider implements TracerProvider {
|
||||
return new TestSpanContext(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Span setTag(io.opentracing.tag.Tag<T> tag, T value) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Span setTag(String key, String value) {
|
||||
return this;
|
||||
@@ -336,22 +343,15 @@ public class TestTracerProvider implements TracerProvider {
|
||||
|
||||
return map.entrySet();
|
||||
}
|
||||
}
|
||||
|
||||
static class TestScope implements Scope {
|
||||
private final TestSpan testSpan;
|
||||
|
||||
TestScope(TestSpan testSpan) {
|
||||
this.testSpan = testSpan;
|
||||
@Override
|
||||
public String toTraceId() {
|
||||
return testSpan.parent.toTraceId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Span span() {
|
||||
return testSpan;
|
||||
public String toSpanId() {
|
||||
return testSpan.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,14 +27,14 @@ module io.helidon.security {
|
||||
requires transitive io.helidon.common.configurable;
|
||||
requires transitive io.helidon.common.reactive;
|
||||
requires transitive io.helidon.config;
|
||||
requires transitive opentracing.api;
|
||||
requires transitive io.opentracing.api;
|
||||
// noop and api expose the same package :(
|
||||
// requires opentracing.noop;
|
||||
requires opentracing.util;
|
||||
// requires io.opentracing.noop;
|
||||
requires io.opentracing.util;
|
||||
|
||||
requires io.helidon.security.util;
|
||||
requires io.helidon.common.context;
|
||||
requires opentracing.noop;
|
||||
requires io.opentracing.noop;
|
||||
|
||||
exports io.helidon.security;
|
||||
exports io.helidon.security.spi;
|
||||
|
||||
@@ -23,9 +23,10 @@ module io.helidon.tracing.jaeger {
|
||||
requires io.helidon.tracing;
|
||||
|
||||
requires java.logging;
|
||||
requires opentracing.util;
|
||||
requires io.opentracing.util;
|
||||
requires jaeger.client;
|
||||
requires jaeger.core;
|
||||
requires io.opentracing.noop;
|
||||
|
||||
exports io.helidon.tracing.jaeger;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ import io.opentracing.Span;
|
||||
import io.opentracing.SpanContext;
|
||||
import io.opentracing.Tracer;
|
||||
import io.opentracing.propagation.Format;
|
||||
import io.opentracing.propagation.TextMapInjectAdapter;
|
||||
import io.opentracing.propagation.TextMapAdapter;
|
||||
import io.opentracing.tag.Tags;
|
||||
import io.opentracing.util.GlobalTracer;
|
||||
|
||||
@@ -325,7 +325,7 @@ public class ClientTracingFilter implements ClientRequestFilter, ClientResponseF
|
||||
|
||||
tracer.inject(currentSpan.context(),
|
||||
Format.Builtin.HTTP_HEADERS,
|
||||
new TextMapInjectAdapter(tracerHeaders));
|
||||
new TextMapAdapter(tracerHeaders));
|
||||
|
||||
return new HashMap<>(tracerHeaders.entrySet()
|
||||
.stream()
|
||||
|
||||
@@ -28,8 +28,8 @@ module io.helidon.tracing.jersey.client {
|
||||
requires jersey.client;
|
||||
requires jersey.common;
|
||||
|
||||
requires opentracing.api;
|
||||
requires opentracing.util;
|
||||
requires io.opentracing.api;
|
||||
requires io.opentracing.util;
|
||||
|
||||
requires io.helidon.tracing;
|
||||
requires io.helidon.tracing.config;
|
||||
|
||||
@@ -83,7 +83,7 @@ public abstract class AbstractTracingFilter implements ContainerRequestFilter, C
|
||||
configureSpan(spanBuilder);
|
||||
|
||||
Span span = spanBuilder.start();
|
||||
Scope spanScope = tracer.scopeManager().activate(span, false);
|
||||
Scope spanScope = tracer.scopeManager().activate(span);
|
||||
|
||||
requestContext.setProperty(SPAN_PROPERTY, span);
|
||||
requestContext.setProperty(SPAN_SCOPE_PROPERTY, spanScope);
|
||||
|
||||
@@ -23,7 +23,7 @@ module io.helidon.tracing.jersey {
|
||||
|
||||
requires java.ws.rs;
|
||||
requires jersey.server;
|
||||
requires opentracing.api;
|
||||
requires io.opentracing.api;
|
||||
requires io.helidon.common;
|
||||
requires io.helidon.common.context;
|
||||
requires io.helidon.jersey.common;
|
||||
|
||||
@@ -23,9 +23,9 @@ module io.helidon.tracing {
|
||||
requires io.helidon.common;
|
||||
requires io.helidon.common.serviceloader;
|
||||
requires io.helidon.config;
|
||||
requires transitive opentracing.api;
|
||||
requires opentracing.noop;
|
||||
requires opentracing.util;
|
||||
requires transitive io.opentracing.api;
|
||||
requires io.opentracing.noop;
|
||||
requires io.opentracing.util;
|
||||
|
||||
exports io.helidon.tracing;
|
||||
exports io.helidon.tracing.spi;
|
||||
|
||||
@@ -32,17 +32,22 @@ class ZipkinScopeManager implements ScopeManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scope activate(Span span, boolean finishSpanOnClose) {
|
||||
Span toActivate = span;
|
||||
public Scope activate(Span span) {
|
||||
return scopeManager.activate(unwrap(span));
|
||||
}
|
||||
|
||||
private Span unwrap(Span span) {
|
||||
Span unwrapped = span;
|
||||
|
||||
if (span instanceof ZipkinSpan) {
|
||||
toActivate = ((ZipkinSpan) span).unwrap();
|
||||
unwrapped = ((ZipkinSpan) span).unwrap();
|
||||
}
|
||||
return scopeManager.activate(toActivate, finishSpanOnClose);
|
||||
|
||||
return unwrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scope active() {
|
||||
return scopeManager.active();
|
||||
public Span activeSpan() {
|
||||
return scopeManager.activeSpan();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Map;
|
||||
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.SpanContext;
|
||||
import io.opentracing.tag.Tag;
|
||||
|
||||
/**
|
||||
* The ZipkinSpan delegates to another {@link Span} while finishing the
|
||||
@@ -111,6 +112,12 @@ class ZipkinSpan implements Span {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Span setTag(Tag<T> tag, T value) {
|
||||
span.setTag(tag, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
Span unwrap() {
|
||||
return span;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,6 @@ import java.util.List;
|
||||
|
||||
import io.helidon.tracing.Tag;
|
||||
|
||||
import io.opentracing.Scope;
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.SpanContext;
|
||||
import io.opentracing.Tracer;
|
||||
@@ -99,12 +98,7 @@ class ZipkinSpanBuilder implements Tracer.SpanBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scope startActive(boolean finishSpanOnClose) {
|
||||
return spanBuilder.startActive(finishSpanOnClose);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Span startManual() {
|
||||
return null;
|
||||
public <T> Tracer.SpanBuilder withTag(io.opentracing.tag.Tag<T> tag, T value) {
|
||||
return spanBuilder.withTag(tag, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
import io.helidon.tracing.Tag;
|
||||
|
||||
import brave.opentracing.BraveTracer;
|
||||
import io.opentracing.Scope;
|
||||
import io.opentracing.ScopeManager;
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.SpanContext;
|
||||
@@ -77,4 +78,14 @@ public class ZipkinTracer implements Tracer {
|
||||
public Span activeSpan() {
|
||||
return tracer.activeSpan();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
tracer.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scope activateSpan(Span span) {
|
||||
return tracer.activateSpan(span);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,13 @@ module io.helidon.tracing.zipkin {
|
||||
requires io.helidon.tracing;
|
||||
|
||||
requires java.logging;
|
||||
requires opentracing.util;
|
||||
requires io.opentracing.util;
|
||||
requires brave.opentracing;
|
||||
requires zipkin2.reporter;
|
||||
requires zipkin2.reporter.urlconnection;
|
||||
requires zipkin2;
|
||||
requires brave;
|
||||
requires io.opentracing.noop;
|
||||
|
||||
exports io.helidon.tracing.zipkin;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ module io.helidon.webserver.jersey {
|
||||
requires transitive java.annotation;
|
||||
requires transitive io.helidon.webserver;
|
||||
requires transitive java.ws.rs;
|
||||
requires transitive opentracing.api;
|
||||
requires transitive io.opentracing.api;
|
||||
requires transitive io.helidon.jersey.server;
|
||||
|
||||
requires io.helidon.common.context;
|
||||
|
||||
@@ -36,7 +36,7 @@ import io.opentracing.SpanContext;
|
||||
import io.opentracing.Tracer;
|
||||
import io.opentracing.noop.NoopSpanBuilder;
|
||||
import io.opentracing.propagation.Format;
|
||||
import io.opentracing.propagation.TextMapExtractAdapter;
|
||||
import io.opentracing.propagation.TextMapAdapter;
|
||||
import io.opentracing.tag.Tags;
|
||||
import io.opentracing.util.GlobalTracer;
|
||||
|
||||
@@ -255,7 +255,7 @@ public abstract class WebTracingConfig {
|
||||
}
|
||||
}
|
||||
|
||||
SpanContext inboundSpanContext = tracer.extract(Format.Builtin.HTTP_HEADERS, new TextMapExtractAdapter(headersMap));
|
||||
SpanContext inboundSpanContext = tracer.extract(Format.Builtin.HTTP_HEADERS, new TextMapAdapter(headersMap));
|
||||
|
||||
if (inboundSpanContext instanceof NoopSpanBuilder) {
|
||||
// this is all a noop stuff, does not matter what I do here - this is to prevent null pointers
|
||||
|
||||
@@ -27,11 +27,11 @@ module io.helidon.webserver {
|
||||
requires transitive io.helidon.common.context;
|
||||
requires transitive io.helidon.config;
|
||||
requires transitive io.helidon.tracing.config;
|
||||
requires transitive opentracing.util;
|
||||
requires transitive io.opentracing.util;
|
||||
|
||||
requires java.logging;
|
||||
requires opentracing.api;
|
||||
requires opentracing.noop;
|
||||
requires io.opentracing.api;
|
||||
requires io.opentracing.noop;
|
||||
requires io.netty.handler;
|
||||
requires io.netty.codec.http;
|
||||
requires io.netty.codec;
|
||||
|
||||
Reference in New Issue
Block a user