Skip to content

Commit

Permalink
fix(deps): change opentelemetry-semconv from alpha to release candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
JoergSiebahn committed Feb 17, 2025
1 parent 124aaf5 commit d3c4fec
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sda-commons-client-jersey/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
exclude group: "io.opentelemetry.instrumentation", module: "opentelemetry-instrumentation-api"
exclude group: "io.opentelemetry", module: "opentelemetry-api-incubator"
}
api 'io.opentelemetry:opentelemetry-semconv'
api 'io.opentelemetry.semconv:opentelemetry-semconv'

implementation 'io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-apache-httpclient-5.0'
implementation 'io.opentelemetry.instrumentation:opentelemetry-apache-httpclient-5.2'
Expand Down
2 changes: 1 addition & 1 deletion sda-commons-dependencies/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ dependencies {
// sda-commons-server-opentelemetry
api "io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-apache-httpclient-5.0:${openTelemetryAlpha2Version}"
api "io.opentelemetry.instrumentation:opentelemetry-apache-httpclient-5.2:${openTelemetryAlpha2Version}"
api "io.opentelemetry:opentelemetry-semconv:1.30.1-alpha"
api "io.opentelemetry.semconv:opentelemetry-semconv:1.30.0-rc.1"
api "io.opentelemetry.instrumentation:opentelemetry-instrumentation-api:2.13.0"
api "io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-semconv:1.33.6-alpha"
api "com.squareup.okhttp3:okhttp:4.12.0" // bump from 4.9.3 used in opentelemetry-exporter-otlp-common
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.opentelemetry.api.trace.StatusCode;
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.context.Scope;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.ExceptionAttributes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
Expand Down Expand Up @@ -148,7 +148,7 @@ private void tagException(Span span, Exception ex) {
// https://github.com/open-telemetry/opentelemetry-specification/tree/v1.23.0/specification/trace/semantic_conventions

span.setStatus(StatusCode.ERROR, "Something bad happened!");
span.setAttribute(SemanticAttributes.EXCEPTION_EVENT_NAME, "error");
span.setAttribute(ExceptionAttributes.EXCEPTION_TYPE, "error");
span.recordException(ex);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ void shouldGetInstrumented() {
"someWork",
"instrumentedWork",
"GET /instrumented"));

;
}

@Test
Expand Down Expand Up @@ -82,7 +80,6 @@ void shouldDoException() {
.extracting(SpanData::getStatus)
.extracting(StatusData::getStatusCode, StatusData::getDescription)
.contains(Tuple.tuple(StatusCode.ERROR, "Something bad happened!")));
;
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion sda-commons-server-opentelemetry/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies {
exclude group: "io.opentelemetry.instrumentation", module: "opentelemetry-instrumentation-api"
exclude group: "io.opentelemetry", module: "opentelemetry-api-incubator"
}
api 'io.opentelemetry:opentelemetry-semconv'
api 'io.opentelemetry.semconv:opentelemetry-semconv'

// Provides support for jaeger baggage
api 'io.opentelemetry:opentelemetry-extension-trace-propagators'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.sdase.commons.server.opentelemetry.decorators;

import io.opentelemetry.api.trace.Span;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.ws.rs.container.ContainerRequestContext;
Expand All @@ -22,16 +24,16 @@ public static void decorateRequest(ContainerRequestContext requestContext, Span
Objects.requireNonNull(new JerseySpanNameProvider().get(requestContext.getRequest()));
updateSpanName(requestContext.getMethod(), route, span);
// Add the attributes defined in the Semantic Conventions
span.setAttribute(SemanticAttributes.HTTP_ROUTE, route);
span.setAttribute(HttpAttributes.HTTP_ROUTE, route);
}

public static void decorateRequest(HttpServletRequest request, Span span) {
span.setAttribute(SemanticAttributes.HTTP_REQUEST_METHOD, request.getMethod());
span.setAttribute(SemanticAttributes.URL_SCHEME, request.getScheme());
span.setAttribute(HttpAttributes.HTTP_REQUEST_METHOD, request.getMethod());
span.setAttribute(UrlAttributes.URL_SCHEME, request.getScheme());
span.setAttribute(
SemanticAttributes.SERVER_ADDRESS,
ServerAttributes.SERVER_ADDRESS,
String.format("%s:%s", request.getRemoteHost(), request.getServerPort()));
span.setAttribute(SemanticAttributes.URL_FULL, request.getRequestURI());
span.setAttribute(UrlAttributes.URL_FULL, request.getRequestURI());
}

public static void decorateResponse(ContainerResponseContext responseContext, Span span) {
Expand All @@ -41,7 +43,7 @@ public static void decorateResponse(ContainerResponseContext responseContext, Sp
}

public static void decorateResponse(HttpServletResponse response, Span span) {
span.setAttribute(SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, response.getStatus());
span.setAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, response.getStatus());
}

private static void updateSpanName(String method, String route, Span span) {
Expand Down

0 comments on commit d3c4fec

Please sign in to comment.