Skip to content

Commit 75859e1

Browse files
authored
Merge cb8746c into b0e4add
2 parents b0e4add + cb8746c commit 75859e1

File tree

14 files changed

+112
-25
lines changed

14 files changed

+112
-25
lines changed

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
- To enable the auto configuration of it, please set `-Dotel.java.global-autoconfigure.enabled=true` on the `java` command, when starting your application.
1010
- You may also want to set `OTEL_LOGS_EXPORTER=none;OTEL_METRICS_EXPORTER=none;OTEL_TRACES_EXPORTER=none` env vars to not have the log flooded with error messages regarding OpenTelemetry features we don't use.
1111
- `OpenTelemetryUtil.applyOpenTelemetryOptions` now takes an enum instead of a boolean for its mode
12-
- Use `AGENT` when using `sentry-opentelemetry-agent`
13-
- Use `AGENTLESS` when using `sentry-opentelemetry-agentless`
14-
- Use `AGENTLESS_SPRING` when using `sentry-opentelemetry-agentless-spring`
12+
- Add `openTelemetryMode` option ([#3994](https://github.com/getsentry/sentry-java/pull/3994))
13+
- It defaults to `AUTO` meaning the SDK will figure out how to best configure itself for use with OpenTelemetry
14+
- Use `AGENT` when using `sentry-opentelemetry-agent`
15+
- Use `AGENTLESS` when using `sentry-opentelemetry-agentless`
16+
- Use `AGENTLESS_SPRING` when using `sentry-opentelemetry-agentless-spring`
1517

1618
### Fixes
1719

sentry-opentelemetry/sentry-opentelemetry-agentcustomization/src/main/java/io/sentry/opentelemetry/SentryAutoConfigurationCustomizerProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void customize(AutoConfigurationCustomizer autoConfiguration) {
3939
options -> {
4040
options.setEnableExternalConfiguration(true);
4141
options.setInitPriority(InitPriority.HIGH);
42-
OpenTelemetryUtil.applyOpenTelemetryOptions(options, SentryOpenTelemetryMode.AGENT);
42+
options.setOpenTelemetryMode(SentryOpenTelemetryMode.AGENT);
4343
final @Nullable SdkVersion sdkVersion = createSdkVersion(options, versionInfoHolder);
4444
if (sdkVersion != null) {
4545
options.setSdkVersion(sdkVersion);

sentry-samples/sentry-samples-console-opentelemetry-noagent/src/main/java/io/sentry/samples/console/Main.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
import io.sentry.Sentry;
1414
import io.sentry.SentryEvent;
1515
import io.sentry.SentryLevel;
16-
import io.sentry.SentryOpenTelemetryMode;
1716
import io.sentry.SpanStatus;
18-
import io.sentry.opentelemetry.OpenTelemetryUtil;
1917
import io.sentry.protocol.Message;
2018
import io.sentry.protocol.User;
2119
import java.util.Collections;
@@ -30,8 +28,6 @@ public static void main(String[] args) throws InterruptedException {
3028
options.setDsn(
3129
"https://[email protected]/5428563");
3230

33-
OpenTelemetryUtil.applyOpenTelemetryOptions(options, SentryOpenTelemetryMode.AGENTLESS);
34-
3531
// All events get assigned to the release. See more at
3632
// https://docs.sentry.io/workflow/releases/
3733
options.setRelease("[email protected]+1");

sentry-spring-boot-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/it/SentrySpringIntegrationTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import io.sentry.DefaultSpanFactory
44
import io.sentry.IScopes
55
import io.sentry.ITransportFactory
66
import io.sentry.Sentry
7+
import io.sentry.SentryOpenTelemetryMode
78
import io.sentry.SentryOptions
89
import io.sentry.checkEvent
910
import io.sentry.checkTransaction
@@ -249,6 +250,7 @@ open class App {
249250
open fun optionsCallback() = Sentry.OptionsConfiguration<SentryOptions> { options ->
250251
// due to OTel being on the classpath we need to set the default again
251252
options.spanFactory = DefaultSpanFactory()
253+
options.openTelemetryMode = SentryOpenTelemetryMode.ALL_ORIGINS
252254
}
253255
}
254256

sentry-spring-boot/src/test/kotlin/io/sentry/spring/boot/it/SentrySpringIntegrationTest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import io.sentry.DefaultSpanFactory
44
import io.sentry.IScopes
55
import io.sentry.ITransportFactory
66
import io.sentry.Sentry
7+
import io.sentry.SentryOpenTelemetryMode
78
import io.sentry.SentryOptions
89
import io.sentry.checkEvent
910
import io.sentry.checkTransaction
@@ -249,6 +250,8 @@ open class App {
249250
open fun optionsCallback() = Sentry.OptionsConfiguration<SentryOptions> { options ->
250251
// due to OTel being on the classpath we need to set the default again
251252
options.spanFactory = DefaultSpanFactory()
253+
// to test the actual spring implementation
254+
options.openTelemetryMode = SentryOpenTelemetryMode.ALL_ORIGINS
252255
}
253256
}
254257

sentry-spring-jakarta/src/main/java/io/sentry/spring/jakarta/opentelemetry/SentryOpenTelemetryAgentWithoutAutoInitConfiguration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import io.sentry.SentryIntegrationPackageStorage;
66
import io.sentry.SentryOpenTelemetryMode;
77
import io.sentry.SentryOptions;
8-
import io.sentry.opentelemetry.OpenTelemetryUtil;
98
import org.jetbrains.annotations.NotNull;
109
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
1110
import org.springframework.context.annotation.Bean;
@@ -22,7 +21,7 @@ public class SentryOpenTelemetryAgentWithoutAutoInitConfiguration {
2221
return options -> {
2322
SentryIntegrationPackageStorage.getInstance()
2423
.addIntegration("SpringBoot3OpenTelemetryAgentWithoutAutoInit");
25-
OpenTelemetryUtil.applyOpenTelemetryOptions(options, SentryOpenTelemetryMode.AGENT);
24+
options.setOpenTelemetryMode(SentryOpenTelemetryMode.AGENT);
2625
};
2726
}
2827
}

sentry-spring-jakarta/src/main/java/io/sentry/spring/jakarta/opentelemetry/SentryOpenTelemetryNoAgentConfiguration.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import io.sentry.SentryIntegrationPackageStorage;
88
import io.sentry.SentryOpenTelemetryMode;
99
import io.sentry.SentryOptions;
10-
import io.sentry.opentelemetry.OpenTelemetryUtil;
1110
import io.sentry.opentelemetry.OtelSpanFactory;
1211
import io.sentry.opentelemetry.SentryAutoConfigurationCustomizerProvider;
1312
import org.jetbrains.annotations.NotNull;
@@ -33,8 +32,7 @@ public static ISpanFactory openTelemetrySpanFactory(OpenTelemetry openTelemetry)
3332
SentryIntegrationPackageStorage.getInstance()
3433
.addIntegration("SpringBoot3OpenTelemetryNoAgent");
3534
SentryAutoConfigurationCustomizerProvider.skipInit = true;
36-
OpenTelemetryUtil.applyOpenTelemetryOptions(
37-
options, SentryOpenTelemetryMode.AGENTLESS_SPRING);
35+
options.setOpenTelemetryMode(SentryOpenTelemetryMode.AGENTLESS_SPRING);
3836
};
3937
}
4038
}

sentry-spring/src/main/java/io/sentry/spring/opentelemetry/SentryOpenTelemetryAgentWithoutAutoInitConfiguration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import io.sentry.SentryIntegrationPackageStorage;
66
import io.sentry.SentryOpenTelemetryMode;
77
import io.sentry.SentryOptions;
8-
import io.sentry.opentelemetry.OpenTelemetryUtil;
98
import org.jetbrains.annotations.NotNull;
109
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
1110
import org.springframework.context.annotation.Bean;
@@ -22,7 +21,7 @@ public class SentryOpenTelemetryAgentWithoutAutoInitConfiguration {
2221
return options -> {
2322
SentryIntegrationPackageStorage.getInstance()
2423
.addIntegration("SpringBootOpenTelemetryAgentWithoutAutoInit");
25-
OpenTelemetryUtil.applyOpenTelemetryOptions(options, SentryOpenTelemetryMode.AGENT);
24+
options.setOpenTelemetryMode(SentryOpenTelemetryMode.AGENT);
2625
};
2726
}
2827
}

sentry-spring/src/main/java/io/sentry/spring/opentelemetry/SentryOpenTelemetryNoAgentConfiguration.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import io.sentry.SentryIntegrationPackageStorage;
88
import io.sentry.SentryOpenTelemetryMode;
99
import io.sentry.SentryOptions;
10-
import io.sentry.opentelemetry.OpenTelemetryUtil;
1110
import io.sentry.opentelemetry.OtelSpanFactory;
1211
import io.sentry.opentelemetry.SentryAutoConfigurationCustomizerProvider;
1312
import org.jetbrains.annotations.NotNull;
@@ -33,8 +32,7 @@ public static ISpanFactory openTelemetrySpanFactory(OpenTelemetry openTelemetry)
3332
SentryIntegrationPackageStorage.getInstance()
3433
.addIntegration("SpringBootOpenTelemetryNoAgent");
3534
SentryAutoConfigurationCustomizerProvider.skipInit = true;
36-
OpenTelemetryUtil.applyOpenTelemetryOptions(
37-
options, SentryOpenTelemetryMode.AGENTLESS_SPRING);
35+
options.setOpenTelemetryMode(SentryOpenTelemetryMode.AGENTLESS_SPRING);
3836
};
3937
}
4038
}

sentry/api/sentry.api

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2785,6 +2785,8 @@ public final class io/sentry/SentryOpenTelemetryMode : java/lang/Enum {
27852785
public static final field AGENT Lio/sentry/SentryOpenTelemetryMode;
27862786
public static final field AGENTLESS Lio/sentry/SentryOpenTelemetryMode;
27872787
public static final field AGENTLESS_SPRING Lio/sentry/SentryOpenTelemetryMode;
2788+
public static final field ALL_ORIGINS Lio/sentry/SentryOpenTelemetryMode;
2789+
public static final field AUTO Lio/sentry/SentryOpenTelemetryMode;
27882790
public static fun valueOf (Ljava/lang/String;)Lio/sentry/SentryOpenTelemetryMode;
27892791
public static fun values ()[Lio/sentry/SentryOpenTelemetryMode;
27902792
}
@@ -2797,6 +2799,7 @@ public class io/sentry/SentryOptions {
27972799
public fun addContextTag (Ljava/lang/String;)V
27982800
public fun addEventProcessor (Lio/sentry/EventProcessor;)V
27992801
public fun addIgnoredExceptionForType (Ljava/lang/Class;)V
2802+
public fun addIgnoredSpanOrigin (Ljava/lang/String;)V
28002803
public fun addInAppExclude (Ljava/lang/String;)V
28012804
public fun addInAppInclude (Ljava/lang/String;)V
28022805
public fun addIntegration (Lio/sentry/Integration;)V
@@ -2854,6 +2857,7 @@ public class io/sentry/SentryOptions {
28542857
public fun getMaxSpans ()I
28552858
public fun getMaxTraceFileSize ()J
28562859
public fun getModulesLoader ()Lio/sentry/internal/modules/IModulesLoader;
2860+
public fun getOpenTelemetryMode ()Lio/sentry/SentryOpenTelemetryMode;
28572861
public fun getOptionsObservers ()Ljava/util/List;
28582862
public fun getOutboxPath ()Ljava/lang/String;
28592863
public fun getPerformanceCollectors ()Ljava/util/List;
@@ -2979,6 +2983,7 @@ public class io/sentry/SentryOptions {
29792983
public fun setMaxSpans (I)V
29802984
public fun setMaxTraceFileSize (J)V
29812985
public fun setModulesLoader (Lio/sentry/internal/modules/IModulesLoader;)V
2986+
public fun setOpenTelemetryMode (Lio/sentry/SentryOpenTelemetryMode;)V
29822987
public fun setPrintUncaughtStackTrace (Z)V
29832988
public fun setProfilesSampleRate (Ljava/lang/Double;)V
29842989
public fun setProfilesSampler (Lio/sentry/SentryOptions$ProfilesSamplerCallback;)V
@@ -4213,7 +4218,7 @@ public abstract interface class io/sentry/internal/viewhierarchy/ViewHierarchyEx
42134218

42144219
public final class io/sentry/opentelemetry/OpenTelemetryUtil {
42154220
public fun <init> ()V
4216-
public static fun applyOpenTelemetryOptions (Lio/sentry/SentryOptions;Lio/sentry/SentryOpenTelemetryMode;)V
4221+
public static fun applyIgnoredSpanOrigins (Lio/sentry/SentryOptions;Lio/sentry/util/LoadClass;)V
42174222
}
42184223

42194224
public final class io/sentry/profilemeasurements/ProfileMeasurement : io/sentry/JsonSerializable, io/sentry/JsonUnknown {

0 commit comments

Comments
 (0)