Skip to content

Support Pyroscope SDK loaded from Application ClassLoader #46

Description

@dordor12

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, 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():

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions