Skip to content

Commit 97634f7

Browse files
authored
Merge branch 'main' into fix/profile-measurement-types
2 parents 1b726ae + f122116 commit 97634f7

13 files changed

Lines changed: 91 additions & 71 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
### Fixes
66

77
- Updated ProfileMeasurementValue types ([#2412](https://github.com/getsentry/sentry-java/pull/2412))
8+
- No longer disable OpenTelemetry exporters in default Java Agent config ([#2408](https://github.com/getsentry/sentry-java/pull/2408))
9+
- Fix `ClassNotFoundException` for `io.sentry.spring.SentrySpringServletContainerInitializer` in `sentry-spring-jakarta` ([#2411](https://github.com/getsentry/sentry-java/issues/2411))
10+
- Fix `sentry-samples-spring-jakarta` ([#2411](https://github.com/getsentry/sentry-java/issues/2411))
811

912
## 6.9.1
1013

buildSrc/src/main/java/Config.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ object Config {
5959
val androidxRecylerView = "androidx.recyclerview:recyclerview:1.2.1"
6060

6161
val slf4jApi = "org.slf4j:slf4j-api:1.7.30"
62+
val slf4jApi2 = "org.slf4j:slf4j-api:2.0.5"
6263
val slf4jJdk14 = "org.slf4j:slf4j-jdk14:1.7.30"
6364
val logbackVersion = "1.2.9"
6465
val logbackClassic = "ch.qos.logback:logback-classic:$logbackVersion"
@@ -67,6 +68,8 @@ object Config {
6768
val log4j2Api = "org.apache.logging.log4j:log4j-api:$log4j2Version"
6869
val log4j2Core = "org.apache.logging.log4j:log4j-core:$log4j2Version"
6970

71+
val jacksonDatabind = "com.fasterxml.jackson.core:jackson-databind"
72+
7073
val springBootStarter = "org.springframework.boot:spring-boot-starter:$springBootVersion"
7174
val springBootStarterTest = "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
7275
val springBootStarterWeb = "org.springframework.boot:spring-boot-starter-web:$springBootVersion"

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import android.annotation.SuppressLint;
77
import android.app.ActivityManager;
88
import android.content.Context;
9-
import android.content.pm.PackageInfo;
109
import android.os.Build;
1110
import android.os.Debug;
1211
import android.os.Process;
@@ -61,7 +60,6 @@ final class AndroidTransactionProfiler implements ITransactionProfiler {
6160
private final @NotNull SentryAndroidOptions options;
6261
private final @NotNull IHub hub;
6362
private final @NotNull BuildInfoProvider buildInfoProvider;
64-
private final @Nullable PackageInfo packageInfo;
6563
private long transactionStartNanos = 0;
6664
private long profileStartCpuMillis = 0;
6765
private boolean isInitialized = false;
@@ -103,7 +101,6 @@ public AndroidTransactionProfiler(
103101
Objects.requireNonNull(frameMetricsCollector, "SentryFrameMetricsCollector is required");
104102
this.buildInfoProvider =
105103
Objects.requireNonNull(buildInfoProvider, "The BuildInfoProvider is required.");
106-
this.packageInfo = ContextUtils.getPackageInfo(context, options.getLogger(), buildInfoProvider);
107104
}
108105

109106
private void init() {
@@ -322,14 +319,8 @@ private void onLastTransactionFinished(final ITransaction transaction, final boo
322319
return;
323320
}
324321

325-
String versionName = "";
326-
String versionCode = "";
327322
String totalMem = "0";
328323
ActivityManager.MemoryInfo memInfo = getMemInfo();
329-
if (packageInfo != null) {
330-
versionName = ContextUtils.getVersionName(packageInfo);
331-
versionCode = ContextUtils.getVersionCode(packageInfo, buildInfoProvider);
332-
}
333324
if (memInfo != null) {
334325
totalMem = Long.toString(memInfo.totalMem);
335326
}
@@ -379,8 +370,7 @@ private void onLastTransactionFinished(final ITransaction transaction, final boo
379370
buildInfoProvider.isEmulator(),
380371
totalMem,
381372
options.getProguardUuid(),
382-
versionName,
383-
versionCode,
373+
options.getRelease(),
384374
options.getEnvironment(),
385375
isTimeout
386376
? ProfilingTraceData.TRUNCATION_REASON_TIMEOUT

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,20 @@ class AndroidTransactionProfilerTest {
368368
}
369369

370370
@Test
371+
fun `profiling trace data contains release field`() {
372+
val profiler = fixture.getSut(context)
373+
profiler.onTransactionStart(fixture.transaction1)
374+
profiler.onTransactionFinish(fixture.transaction1)
375+
verify(fixture.hub).captureEnvelope(
376+
check {
377+
assertEnvelopeItem<ProfilingTraceData>(it.items.toList()) { _, item ->
378+
assertEquals(fixture.options.release, item.release)
379+
assertNotNull(item.release)
380+
}
381+
}
382+
)
383+
}
384+
371385
fun `profiler starts collecting frame metrics when the first transaction starts`() {
372386
val profiler = fixture.getSut(context)
373387
profiler.onTransactionStart(fixture.transaction1)

sentry-opentelemetry/sentry-opentelemetry-agent/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,25 @@ To enable debug logging for Sentry, please provide `SENTRY_DEBUG=true` as enviro
4444
add `debug=true` to your `sentry.properties`.
4545

4646
To also show debug output for OpenTelemetry please add `-Dotel.javaagent.debug=true` to the command.
47+
48+
## Getting rid of exporter error messages
49+
50+
In case you are using this agent without needing to use any OpenTelemetry exporters you can add
51+
the following environment variables to turn off exporters and stop seeing error messages about
52+
servers not being reachable in the logs.
53+
54+
Example log message:
55+
```
56+
ERROR io.opentelemetry.exporter.internal.grpc.OkHttpGrpcExporter - Failed to export spans. The request could not be executed. Full error message: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:4317
57+
ERROR io.opentelemetry.exporter.internal.grpc.OkHttpGrpcExporter - Failed to export metrics. The request could not be executed. Full error message: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:4317
58+
```
59+
60+
### Traces
61+
62+
To turn off exporting of traces you can set `OTEL_TRACES_EXPORTER=none`
63+
see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters)
64+
65+
### Metrics
66+
67+
To turn off exporting of metrics you can set `OTEL_METRICS_EXPORTER=none`
68+
see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ private SdkTracerProviderBuilder configureSdkTracerProvider(
9292

9393
private Map<String, String> getDefaultProperties() {
9494
Map<String, String> properties = new HashMap<>();
95-
properties.put("otel.traces.exporter", "none");
96-
properties.put("otel.metrics.exporter", "none");
9795
properties.put("otel.propagators", "sentry");
9896
return properties;
9997
}

sentry-samples/sentry-samples-spring-jakarta/build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ dependencies {
3434
jakartaTransform("org.eclipse.transformer:org.eclipse.transformer.cli:0.5.0")
3535
jakartaTransform("org.eclipse.transformer:org.eclipse.transformer.jakarta:0.5.0")
3636

37-
implementation(Config.Libs.servletApi)
37+
implementation(Config.Libs.servletApiJakarta)
3838
implementation(Config.Libs.springWeb)
3939
implementation(Config.Libs.springAop)
4040
implementation(Config.Libs.aspectj)
4141
implementation(Config.Libs.springSecurityWeb)
4242
implementation(Config.Libs.springSecurityConfig)
4343
implementation(Config.Libs.logbackClassic)
44+
implementation(Config.Libs.slf4jApi2)
45+
implementation(Config.Libs.jacksonDatabind)
4446
implementation(Config.Libs.kotlinReflect)
4547
implementation(kotlin(Config.kotlinStdLib, KotlinCompilerVersion.VERSION))
4648
implementation(projects.sentrySpringJakarta)

sentry-samples/sentry-samples-spring-jakarta/src/main/java/io/sentry/samples/spring/jakarta/SecurityConfiguration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.springframework.context.annotation.Bean;
55
import org.springframework.context.annotation.Configuration;
66
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
7+
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
78
import org.springframework.security.core.userdetails.User;
89
import org.springframework.security.core.userdetails.UserDetails;
910
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
@@ -12,6 +13,7 @@
1213
import org.springframework.security.web.SecurityFilterChain;
1314

1415
@Configuration
16+
@EnableWebSecurity
1517
public class SecurityConfiguration {
1618

1719
// this API is meant to be consumed by non-browser clients thus the CSRF protection is not needed.

sentry-samples/sentry-samples-spring-jakarta/src/main/java/io/sentry/samples/spring/jakarta/WebConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@Configuration
1414
@EnableAspectJAutoProxy(proxyTargetClass = true)
15-
@ComponentScan("io.sentry.samples.spring.web")
15+
@ComponentScan("io.sentry.samples.spring.jakarta")
1616
@EnableWebMvc
1717
public class WebConfig {
1818

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
io.sentry.spring.SentrySpringServletContainerInitializer
1+
io.sentry.spring.jakarta.SentrySpringServletContainerInitializer

0 commit comments

Comments
 (0)