-
-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/internal-sdk-debug-image-fetching-per-s…
…tacktrace
- Loading branch information
Showing
32 changed files
with
606 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
* @adinauer @romtsn @stefanosiano @markushi | ||
* @adinauer @romtsn @stefanosiano @markushi @lcian |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
sentry-opentelemetry/sentry-opentelemetry-core/api/sentry-opentelemetry-core.api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...elemetry-core/src/main/java/io/sentry/opentelemetry/OpenTelemetryAttributesExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package io.sentry.opentelemetry; | ||
|
||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.sdk.trace.data.SpanData; | ||
import io.opentelemetry.semconv.HttpAttributes; | ||
import io.opentelemetry.semconv.ServerAttributes; | ||
import io.opentelemetry.semconv.UrlAttributes; | ||
import io.sentry.IScope; | ||
import io.sentry.ISpan; | ||
import io.sentry.protocol.Request; | ||
import io.sentry.util.UrlUtils; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@ApiStatus.Internal | ||
public final class OpenTelemetryAttributesExtractor { | ||
|
||
public void extract( | ||
final @NotNull SpanData otelSpan, | ||
final @NotNull ISpan sentrySpan, | ||
final @NotNull IScope scope) { | ||
final @NotNull Attributes attributes = otelSpan.getAttributes(); | ||
addRequestAttributesToScope(attributes, scope); | ||
} | ||
|
||
private void addRequestAttributesToScope(Attributes attributes, IScope scope) { | ||
if (scope.getRequest() == null) { | ||
scope.setRequest(new Request()); | ||
} | ||
final @Nullable Request request = scope.getRequest(); | ||
if (request != null) { | ||
final @Nullable String requestMethod = attributes.get(HttpAttributes.HTTP_REQUEST_METHOD); | ||
if (requestMethod != null) { | ||
request.setMethod(requestMethod); | ||
} | ||
|
||
if (request.getUrl() == null) { | ||
final @Nullable String urlFull = attributes.get(UrlAttributes.URL_FULL); | ||
if (urlFull != null) { | ||
final @NotNull UrlUtils.UrlDetails urlDetails = UrlUtils.parse(urlFull); | ||
urlDetails.applyToRequest(request); | ||
} | ||
} | ||
|
||
if (request.getUrl() == null) { | ||
final String urlString = buildUrlString(attributes); | ||
if (!urlString.isEmpty()) { | ||
request.setUrl(urlString); | ||
} | ||
} | ||
|
||
if (request.getQueryString() == null) { | ||
final @Nullable String query = attributes.get(UrlAttributes.URL_QUERY); | ||
if (query != null) { | ||
request.setQueryString(query); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private @NotNull String buildUrlString(final @NotNull Attributes attributes) { | ||
final @Nullable String scheme = attributes.get(UrlAttributes.URL_SCHEME); | ||
final @Nullable String serverAddress = attributes.get(ServerAttributes.SERVER_ADDRESS); | ||
final @Nullable Long serverPort = attributes.get(ServerAttributes.SERVER_PORT); | ||
final @Nullable String path = attributes.get(UrlAttributes.URL_PATH); | ||
|
||
if (scheme == null || serverAddress == null) { | ||
return ""; | ||
} | ||
|
||
final @NotNull StringBuilder urlBuilder = new StringBuilder(); | ||
urlBuilder.append(scheme); | ||
urlBuilder.append("://"); | ||
|
||
if (serverAddress != null) { | ||
urlBuilder.append(serverAddress); | ||
if (serverPort != null) { | ||
urlBuilder.append(":"); | ||
urlBuilder.append(serverPort); | ||
} | ||
} | ||
|
||
if (path != null) { | ||
urlBuilder.append(path); | ||
} | ||
|
||
return urlBuilder.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.