Skip to content

ref(logging): Decouple async log context#970

Merged
dcramer merged 8 commits into
mainfrom
refactor/async-log-context
Jul 23, 2026
Merged

ref(logging): Decouple async log context#970
dcramer merged 8 commits into
mainfrom
refactor/async-log-context

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Bind provider-neutral correlation data to a typed async context domain so nested logs and spans inherit it without Slack-shaped logging contracts.

What changed

  • log-context.ts now owns the typed LogContext, its telemetry projection, and a strictly scoped runWithLogContext() API.
  • removed the public enterWith() mutation path.
  • LogTape and the direct-emission fallback consume the same AsyncLocalStorage.
  • agent runs bind conversation, destination, user, actor, and run correlation once at the execution boundary; downstream spans and errors only add local fields such as model ID.
  • provider-neutral field names preserve existing OpenTelemetry/Sentry attribute names.
  • tests cover nested restoration and concurrent isolation.

Checks

  • pnpm --filter @sentry/junior typecheck
  • pnpm lint
  • direct async-context concurrency check
  • focused Vitest is blocked locally because Postgres is unavailable at 127.0.0.1:54322; CI exercises the suite.

Requested by David Cramer via Junior.

--

View Junior Session

@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview Jul 23, 2026 1:21am

Request Review

Comment thread packages/junior/src/chat/logging.ts Outdated
Comment thread packages/junior/src/chat/log-context.ts
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: high PR risk score: high labels Jul 21, 2026
sentry-junior Bot and others added 5 commits July 22, 2026 17:36
Co-Authored-By: David Cramer <david@sentry.io>
Co-Authored-By: David Cramer <david@sentry.io>
Co-Authored-By: David Cramer <david@sentry.io>
Drop the removed resume correlation field and cover scoped updates, sanitization, and startup-failure correlation after rebasing.
Build the provider-neutral run context once for async binding and Sentry publication, and narrow its typed projection to optional strings.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cd752ef. Configure here.

Comment thread packages/junior/src/chat/logging.ts
Co-Authored-By: David Cramer <david@sentry.io>
Ignore undefined typed context deltas so nested scopes retain parent values just like the emitted attribute store.
@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: medium PR risk score: medium labels Jul 23, 2026
@dcramer
dcramer merged commit a73f28e into main Jul 23, 2026
36 checks passed
@dcramer
dcramer deleted the refactor/async-log-context branch July 23, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant