Skip to content

Commit

Permalink
Merge branch '8.x.x' into feat/graphql-22-update-instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lbloder authored Dec 17, 2024
2 parents dd032f7 + 30f169f commit c710bc2
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 12 deletions.
1 change: 1 addition & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ targets:
maven:io.sentry:sentry-opentelemetry-agent:
maven:io.sentry:sentry-opentelemetry-agentcustomization:
maven:io.sentry:sentry-opentelemetry-core:
# maven:io.sentry:sentry-opentelemetry-agentless:
maven:io.sentry:sentry-apollo:
maven:io.sentry:sentry-jdbc:
maven:io.sentry:sentry-graphql:
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report_java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ body:
- sentry-apollo-3
- sentry-kotlin-extensions
- sentry-opentelemetry-agent
- sentry-opentelemetry-agentless
- sentry-opentelemetry-core
- sentry-servlet
- sentry-servlet-jakarta
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Unreleased

### Features

- 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.
- 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.

### Fixes
- Replace deprecated `SimpleInstrumentation` with `SimplePerformantInstrumentation` for graphql 22 ([#3974](https://github.com/getsentry/sentry-java/pull/3974))

Expand Down
54 changes: 54 additions & 0 deletions sentry-opentelemetry/sentry-opentelemetry-agentless/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# sentry-opentelemetry-agentless

*NOTE: Our OpenTelemetry modules are still experimental. Any feedback is welcome.*

## How to use it

Add the latest `sentry-opentelemetry-agentless` 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://[email protected]/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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
plugins {
`java-library`
}

configure<JavaPluginExtension> {
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)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package io.sentry.opentelemetry.agent;

public final class AgentlessMarker {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,5 @@ configure<JavaPluginExtension> {
}

dependencies {
implementation(projects.sentry)

implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentcustomization)
implementation(projects.sentryOpentelemetry.sentryOpentelemetryBootstrap)
implementation(Config.Libs.OpenTelemetry.otelSdk)
implementation(Config.Libs.OpenTelemetry.otelExtensionAutoconfigure)
implementation(Config.Libs.OpenTelemetry.otelSemconv)
implementation(Config.Libs.OpenTelemetry.otelSemconvIncubating)
implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentless)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.sentry.SentryEvent;
import io.sentry.SentryLevel;
import io.sentry.SpanStatus;
import io.sentry.opentelemetry.OpenTelemetryUtil;
import io.sentry.protocol.Message;
import io.sentry.protocol.User;
import java.util.Collections;
Expand All @@ -28,6 +29,8 @@ public static void main(String[] args) throws InterruptedException {
options.setDsn(
"https://[email protected]/5428563");

OpenTelemetryUtil.applyOpenTelemetryOptions(options, false);

// All events get assigned to the release. See more at
// https://docs.sentry.io/workflow/releases/
options.setRelease("[email protected]+1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ dependencies {
implementation(projects.sentryGraphql22)
implementation(projects.sentryQuartz)
implementation(Config.Libs.springBoot3StarterOpenTelemetry)
implementation(projects.sentryOpentelemetry.sentryOpentelemetryBootstrap)
implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentcustomization)
implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentless)

// database query tracing
implementation(projects.sentryJdbc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ dependencies {
implementation(projects.sentryGraphql)
implementation(projects.sentryQuartz)
implementation(Config.Libs.springBoot3StarterOpenTelemetry)
implementation(projects.sentryOpentelemetry.sentryOpentelemetryBootstrap)
implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentcustomization)
implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentless)

// database query tracing
implementation(projects.sentryJdbc)
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ include(
"sentry-opentelemetry:sentry-opentelemetry-core",
"sentry-opentelemetry:sentry-opentelemetry-agentcustomization",
"sentry-opentelemetry:sentry-opentelemetry-agent",
"sentry-opentelemetry:sentry-opentelemetry-agentless",
"sentry-quartz",
"sentry-okhttp",
"sentry-samples:sentry-samples-android",
Expand Down

0 comments on commit c710bc2

Please sign in to comment.