diff --git a/.craft.yml b/.craft.yml index 72373fa343..0083100920 100644 --- a/.craft.yml +++ b/.craft.yml @@ -45,6 +45,7 @@ targets: maven:io.sentry:sentry-opentelemetry-agentcustomization: maven:io.sentry:sentry-opentelemetry-core: # maven:io.sentry:sentry-opentelemetry-agentless: +# maven:io.sentry:sentry-opentelemetry-agentless-spring: maven:io.sentry:sentry-apollo: maven:io.sentry:sentry-jdbc: maven:io.sentry:sentry-graphql: diff --git a/.github/ISSUE_TEMPLATE/bug_report_java.yml b/.github/ISSUE_TEMPLATE/bug_report_java.yml index 98521cdd7a..d71d61c074 100644 --- a/.github/ISSUE_TEMPLATE/bug_report_java.yml +++ b/.github/ISSUE_TEMPLATE/bug_report_java.yml @@ -16,6 +16,7 @@ body: - sentry-kotlin-extensions - sentry-opentelemetry-agent - sentry-opentelemetry-agentless + - sentry-opentelemetry-agentless-spring - sentry-opentelemetry-core - sentry-servlet - sentry-servlet-jakarta diff --git a/CHANGELOG.md b/CHANGELOG.md index 254bc8854f..10b65f0b74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ ### Features +- Add `sentry-opentelemetry-agentless-spring` module ([#4000](https://github.com/getsentry/sentry-java/pull/4000)) + - 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. + - 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. - Add `sentry-opentelemetry-agentless` module ([#3961](https://github.com/getsentry/sentry-java/pull/3961)) - 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. - To enable the auto configuration of it, please set `-Dotel.java.global-autoconfigure.enabled=true` on the `java` command, when starting your application. diff --git a/sentry-opentelemetry/sentry-opentelemetry-agentless-spring/README.md b/sentry-opentelemetry/sentry-opentelemetry-agentless-spring/README.md new file mode 100644 index 0000000000..b808195c90 --- /dev/null +++ b/sentry-opentelemetry/sentry-opentelemetry-agentless-spring/README.md @@ -0,0 +1,54 @@ +# sentry-opentelemetry-agentless-spring + +*NOTE: Our OpenTelemetry modules are still experimental. Any feedback is welcome.* + +## How to use it + +Add the latest `sentry-opentelemetry-agentless-spring` module as a dependency and add a `sentry.properties` +configuration file to your project that could look like this: + +```properties +# NOTE: Replace the test DSN below with YOUR OWN DSN to see the events from this app in your Sentry project/dashboard +dsn=https://502f25099c204a2fbf4cb16edc5975d1@o447951.ingest.sentry.io/5428563 +traces-sample-rate=1.0 +``` + +For more details on configuring Sentry via `sentry.properties` please see the +[docs page](https://docs.sentry.io/platforms/java/configuration/). + +As an alternative to the `SENTRY_PROPERTIES_FILE` environment variable you can provide individual +settings as environment variables (e.g. `SENTRY_DSN=...`) or you may initialize `Sentry` inside +your target application. If you do so, please make sure to apply OpenTelemetry specific options, e.g. +like this: + +``` +Sentry.init( + options -> { + options.setDsn("..."); + ... + OpenTelemetryUtil.applyOpenTelemetryOptions(options, false); + } +) +``` + +## Getting rid of exporter error messages + +In case you are using this module without needing to use any OpenTelemetry exporters you can add +the following environment variables to turn off exporters and stop seeing error messages about +servers not being reachable in the logs. + +Example log message: +``` +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 +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 +``` + +### Traces + +To turn off exporting of traces you can set `OTEL_TRACES_EXPORTER=none` +see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters) + +### Metrics + +To turn off exporting of metrics you can set `OTEL_METRICS_EXPORTER=none` +see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters) diff --git a/sentry-opentelemetry/sentry-opentelemetry-agentless-spring/build.gradle.kts b/sentry-opentelemetry/sentry-opentelemetry-agentless-spring/build.gradle.kts new file mode 100644 index 0000000000..842341e2f1 --- /dev/null +++ b/sentry-opentelemetry/sentry-opentelemetry-agentless-spring/build.gradle.kts @@ -0,0 +1,19 @@ +plugins { + `java-library` +} + +configure { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +dependencies { + api(projects.sentry) + api(projects.sentryOpentelemetry.sentryOpentelemetryBootstrap) + implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentcustomization) + api(Config.Libs.OpenTelemetry.otelSdk) + api(Config.Libs.OpenTelemetry.otelSemconv) + api(Config.Libs.OpenTelemetry.otelSemconvIncubating) + api(Config.Libs.OpenTelemetry.otelExtensionAutoconfigure) + api(Config.Libs.springBoot3StarterOpenTelemetry) +} diff --git a/sentry-opentelemetry/sentry-opentelemetry-agentless-spring/src/main/java/io/sentry/opentelemetry/agent/AgentlessSpringMarker.java b/sentry-opentelemetry/sentry-opentelemetry-agentless-spring/src/main/java/io/sentry/opentelemetry/agent/AgentlessSpringMarker.java new file mode 100644 index 0000000000..eb9441148f --- /dev/null +++ b/sentry-opentelemetry/sentry-opentelemetry-agentless-spring/src/main/java/io/sentry/opentelemetry/agent/AgentlessSpringMarker.java @@ -0,0 +1,3 @@ +package io.sentry.opentelemetry.agent; + +public final class AgentlessSpringMarker {} diff --git a/sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/build.gradle.kts b/sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/build.gradle.kts index d73938fef8..eebb0dcd84 100644 --- a/sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/build.gradle.kts +++ b/sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/build.gradle.kts @@ -52,8 +52,7 @@ dependencies { implementation(projects.sentryLogback) implementation(projects.sentryGraphql22) implementation(projects.sentryQuartz) - implementation(Config.Libs.springBoot3StarterOpenTelemetry) - implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentless) + implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentlessSpring) // database query tracing implementation(projects.sentryJdbc) diff --git a/sentry-samples/sentry-samples-spring-boot-opentelemetry-noagent/build.gradle.kts b/sentry-samples/sentry-samples-spring-boot-opentelemetry-noagent/build.gradle.kts index 59687ccc26..c6dd41951c 100644 --- a/sentry-samples/sentry-samples-spring-boot-opentelemetry-noagent/build.gradle.kts +++ b/sentry-samples/sentry-samples-spring-boot-opentelemetry-noagent/build.gradle.kts @@ -52,8 +52,7 @@ dependencies { implementation(projects.sentryLogback) implementation(projects.sentryGraphql) implementation(projects.sentryQuartz) - implementation(Config.Libs.springBoot3StarterOpenTelemetry) - implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentless) + implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentlessSpring) // database query tracing implementation(projects.sentryJdbc) diff --git a/settings.gradle.kts b/settings.gradle.kts index 75cff85874..d99f0f0e0a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -49,6 +49,7 @@ include( "sentry-opentelemetry:sentry-opentelemetry-agentcustomization", "sentry-opentelemetry:sentry-opentelemetry-agent", "sentry-opentelemetry:sentry-opentelemetry-agentless", + "sentry-opentelemetry:sentry-opentelemetry-agentless-spring", "sentry-quartz", "sentry-okhttp", "sentry-samples:sentry-samples-android",