Skip to content

Commit

Permalink
Update OpenTelemetry and resolve few deprecations (#81)
Browse files Browse the repository at this point in the history
* Update OpenTelemetry and resolve few deprecations

Signed-off-by: Lukas Kral <[email protected]>

* remove okhttp.version

Signed-off-by: Lukas Kral <[email protected]>

---------

Signed-off-by: Lukas Kral <[email protected]>
  • Loading branch information
im-konge authored Mar 6, 2024
1 parent b01aa48 commit d352593
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
4 changes: 0 additions & 4 deletions clients/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
15 changes: 6 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
<netty.version>4.1.72.Final</netty.version>
<maven-shade.version>3.2.1</maven-shade.version>
<kafka-kubernetes-config-provider.version>1.1.2</kafka-kubernetes-config-provider.version>
<jaeger.version>1.8.1</jaeger.version>
<opentelemetry.alpha-version>1.31.0-alpha</opentelemetry.alpha-version>
<opentelemetry.version>1.31.0</opentelemetry.version>

<opentelemetry.version>1.34.1</opentelemetry.version>
<opentelemetry.alpha-version>${opentelemetry.version}-alpha</opentelemetry.alpha-version>
<opentelemetry-semconv.version>1.21.0-alpha</opentelemetry-semconv.version>
<opentelemetry.instrumentation.version>1.32.0-alpha</opentelemetry.instrumentation.version>

<grpc.version>1.59.0</grpc.version>
<checkstyle.version>10.8.1</checkstyle.version>
<okhttp.version>4.10.0</okhttp.version>
<picocli.version>4.7.5</picocli.version>
<sl4j-nop.version>1.7.36</sl4j-nop.version>
</properties>
Expand Down Expand Up @@ -97,11 +99,6 @@
<artifactId>kafka-clients</artifactId>
<version>${kafka.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp.version}</version>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
Expand Down
14 changes: 10 additions & 4 deletions tracing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>io.jaegertracing</groupId>
<artifactId>jaeger-client</artifactId>
<version>${jaeger.version}</version>
<groupId>io.opentelemetry.semconv</groupId>
<artifactId>opentelemetry-semconv</artifactId>
<version>${opentelemetry-semconv.version}</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
Expand All @@ -46,13 +46,19 @@
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-kafka-clients-2.6</artifactId>
<version>${opentelemetry.alpha-version}</version>
<version>${opentelemetry.instrumentation.version}</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
<version>${opentelemetry.version}</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-sender-jdk</artifactId>
<version>${opentelemetry.alpha-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public String getServiceName() {
public void initialize() {
// disable metrics
System.setProperty("otel.metrics.exporter", "none");
// disable otel logs exporter
System.setProperty("otel.logs.exporter", "none");
AutoConfiguredOpenTelemetrySdk.initialize();
}

Expand Down Expand Up @@ -93,8 +95,8 @@ private static TextMapPropagator propagator() {
public HttpRequest build(HttpContext context) {
SpanBuilder spanBuilder = get().spanBuilder(operationName);
spanBuilder.setSpanKind(SpanKind.CLIENT);
spanBuilder.setAttribute(SemanticAttributes.HTTP_METHOD, context.getRecord() == null ? "GET" : "POST");
spanBuilder.setAttribute(SemanticAttributes.HTTP_URL, context.getUri());
spanBuilder.setAttribute(SemanticAttributes.HTTP_REQUEST_METHOD, context.getRecord() == null ? "GET" : "POST");
spanBuilder.setAttribute(SemanticAttributes.URL_FULL, context.getUri());
span = spanBuilder.startSpan();
HttpRequest.Builder builder = builder(context);
try (Scope ignored = span.makeCurrent()) {
Expand All @@ -107,7 +109,7 @@ public HttpRequest build(HttpContext context) {
public HttpResponse<T> finish(HttpResponse<T> response) {
try (Scope ignored = span.makeCurrent()) {
int code = response.statusCode();
span.setAttribute(SemanticAttributes.HTTP_STATUS_CODE, code);
span.setAttribute(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, code);
span.setStatus(code == 200 ? StatusCode.OK : StatusCode.ERROR);
} finally {
span.end();
Expand Down

0 comments on commit d352593

Please sign in to comment.