Skip to content

Propagating Pyroscope labels to async worker threads in Java #237

Description

@mouhamadalmounayar

Hello,
I'm using the Pyroscope Java profiling agent to profile a Java application which does a lot of async tasks. I have a method like this:

public CompletableFuture<?> method() {
    return Pyroscope.LabelsWrapper.run(new LabelsSet(key, value), () -> doStuff());
}

The issue is that doStuff() triggers async operations executed on different worker threads. The labels set via LabelsWrapper.run() don't propagate to these worker threads, so the async work isn't profiled with the correct labels.
Is there a recommended way to handle this without adding significant verbosity to the existing code? I'm hoping to avoid manually wrapping every async call.

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