Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
### Fixes

- Use OpenTelemetry span name as fallback for transaction name ([#3557](https://github.com/getsentry/sentry-java/pull/3557))
- In certain cases we were sending transactions as "<unlabeled transaction>" when using OpenTelemetry
- In certain cases we were sending transactions as "<unlabeled transaction>" when using OpenTelemetry
- Add OpenTelemetry span data to Sentry span ([#3593](https://github.com/getsentry/sentry-java/pull/3593))
- No longer selectively copy OpenTelemetry attributes to Sentry spans / transactions `data` ([#3663](https://github.com/getsentry/sentry-java/pull/3663))
- Remove `PROCESS_COMMAND_ARGS` (`process.command_args`) OpenTelemetry span attribute as it can be very large ([#3664](https://github.com/getsentry/sentry-java/pull/3664))

### Dependencies

- Bump OpenTelemetry to 1.41.0, OpenTelemetry Java Agent to 2.7.0 and Semantic Conventions to 1.25.0 ([#3668](https://github.com/getsentry/sentry-java/pull/3668))

## 8.0.0-alpha.4

### Fixes
Expand Down
7 changes: 4 additions & 3 deletions buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,15 @@ object Config {
val apolloKotlin = "com.apollographql.apollo3:apollo-runtime:3.8.2"

object OpenTelemetry {
val otelVersion = "1.39.0"
val otelVersion = "1.41.0"
val otelAlphaVersion = "$otelVersion-alpha"
val otelJavaagentVersion = "2.5.0"
val otelJavaagentVersion = "2.7.0"
val otelJavaagentAlphaVersion = "$otelJavaagentVersion-alpha"
val otelSemanticConvetionsVersion = "1.23.1-alpha"
val otelSemanticConvetionsVersion = "1.25.0-alpha" // check https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/dependencyManagement/build.gradle.kts#L49 for release version above to find a compatible version

val otelSdk = "io.opentelemetry:opentelemetry-sdk:$otelVersion"
val otelSemconv = "io.opentelemetry.semconv:opentelemetry-semconv:$otelSemanticConvetionsVersion"
val otelSemconvIncubating = "io.opentelemetry.semconv:opentelemetry-semconv-incubating:$otelSemanticConvetionsVersion"
val otelJavaAgent = "io.opentelemetry.javaagent:opentelemetry-javaagent:$otelJavaagentVersion"
val otelJavaAgentExtensionApi = "io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api:$otelJavaagentAlphaVersion"
val otelJavaAgentTooling = "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling:$otelJavaagentAlphaVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencies {

testImplementation(Config.Libs.OpenTelemetry.otelSdk)
testImplementation(Config.Libs.OpenTelemetry.otelSemconv)
testImplementation(Config.Libs.OpenTelemetry.otelSemconvIncubating)
}

configure<SourceSetContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies {

implementation(Config.Libs.OpenTelemetry.otelSdk)
compileOnly(Config.Libs.OpenTelemetry.otelSemconv)
compileOnly(Config.Libs.OpenTelemetry.otelSemconvIncubating)

compileOnly(Config.CompileOnly.nopen)
errorprone(Config.CompileOnly.nopenChecker)
Expand All @@ -44,6 +45,7 @@ dependencies {

testImplementation(Config.Libs.OpenTelemetry.otelSdk)
testImplementation(Config.Libs.OpenTelemetry.otelSemconv)
testImplementation(Config.Libs.OpenTelemetry.otelSemconvIncubating)
}

configure<SourceSetContainer> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.sentry.DsnUtil;
import io.sentry.IScopes;
import java.util.Arrays;
Expand All @@ -27,12 +27,13 @@ public static boolean isSentryRequest(
return false;
}

final @Nullable String httpUrl = attributes.get(SemanticAttributes.HTTP_URL);
final @Nullable String httpUrl =
attributes.get(io.opentelemetry.semconv.SemanticAttributes.HTTP_URL);
if (DsnUtil.urlContainsDsnHost(scopes.getOptions(), httpUrl)) {
return true;
}

final @Nullable String fullUrl = attributes.get(SemanticAttributes.URL_FULL);
final @Nullable String fullUrl = attributes.get(UrlAttributes.URL_FULL);
if (DsnUtil.urlContainsDsnHost(scopes.getOptions(), fullUrl)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.data.StatusData;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import io.opentelemetry.semconv.ResourceAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.incubating.ProcessIncubatingAttributes;
import io.sentry.Baggage;
import io.sentry.DateUtils;
import io.sentry.DefaultSpanFactory;
Expand Down Expand Up @@ -66,7 +66,7 @@ public final class SentrySpanExporter implements SpanExporter {
InternalSemanticAttributes.PROFILE_SAMPLED.getKey(),
InternalSemanticAttributes.PROFILE_SAMPLE_RATE.getKey(),
InternalSemanticAttributes.PARENT_SAMPLED.getKey(),
ResourceAttributes.PROCESS_COMMAND_ARGS.getKey() // can be very long
ProcessIncubatingAttributes.PROCESS_COMMAND_ARGS.getKey() // can be very long
);
private static final @NotNull Long SPAN_TIMEOUT = DateUtils.secondsToNanos(5 * 60);

Expand Down Expand Up @@ -458,7 +458,7 @@ private SpanStatus mapOtelStatus(
}

final @Nullable Long httpStatus =
otelSpanData.getAttributes().get(SemanticAttributes.HTTP_STATUS_CODE);
otelSpanData.getAttributes().get(HttpAttributes.HTTP_RESPONSE_STATUS_CODE);
if (httpStatus != null) {
final @Nullable SpanStatus spanStatus = SpanStatus.fromHttpStatusCode(httpStatus.intValue());
if (spanStatus != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import io.opentelemetry.sdk.trace.SpanProcessor;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.data.StatusData;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.sentry.Baggage;
import io.sentry.DsnUtil;
import io.sentry.IScopes;
Expand Down Expand Up @@ -261,7 +262,7 @@ private boolean isSentryRequest(final @NotNull ReadableSpan otelSpan) {
return false;
}

final @Nullable String httpUrl = otelSpan.getAttribute(SemanticAttributes.HTTP_URL);
final @Nullable String httpUrl = otelSpan.getAttribute(UrlAttributes.URL_FULL);
return DsnUtil.urlContainsDsnHost(scopes.getOptions(), httpUrl);
}

Expand Down Expand Up @@ -345,7 +346,8 @@ private SpanStatus mapOtelStatus(final @NotNull ReadableSpan otelSpan) {
return SpanStatus.OK;
}

final @Nullable Long httpStatus = otelSpan.getAttribute(SemanticAttributes.HTTP_STATUS_CODE);
final @Nullable Long httpStatus =
otelSpan.getAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE);
if (httpStatus != null) {
final @Nullable SpanStatus spanStatus = SpanStatus.fromHttpStatusCode(httpStatus.intValue());
if (spanStatus != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;
import io.sentry.protocol.TransactionNameSource;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
Expand All @@ -17,18 +20,17 @@ public final class SpanDescriptionExtractor {
final @NotNull SpanData otelSpan, final @Nullable OtelSpanWrapper sentrySpan) {
final @NotNull Attributes attributes = otelSpan.getAttributes();

final @Nullable String httpMethod = attributes.get(SemanticAttributes.HTTP_METHOD);
final @Nullable String httpMethod = attributes.get(HttpAttributes.HTTP_REQUEST_METHOD);
if (httpMethod != null) {
return descriptionForHttpMethod(otelSpan, httpMethod);
}

final @Nullable String httpRequestMethod =
attributes.get(SemanticAttributes.HTTP_REQUEST_METHOD);
final @Nullable String httpRequestMethod = attributes.get(HttpAttributes.HTTP_REQUEST_METHOD);
if (httpRequestMethod != null) {
return descriptionForHttpMethod(otelSpan, httpRequestMethod);
}

final @Nullable String dbSystem = attributes.get(SemanticAttributes.DB_SYSTEM);
final @Nullable String dbSystem = attributes.get(DbIncubatingAttributes.DB_SYSTEM);
if (dbSystem != null) {
return descriptionForDbSystem(otelSpan);
}
Expand All @@ -53,15 +55,14 @@ private OtelSpanInfo descriptionForHttpMethod(
} else if (SpanKind.SERVER.equals(kind)) {
opBuilder.append(".server");
}
final @Nullable String httpTarget = attributes.get(SemanticAttributes.HTTP_TARGET);
final @Nullable String httpRoute = attributes.get(SemanticAttributes.HTTP_ROUTE);
final @Nullable String httpTarget = attributes.get(HttpIncubatingAttributes.HTTP_TARGET);
final @Nullable String httpRoute = attributes.get(HttpAttributes.HTTP_ROUTE);
@Nullable String httpPath = httpRoute;
if (httpPath == null) {
httpPath = httpTarget;
}
final @NotNull String op = opBuilder.toString();

final @Nullable String urlFull = attributes.get(SemanticAttributes.URL_FULL);
final @Nullable String urlFull = attributes.get(UrlAttributes.URL_FULL);
if (urlFull != null) {
if (httpPath == null) {
httpPath = urlFull;
Expand All @@ -82,7 +83,7 @@ private OtelSpanInfo descriptionForHttpMethod(
@SuppressWarnings("deprecation")
private OtelSpanInfo descriptionForDbSystem(final @NotNull SpanData otelSpan) {
final @NotNull Attributes attributes = otelSpan.getAttributes();
@Nullable String dbStatement = attributes.get(SemanticAttributes.DB_STATEMENT);
@Nullable String dbStatement = attributes.get(DbIncubatingAttributes.DB_STATEMENT);
@NotNull String description = dbStatement != null ? dbStatement : otelSpan.getName();
return new OtelSpanInfo("db", description, TransactionNameSource.TASK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import io.opentelemetry.sdk.OpenTelemetrySdk
import io.opentelemetry.sdk.trace.ReadWriteSpan
import io.opentelemetry.sdk.trace.ReadableSpan
import io.opentelemetry.sdk.trace.SdkTracerProvider
import io.opentelemetry.semconv.SemanticAttributes
import io.opentelemetry.semconv.HttpAttributes
import io.opentelemetry.semconv.UrlAttributes
import io.sentry.Baggage
import io.sentry.BaggageHeader
import io.sentry.Hint
Expand Down Expand Up @@ -125,7 +126,7 @@ class SentrySpanProcessorTest {
fun `ignores sentry client request`() {
fixture.setup()
givenSpanBuilder(SpanKind.CLIENT)
.setAttribute(SemanticAttributes.HTTP_URL, "https://[email protected]/proj/some-api")
.setAttribute(UrlAttributes.URL_FULL, "https://[email protected]/proj/some-api")
.startSpan()

thenNoTransactionIsStarted()
Expand All @@ -135,7 +136,7 @@ class SentrySpanProcessorTest {
fun `ignores sentry internal request`() {
fixture.setup()
givenSpanBuilder(SpanKind.CLIENT)
.setAttribute(SemanticAttributes.HTTP_URL, "https://[email protected]/proj/some-api")
.setAttribute(UrlAttributes.URL_FULL, "https://[email protected]/proj/some-api")
.startSpan()

thenNoTransactionIsStarted()
Expand Down Expand Up @@ -304,8 +305,8 @@ class SentrySpanProcessorTest {
thenChildSpanIsStarted()

otelChildSpan.setStatus(StatusCode.ERROR)
otelChildSpan.setAttribute(SemanticAttributes.HTTP_URL, "http://github.com/getsentry/sentry-java")
otelChildSpan.setAttribute(SemanticAttributes.HTTP_STATUS_CODE, 404L)
otelChildSpan.setAttribute(UrlAttributes.URL_FULL, "http://github.com/getsentry/sentry-java")
otelChildSpan.setAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 404L)

otelChildSpan.end()
thenChildSpanIsFinished(SpanStatus.NOT_FOUND)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies {

testImplementation(Config.Libs.OpenTelemetry.otelSdk)
testImplementation(Config.Libs.OpenTelemetry.otelSemconv)
testImplementation(Config.Libs.OpenTelemetry.otelSemconvIncubating)
}

configure<SourceSetContainer> {
Expand Down
Loading