Skip to content

Commit bbfcea0

Browse files
authored
Merge branch 'feat/update-otel-sample-readme' into fix/fix-console-samples
2 parents 2ffbf93 + 8e854e7 commit bbfcea0

File tree

89 files changed

+1183
-216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1183
-216
lines changed

.craft.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ targets:
4545
maven:io.sentry:sentry-opentelemetry-agentcustomization:
4646
maven:io.sentry:sentry-opentelemetry-core:
4747
# maven:io.sentry:sentry-opentelemetry-agentless:
48+
# maven:io.sentry:sentry-opentelemetry-agentless-spring:
4849
maven:io.sentry:sentry-apollo:
4950
maven:io.sentry:sentry-jdbc:
5051
maven:io.sentry:sentry-graphql:

.github/ISSUE_TEMPLATE/bug_report_java.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ body:
1616
- sentry-kotlin-extensions
1717
- sentry-opentelemetry-agent
1818
- sentry-opentelemetry-agentless
19+
- sentry-opentelemetry-agentless-spring
1920
- sentry-opentelemetry-core
2021
- sentry-servlet
2122
- sentry-servlet-jakarta

CHANGELOG.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,38 @@
44

55
### Features
66

7+
- Add `sentry-opentelemetry-agentless-spring` module ([#4000](https://github.com/getsentry/sentry-java/pull/4000))
8+
- This module can be added as a dependency when using Sentry with OpenTelemetry and Spring Boot but don't want to use our Agent. It takes care of configuring OpenTelemetry for use with Sentry.
9+
- You may 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.
710
- Add `sentry-opentelemetry-agentless` module ([#3961](https://github.com/getsentry/sentry-java/pull/3961))
811
- This module can be added as a dependency when using Sentry with OpenTelemetry but don't want to use our Agent. It takes care of configuring OpenTelemetry for use with Sentry.
912
- To enable the auto configuration of it, please set `-Dotel.java.global-autoconfigure.enabled=true` on the `java` command, when starting your application.
1013
- 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.
1114
- `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`
15+
- Add `openTelemetryMode` option ([#3994](https://github.com/getsentry/sentry-java/pull/3994))
16+
- It defaults to `AUTO` meaning the SDK will figure out how to best configure itself for use with OpenTelemetry
17+
- Use of OpenTelemetry can also be disabled completely by setting it to `OFF` ([#3995](https://github.com/getsentry/sentry-java/pull/3995))
18+
- In this case even if OpenTelemetry is present, the Sentry SDK will not use it
19+
- Use `AGENT` when using `sentry-opentelemetry-agent`
20+
- Use `AGENTLESS` when using `sentry-opentelemetry-agentless`
21+
- Use `AGENTLESS_SPRING` when using `sentry-opentelemetry-agentless-spring`
22+
- Add `scopeBindingMode` to `SpanOptions` ([#4004](https://github.com/getsentry/sentry-java/pull/4004))
23+
- This setting only affects the SDK when used with OpenTelemetry.
24+
- Defaults to `AUTO` meaning the SDK will decide whether the span should be bound to the current scope. It will not bind transactions to scope using `AUTO`, it will only bind spans where the parent span is on the current scope.
25+
- `ON` sets the new span on the current scope.
26+
- `OFF` does not set the new span on the scope.
1527

1628
### Fixes
1729

1830
- Replace deprecated `SimpleInstrumentation` with `SimplePerformantInstrumentation` for graphql 22 ([#3974](https://github.com/getsentry/sentry-java/pull/3974))
1931
- Cache requests for Spring using Springs `ContentCachingRequestWrapper` instead of our own Wrapper to also cache parameters ([#3641](https://github.com/getsentry/sentry-java/pull/3641))
2032
- Previously only the body was cached which could lead to problems in the FilterChain as Request parameters were not available
33+
- We now hold a strong reference to the underlying OpenTelemetry span when it is created through Sentry API ([#3997](https://github.com/getsentry/sentry-java/pull/3997))
34+
- This keeps it from being garbage collected too early
35+
- Close backpressure monitor on SDK shutdown ([#3998](https://github.com/getsentry/sentry-java/pull/3998))
36+
- Due to the backpressure monitor rescheduling a task to run every 10s, it very likely caused shutdown to wait the full `shutdownTimeoutMillis` (defaulting to 2s) instead of being able to terminate immediately
37+
- Improve ignored check performance ([#3992](https://github.com/getsentry/sentry-java/pull/3992))
38+
- Checking if a span origin, a transaction or a checkIn should be ignored is now faster
2139

2240
## 8.0.0-rc.2
2341

sentry-android-core/src/main/java/io/sentry/android/core/AndroidOptionsInitializer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import io.sentry.SendFireAndForgetEnvelopeSender;
1616
import io.sentry.SendFireAndForgetOutboxSender;
1717
import io.sentry.SentryLevel;
18+
import io.sentry.SentryOpenTelemetryMode;
1819
import io.sentry.android.core.cache.AndroidEnvelopeCache;
1920
import io.sentry.android.core.internal.debugmeta.AssetsDebugMetaLoader;
2021
import io.sentry.android.core.internal.gestures.AndroidViewGestureTargetLocator;
@@ -101,7 +102,7 @@ static void loadDefaultAndMetadataOptions(
101102
options.setLogger(logger);
102103

103104
options.setDefaultScopeType(ScopeType.CURRENT);
104-
105+
options.setOpenTelemetryMode(SentryOpenTelemetryMode.OFF);
105106
options.setDateProvider(new SentryAndroidDateProvider());
106107

107108
// set a lower flush timeout on Android to avoid ANRs

sentry-android-core/src/test/java/io/sentry/android/core/EnvelopeFileObserverIntegrationTest.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ class EnvelopeFileObserverIntegrationTest {
5252

5353
@AfterTest
5454
fun shutdown() {
55-
Files.delete(file.toPath())
55+
delete(file)
56+
}
57+
58+
private fun delete(f: File) {
59+
f.listFiles()?.forEach { delete(it) }
60+
Files.delete(f.toPath())
5661
}
5762

5863
@Test

sentry-android-core/src/test/java/io/sentry/android/core/InternalSentrySdkTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class InternalSentrySdkTest {
5555
lateinit var options: SentryOptions
5656

5757
fun init(context: Context) {
58-
SentryAndroid.init(context) { options ->
58+
initForTest(context) { options ->
5959
this@Fixture.options = options
6060
options.dsn = "https://key@host/proj"
6161
options.setTransportFactory { _, _ ->

sentry-android-core/src/test/java/io/sentry/android/core/SentryAndroidTest.kt

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import io.sentry.Hint
1515
import io.sentry.ILogger
1616
import io.sentry.ISentryClient
1717
import io.sentry.Sentry
18+
import io.sentry.Sentry.OptionsConfiguration
1819
import io.sentry.SentryEnvelope
1920
import io.sentry.SentryLevel
2021
import io.sentry.SentryLevel.DEBUG
@@ -40,6 +41,8 @@ import io.sentry.cache.PersistingScopeObserver
4041
import io.sentry.cache.PersistingScopeObserver.BREADCRUMBS_FILENAME
4142
import io.sentry.cache.PersistingScopeObserver.SCOPE_CACHE
4243
import io.sentry.cache.PersistingScopeObserver.TRANSACTION_FILENAME
44+
import io.sentry.test.applyTestOptions
45+
import io.sentry.test.initForTest
4346
import io.sentry.transport.NoOpEnvelopeCache
4447
import io.sentry.util.StringUtils
4548
import org.awaitility.kotlin.await
@@ -100,9 +103,9 @@ class SentryAndroidTest {
100103
}
101104
val mockContext = context ?: ContextUtilsTestHelper.mockMetaData(metaData = metadata)
102105
when {
103-
logger != null -> SentryAndroid.init(mockContext, logger)
104-
options != null -> SentryAndroid.init(mockContext, options)
105-
else -> SentryAndroid.init(mockContext)
106+
logger != null -> initForTest(mockContext, logger)
107+
options != null -> initForTest(mockContext, options)
108+
else -> initForTest(mockContext)
106109
}
107110
}
108111

@@ -290,7 +293,7 @@ class SentryAndroidTest {
290293

291294
val mockContext = ContextUtilsTestHelper.createMockContext(true)
292295
val cacheDirPath = Files.createTempDirectory("new_cache").absolutePathString()
293-
SentryAndroid.init(mockContext) {
296+
initForTest(mockContext) {
294297
it.dsn = "https://key@sentry.io/123"
295298
it.cacheDirPath = cacheDirPath
296299
options = it
@@ -354,7 +357,7 @@ class SentryAndroidTest {
354357
@Test
355358
fun `When initializing Sentry a callback is added to application by appStartMetrics`() {
356359
val mockContext = ContextUtilsTestHelper.createMockContext(true)
357-
SentryAndroid.init(mockContext) {
360+
initForTest(mockContext) {
358361
it.dsn = "https://key@sentry.io/123"
359362
}
360363
verify(mockContext.applicationContext as Application).registerActivityLifecycleCallbacks(eq(AppStartMetrics.getInstance()))
@@ -368,7 +371,7 @@ class SentryAndroidTest {
368371
Mockito.mockStatic(ContextUtils::class.java, Mockito.CALLS_REAL_METHODS).use { mockedContextUtils ->
369372
mockedContextUtils.`when`<Any> { ContextUtils.isForegroundImportance() }
370373
.thenReturn(inForeground)
371-
SentryAndroid.init(context) { options ->
374+
initForTest(context) { options ->
372375
options.release = "prod"
373376
options.dsn = "https://key@sentry.io/123"
374377
options.isEnableAutoSessionTracking = true
@@ -558,3 +561,18 @@ class SentryAndroidTest {
558561
override fun discard(envelope: SentryEnvelope) = Unit
559562
}
560563
}
564+
565+
fun initForTest(context: Context, optionsConfiguration: OptionsConfiguration<SentryAndroidOptions>) {
566+
SentryAndroid.init(context) {
567+
applyTestOptions(it)
568+
optionsConfiguration.configure(it)
569+
}
570+
}
571+
572+
fun initForTest(context: Context, logger: ILogger) {
573+
SentryAndroid.init(context, logger)
574+
}
575+
576+
fun initForTest(context: Context) {
577+
SentryAndroid.init(context)
578+
}

sentry-android-core/src/test/java/io/sentry/android/core/SentryLogcatAdapterTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class SentryLogcatAdapterTest {
3030
}
3131
val mockContext = ContextUtilsTestHelper.mockMetaData(metaData = metadata)
3232
when {
33-
options != null -> SentryAndroid.init(mockContext, options)
34-
else -> SentryAndroid.init(mockContext)
33+
options != null -> initForTest(mockContext, options)
34+
else -> initForTest(mockContext)
3535
}
3636
}
3737
}

sentry-android-core/src/test/java/io/sentry/android/core/SessionTrackingIntegrationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class SessionTrackingIntegrationTest {
4444
@Test
4545
fun `session tracking works properly with multiple backgrounds and foregrounds`() {
4646
lateinit var options: SentryAndroidOptions
47-
SentryAndroid.init(context) {
47+
initForTest(context) {
4848
it.dsn = "https://key@sentry.io/proj"
4949
it.release = "io.sentry.samples@2.3.0"
5050
it.environment = "production"

sentry-android-integration-tests/sentry-uitest-android-benchmark/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ dependencies {
9999
errorprone(Config.CompileOnly.errorprone)
100100
errorprone(Config.CompileOnly.errorProneNullAway)
101101

102+
androidTestImplementation(projects.sentryTestSupport)
102103
androidTestImplementation(Config.TestLibs.kotlinTestJunit)
103104
androidTestImplementation(Config.TestLibs.espressoCore)
104105
androidTestImplementation(Config.TestLibs.androidxTestCoreKtx)

0 commit comments

Comments
 (0)