Skip to content

Commit 0926957

Browse files
committed
update readmes
1 parent c7c68dd commit 0926957

File tree

5 files changed

+62
-82
lines changed
  • sentry-opentelemetry
  • sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent

5 files changed

+62
-82
lines changed

sentry-opentelemetry/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@ you also need this module as a dependency.
3838
Contains `SentrySpanProcessor` and `SentryPropagator` which are used by our Java Agent but can also
3939
be used when manually instrumenting using OpenTelemetry. If you want to use OpenTelemetry without
4040
the agent but still want some configuration convenience, you should rather use the
41-
`sentry-opentelemetry-agentless` module.
41+
`sentry-opentelemetry-agentless` module or the `sentry-opentelemetry-agentless-spring` module if you are using Spring Boot.
4242

4343
### `sentry-opentelemetry-agentless`
4444
Combines all modules and dependencies needed to use Sentry with OpenTelemetry without the agent.
4545

46+
### `sentry-opentelemetry-agentless-spring`
47+
Combines all modules and dependencies needed to use Sentry with OpenTelemetry in SpringBoot without an agent.
48+
4649
## Running without an Agent
4750
If you want to use Sentry with OpenTelemetry without an agent, you can do so by adding the `sentry-opentelemetry-agentless` module as dependencies to your project.
4851

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ For more details on configuring Sentry via `sentry.properties` please see the
2121
[docs page](https://docs.sentry.io/platforms/java/configuration/).
2222

2323
As an alternative to the `SENTRY_PROPERTIES_FILE` environment variable you can provide individual
24-
settings as environment variables (e.g. `SENTRY_DSN=...`) or you may initialize `Sentry` inside
25-
your target application:
24+
settings as environment variables (e.g. `SENTRY_DSN=...`).
25+
26+
## Controlling auto initialization of Sentry
27+
28+
By default, if you pass either `SENTRY_DSN` or `SENTRY_PROPERTIES_FILE` as environment variable,
29+
Sentry will automatically be initialized by this agent. To disable this behaviour, you can set
30+
`SENTRY_AUTO_INIT=false` as environment variable. You will then have to initialize Sentry inside
31+
the target application:
2632

2733
```
2834
Sentry.init(
@@ -33,13 +39,6 @@ Sentry.init(
3339
)
3440
```
3541

36-
## Controlling auto initialization of Sentry
37-
38-
By default if you pass either `SENTRY_DSN` or `SENTRY_PROPERTIES_FILE` as environment variable,
39-
Sentry will automatically be initialized by this agent. To disable this behaviour, you can set
40-
`SENTRY_AUTO_INIT=false` as environment variable. You will then have to initialize Sentry inside
41-
the target application.
42-
4342
## Debugging
4443

4544
To enable debug logging for Sentry, please provide `SENTRY_DEBUG=true` as environment variable or
@@ -57,6 +56,7 @@ Example log message:
5756
```
5857
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
5958
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
59+
ERROR io.opentelemetry.exporter.internal.http.HttpExporter - Failed to export logs. The request could not be executed. Full error message: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:4318
6060
```
6161

6262
### Traces
@@ -68,3 +68,8 @@ see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/
6868

6969
To turn off exporting of metrics you can set `OTEL_METRICS_EXPORTER=none`
7070
see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters)
71+
72+
### Logs
73+
74+
To turn off log exporting, set `OTEL_LOGS_EXPORTER=none`
75+
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-agentless-spring/README.md

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,21 @@
22

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

5+
This module allows the use of Sentry with OpenTelemetry in SpringBoot without an agent by using the OpenTelemetry Spring Boot Starter.
6+
For guidance on when to use this module instead of the agent, please have a look at the [OpenTelemetry Spring Boot Starter documentation](https://opentelemetry.io/docs/zero-code/java/spring-boot-starter/).
7+
58
## How to use it
69

7-
Add the latest `sentry-opentelemetry-agentless-spring` module as a dependency and add a `sentry.properties`
8-
configuration file to your project that could look like this:
10+
Add the latest `sentry-opentelemetry-agentless-spring` module as a dependency to your Sentry enabled [SpringBoot](https://docs.sentry.io/platforms/java/guides/spring-boot/) application and add the following to your `application.properties`:
911

1012
```properties
11-
# NOTE: Replace the test DSN below with YOUR OWN DSN to see the events from this app in your Sentry project/dashboard
12-
dsn=https://[email protected]/5428563
13-
traces-sample-rate=1.0
13+
# OTEL configuration
14+
otel.propagators=tracecontext,baggage,sentry
15+
otel.logs.exporter=none
16+
otel.metrics.exporter=none
17+
otel.traces.exporter=none
1418
```
1519

16-
For more details on configuring Sentry via `sentry.properties` please see the
17-
[docs page](https://docs.sentry.io/platforms/java/configuration/).
18-
19-
As an alternative to the `SENTRY_PROPERTIES_FILE` environment variable you can provide individual
20-
settings as environment variables (e.g. `SENTRY_DSN=...`) or you may initialize `Sentry` inside
21-
your target application. If you do so, please make sure to apply OpenTelemetry specific options, e.g.
22-
like this:
23-
24-
```
25-
Sentry.init(
26-
options -> {
27-
options.setDsn("...");
28-
...
29-
OpenTelemetryUtil.applyOpenTelemetryOptions(options, false);
30-
}
31-
)
32-
```
33-
34-
## Getting rid of exporter error messages
35-
36-
In case you are using this module without needing to use any OpenTelemetry exporters you can add
37-
the following environment variables to turn off exporters and stop seeing error messages about
38-
servers not being reachable in the logs.
39-
40-
Example log message:
41-
```
42-
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
43-
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
44-
```
45-
46-
### Traces
47-
48-
To turn off exporting of traces you can set `OTEL_TRACES_EXPORTER=none`
49-
see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters)
50-
51-
### Metrics
20+
This module will automatically configure OpenTelemetry and Sentry for you.
5221

53-
To turn off exporting of metrics you can set `OTEL_METRICS_EXPORTER=none`
54-
see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters)
22+
With the dependency and configuration in place, just run your SpringBoot application as usual.

sentry-opentelemetry/sentry-opentelemetry-agentless/README.md

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,42 @@ For more details on configuring Sentry via `sentry.properties` please see the
1717
[docs page](https://docs.sentry.io/platforms/java/configuration/).
1818

1919
As an alternative to the `SENTRY_PROPERTIES_FILE` environment variable you can provide individual
20-
settings as environment variables (e.g. `SENTRY_DSN=...`) or you may initialize `Sentry` inside
21-
your target application. If you do so, please make sure to apply OpenTelemetry specific options, e.g.
22-
like this:
20+
settings as environment variables (e.g. `SENTRY_DSN=...`).
2321

22+
Run your application with the following JVM arguments:
2423
```
25-
Sentry.init(
26-
options -> {
27-
options.setDsn("...");
28-
...
29-
OpenTelemetryUtil.applyOpenTelemetryOptions(options, false);
30-
}
31-
)
24+
-Dotel.java.global-autoconfigure.enabled=true
3225
```
3326

34-
## Getting rid of exporter error messages
35-
36-
In case you are using this module without needing to use any OpenTelemetry exporters you can add
37-
the following environment variables to turn off exporters and stop seeing error messages about
38-
servers not being reachable in the logs.
39-
40-
Example log message:
41-
```
42-
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
43-
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
27+
You may also want to set the following environment variables to if you do not use OTEL exporters:
28+
`OTEL_LOGS_EXPORTER=none;OTEL_METRICS_EXPORTER=none;OTEL_TRACES_EXPORTER=none`
29+
30+
Alternatively you can initialize OpenTelemetry programmatically like this:
31+
32+
```java
33+
// Initialize OpenTelemetry by using the AutoConfiguredOpenTelemetrySdk which automatically
34+
// registers the `SentrySpanProcessor` and `SentryPropagator` and others.
35+
// Also, you need to disable the OTEL exporters if you do not use them.
36+
AutoConfiguredOpenTelemetrySdk.builder()
37+
.setResultAsGlobal()
38+
.addPropertiesSupplier(() -> {
39+
final Map<String, String> properties = new HashMap<>();
40+
properties.put("otel.logs.exporter", "none");
41+
properties.put("otel.metrics.exporter", "none");
42+
properties.put("otel.traces.exporter", "none");
43+
return properties;
44+
})
45+
.build();
4446
```
4547

46-
### Traces
48+
If you're not using `sentry.properties` or environment variables you can then initialize Sentry programmatically as usual:
4749

48-
To turn off exporting of traces you can set `OTEL_TRACES_EXPORTER=none`
49-
see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters)
50-
51-
### Metrics
52-
53-
To turn off exporting of metrics you can set `OTEL_METRICS_EXPORTER=none`
54-
see [OpenTelemetry GitHub](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#otlp-exporter-span-metric-and-log-exporters)
50+
```java
51+
// Initialize Sentry
52+
Sentry.init(
53+
options -> {
54+
options.setDsn("...");
55+
...
56+
}
57+
)
58+
```

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sentry Sample Spring Boot 3.0+
22

3-
Sample application showing how to use Sentry with [Spring boot](http://spring.io/projects/spring-boot) from version `3.0` onwards integrated with the [OpenTelemetry Spring Boot Starter](https://opentelemetry.io/docs/zero-code/java/spring-boot-starter/).
3+
Sample application showing how to use Sentry with [Spring boot](http://spring.io/projects/spring-boot) from version `3.0` onwards integrated with the [OpenTelemetry Spring Boot Starter](https://opentelemetry.io/docs/zero-code/java/spring-boot-starter/) without an agent.
44

55
## How to run?
66

0 commit comments

Comments
 (0)