Skip to content

Commit 31f24d3

Browse files
committed
add updated info about new async-profiler version. add information on how to use with Spring and Agent Auto-Init
1 parent 6612b69 commit 31f24d3

File tree

3 files changed

+120
-4
lines changed

3 files changed

+120
-4
lines changed

docs/platforms/java/common/profiling/index.mdx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,22 @@ Continuous profiling is available starting in SDK version `8.23.0` for macOS and
1616

1717
</Alert>
1818

19+
<Alert level="warning">
20+
Versions < `8.26.0` use [async-profiler](https://github.com/async-profiler/async-profiler) in version 3 and thus only support Java up to JDK 22. Starting with `8.26.0` we upgraded to [async-profiler](https://github.com/async-profiler/async-profiler) 4.2 enabling support for all Java versions up to JDK 25.
21+
</Alert>
22+
1923
## Install
2024

2125
In addition to your typical Sentry dependencies, you will need to add `sentry-async-profiler` as a dependency:
2226

2327
```groovy {tabTitle:Gradle}
24-
implementation 'io.sentry:sentry-async-profiler:{{@inject packages.version('sentry.java.sentry-async-profiler', '8.23.0') }}'
28+
implementation 'io.sentry:sentry-async-profiler:{{@inject packages.version('sentry.java.async-profiler', '8.23.0') }}'
2529
```
2630
```xml {tabTitle:Maven}
2731
<dependency>
2832
<groupId>io.sentry</groupId>
2933
<artifactId>sentry-async-profiler</artifactId>
30-
<version>{{@inject packages.version('sentry.java.sentry-async-profiler', '8.23.0') }}</version>
34+
<version>{{@inject packages.version('sentry.java.async-profiler', '8.23.0') }}</version>
3135
</dependency>
3236
```
3337

@@ -57,4 +61,5 @@ Continuous profiling for Java is currently supported on:
5761
- macOS
5862
- Linux
5963

60-
The profiler uses [async-profiler](https://github.com/async-profiler/async-profiler) version 3.0 under the hood to collect profiling data. It currently supports Java up to JDK 22.
64+
The profiler uses [async-profiler](https://github.com/async-profiler/async-profiler) under the hood to collect profiling data.
65+

platform-includes/profiling/automatic-instrumentation-setup/java.spring-boot.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ Sentry.stopProfiler()
6161
```
6262

6363
<Alert level="warning">
64-
If you are using our OpenTelemetry Agent, profiling does currently NOT support the <PlatformLink to="/opentelemetry/setup/agent/auto-init">Agent Auto-Init</PlatformLink> case.
64+
If you are using our OpenTelemetry Agent, profiling when running in the <PlatformLink to="/opentelemetry/setup/agent/auto-init">Agent Auto-Init</PlatformLink> mode is supported from version `8.26.0` onwards.
6565
</Alert>
6666

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
2+
### Enabling Trace Lifecycle Profiling
3+
4+
To enable trace profiling, set the lifecycle to `TRACE`. Trace profiling requires tracing to be enabled.
5+
6+
Check out the <PlatformLink to="/tracing/">tracing setup documentation</PlatformLink> for more detailed information on how to configure sampling. Setting the sample rate to 1.0 means all transactions will be captured.
7+
8+
```properties {filename:application.properties}
9+
sentry.traces-sample-rate=1.0
10+
sentry.profile-session-sample-rate=1.0
11+
sentry.profile-lifecycle=TRACE
12+
```
13+
14+
```yaml {filename:application.yml}
15+
sentry:
16+
traces-sample-rate: 1.0
17+
profile-session-sample-rate: 1.0
18+
profile-lifecycle: TRACE
19+
```
20+
21+
### Enabling Manual Lifecycle Profiling
22+
23+
To enable manual profiling, set the lifecycle to `MANUAL`. Manual profiling does not require tracing to be enabled.
24+
25+
```properties {filename:application.properties}
26+
sentry.profile-session-sample-rate=1.0
27+
sentry.profile-lifecycle=MANUAL
28+
```
29+
30+
```yaml {filename:application.yml}
31+
sentry:
32+
profile-session-sample-rate: 1.0
33+
profile-lifecycle: MANUAL
34+
```
35+
36+
Then use the `startProfiler` and `stopProfiler` methods to start and stop profiling respectively.
37+
38+
39+
```java
40+
import io.sentry.Sentry;
41+
42+
// Start profiling
43+
Sentry.startProfiler();
44+
45+
// run some code here
46+
47+
// Stop profiling
48+
Sentry.stopProfiler();
49+
```
50+
51+
```kotlin
52+
import io.sentry.Sentry
53+
54+
// Start profiling
55+
Sentry.startProfiler()
56+
57+
// run some code here
58+
59+
// Stop profiling
60+
Sentry.stopProfiler()
61+
```
62+
63+
### Profiling with OpenTelemetry
64+
When running our OpenTelemetry Agent in <PlatformLink to="/opentelemetry/setup/agent/auto-init">Agent Auto-Init</PlatformLink> mode. The `SentryProfilerConfiguration` needs to be setup. This is due to the fact that the profiler is not yet on the classpath when the agent initializes `Sentry`. Therefore the profiler needs to be initialized when `Spring` starts.
65+
66+
<Alert level="warning">
67+
If you are using our OpenTelemetry Agent, profiling when running in the <PlatformLink to="/opentelemetry/setup/agent/auto-init">Agent Auto-Init</PlatformLink> mode is supported from version `8.26.0` onwards.
68+
</Alert>
69+
70+
In order to set this up, import `SentryProfilerConfiguration` in one of your `@Configuration` classes:
71+
72+
```java {tabTitle:Java (Spring 5)} {diff}
73+
import org.springframework.context.annotation.Bean;
74+
import org.springframework.context.annotation.Import;
75+
+import io.sentry.spring.SentryProfilerConfiguration;
76+
77+
+@Import(SentryProfilerConfiguration.class)
78+
class SentryConfig {
79+
}
80+
```
81+
82+
```java {tabTitle:Java (Spring 6)} {diff}
83+
import org.springframework.context.annotation.Bean;
84+
import org.springframework.context.annotation.Import;
85+
+import io.sentry.spring.jakarta.SentryProfilerConfiguration;
86+
87+
+@Import(SentryProfilerConfiguration.class)
88+
class SentryConfig {
89+
}
90+
```
91+
92+
```kotlin {tabTitle:Kotlin (Spring 5)} {diff}
93+
import org.springframework.context.annotation.Bean
94+
import org.springframework.context.annotation.Import
95+
+import io.sentry.spring.SentryProfilerConfiguration;
96+
97+
+@Import(SentryProfilerConfiguration::class)
98+
class SentryConfig {
99+
}
100+
```
101+
102+
```kotlin {tabTitle:Kotlin (Spring 6)} {diff}
103+
import org.springframework.context.annotation.Bean
104+
import org.springframework.context.annotation.Import
105+
+import io.sentry.spring.jakarta.SentryProfilerConfiguration;
106+
107+
+@Import(SentryProfilerConfiguration::class)
108+
class SentryConfig {
109+
}
110+
```
111+

0 commit comments

Comments
 (0)