Skip to content

feat: async context labels - #334

Open
BadLiveware wants to merge 5 commits into
grafana:mainfrom
BadLiveware:feat/async-context-labels
Open

BadLiveware wants to merge 5 commits into
grafana:mainfrom
BadLiveware:feat/async-context-labels

Conversation

@BadLiveware

@BadLiveware BadLiveware commented Oct 9, 2026 •

Copy link
Copy Markdown

Adds support for labels across async contexts. ~14% slower in a very await-heavy benchmark. Opt-in via config

Use pprof's native scoped contexts to keep labels attached to overlapping asynchronous workloads without per-await JavaScript hooks. Enable this through wall.asyncContext or PYROSCOPE_WALL_ASYNC_CONTEXT, and reject unsupported runtimes instead of silently losing attribution.

Preserve contexts across profile flushes, reject unscoped label mutation in async mode, and retain synchronous labeling by default. Return callback results with their inferred types and restore default-mode labels even when callbacks throw.
Keep activation and compatibility requirements next to the existing usage link instead of maintaining a separate SDK guide. The canonical usage documentation lives on the Pyroscope documentation site.
Create a fresh async frame before calling the native setter, which mutates the current frame's map in place. Existing sibling continuations retain their captured labels while setLabels persists within the current continuation.

Keep default process-wide behavior unchanged. Exercise isolation, historical samples, flushes and restart through native node:test cases with test-managed cleanup.
Keep the contribution aligned with the existing test and tooling layout, which has no benchmark harness. Performance experiments remain local rather than adding a new maintained utility.
The generic wrapper inferred an empty argument tuple for callbacks without declared parameters, rejecting calls that previously accepted extra arguments even with async mode disabled.

Retain the typed overload and restore the legacy call form through a compatibility overload. Verify argument forwarding and promise identity in both profiling modes.
@BadLiveware BadLiveware changed the title Feat/async context labels feat: async context labels Oct 9, 2026
@cla-assistant

cla-assistant Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@BadLiveware
BadLiveware marked this pull request as ready for review October 9, 2026 16:01
@BadLiveware
BadLiveware requested review from a team as code owners October 9, 2026 16:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant