grafana / grafana/otel-profiling-java

Support Pyroscope SDK loaded from Application ClassLoader

Open
#46 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
53
Forks
10
Avg merge
4d 9h
Merged PRs (30d)
4

Description

## Problem

Currently, the OTel Pyroscope integration only supports two modes:
1. **Bundled mode**: Pyroscope agent is shaded into the extension JAR
2. **Java Agent mode**: Pyroscope SDK is loaded via `-javaagent` and accessed from SystemClassLoader

This limitation prevents integration with projects like [async-profiler-actuator-endpoint](https://github.com/taboola/async-profiler-actuator-endpoint), which provide profiling capabilities as a Spring Boot dependency rather than a Java agent.

## Use Case

When using `async-profiler-actuator-endpoint` or similar libraries:
- The profiling SDK is added as a Maven/Gradle dependency
- Spring Boot manages the SDK lifecycle
- The SDK is loaded by the Application ClassLoader, not the SystemClassLoader

The current implementation in `loadProfilerSdk()` only attempts to load `ProfilerSdk` from `ClassLoader.getSystemClassLoader()`:

```java
private static OtelProfilerSdkBridge loadProfilerSdk() {
try {
ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
Class sdkClass = systemClassLoader.loadClass("io.pyroscope.javaagent.ProfilerSdk");
// ...
} catch (Exception e) {
throw new RuntimeException("Error loading the profiler SDK", e);
}
}
```

This fails when the SDK is loaded as an application dependency because it's not visible in the SystemClassLoader.

## Expected Behavior

The OTel extension should be able to detect and use Pyroscope SDK instances that are:
- Loaded as application dependencies (via Maven/Gradle)
- Managed by Spring or other frameworks
- Created lazily during application startup

## Environment

- OTel Pyroscope Integration version: 1.0.4
- OpenTelemetry Java Agent version: 1.33.6
- Pyroscope SDK version: 2.0.0

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.