Skip to content
Merged
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@
import io.sentry.protocol.SentryPackage;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public final class SentryAutoConfigurationCustomizerProvider
implements AutoConfigurationCustomizerProvider {

private static final Logger logger =
Logger.getLogger(SentryAutoConfigurationCustomizerProvider.class.getName());

public static volatile boolean skipInit = false;

@Override
public void customize(AutoConfigurationCustomizer autoConfiguration) {
ensureSentryOtelStorageIsInitialized();
customizeOpenTelemetryDefaults();
final @Nullable ManifestVersionReader.VersionInfoHolder versionInfoHolder =
ManifestVersionReader.getInstance().readOpenTelemetryVersion();

Expand Down Expand Up @@ -63,6 +69,18 @@ private static void ensureSentryOtelStorageIsInitialized() {
Sentry.getGlobalScope();
}

private void customizeOpenTelemetryDefaults() {
try {
if (System.getProperty("otel.instrumentation.graphql.add-operation-name-to-span-name.enabled")
== null) {
System.setProperty(
"otel.instrumentation.graphql.add-operation-name-to-span-name.enabled", "true");
}
} catch (Exception e) {
logger.log(Level.WARNING, "Unable to change OpenTelemetry defaults for use with Sentry.", e);
}
}

private boolean isSentryAutoInitEnabled() {
if (skipInit) {
return false;
Expand Down
Loading