Skip to content

Commit

Permalink
Do not replace op with auto generated content for OpenTelemetry spa…
Browse files Browse the repository at this point in the history
…ns with span kind`INTERNAL` (#3906)

* Disable op generation from span attributes if span kind is internal

* changelog

* Apply suggestions from code review
  • Loading branch information
adinauer authored Nov 21, 2024
1 parent 64bb185 commit 92518a2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- Send `otel.kind` to Sentry ([#3907](https://github.com/getsentry/sentry-java/pull/3907))
- Allow passing `environment` to `CheckinUtils.withCheckIn` ([3889](https://github.com/getsentry/sentry-java/pull/3889))

### Fixes

- Do not replace `op` with auto generated content for OpenTelemetry spans with span kind `INTERNAL` ([#3906](https://github.com/getsentry/sentry-java/pull/3906))

## 8.0.0-beta.2

### Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@ public final class SpanDescriptionExtractor {
@SuppressWarnings("deprecation")
public @NotNull OtelSpanInfo extractSpanInfo(
final @NotNull SpanData otelSpan, final @Nullable IOtelSpanWrapper sentrySpan) {
final @NotNull Attributes attributes = otelSpan.getAttributes();
if (!isInternalSpanKind(otelSpan)) {
final @NotNull Attributes attributes = otelSpan.getAttributes();

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

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

final @Nullable String dbSystem = attributes.get(DbIncubatingAttributes.DB_SYSTEM);
if (dbSystem != null) {
return descriptionForDbSystem(otelSpan);
final @Nullable String dbSystem = attributes.get(DbIncubatingAttributes.DB_SYSTEM);
if (dbSystem != null) {
return descriptionForDbSystem(otelSpan);
}
}

final @NotNull String name = otelSpan.getName();
Expand All @@ -42,6 +44,10 @@ public final class SpanDescriptionExtractor {
return new OtelSpanInfo(name, description, TransactionNameSource.CUSTOM);
}

private boolean isInternalSpanKind(final @NotNull SpanData otelSpan) {
return SpanKind.INTERNAL.equals(otelSpan.getKind());
}

@SuppressWarnings("deprecation")
private OtelSpanInfo descriptionForHttpMethod(
final @NotNull SpanData otelSpan, final @NotNull String httpMethod) {
Expand Down

0 comments on commit 92518a2

Please sign in to comment.