Skip to content

fix(browser): simplify orchestrator otel carrier#10283

Merged
sheremet-va merged 1 commit into
vitest-dev:mainfrom
hi-ogawa:refactor-browser-simplify-orchestrator-otelcarrier
May 7, 2026
Merged

fix(browser): simplify orchestrator otel carrier#10283
sheremet-va merged 1 commit into
vitest-dev:mainfrom
hi-ogawa:refactor-browser-simplify-orchestrator-otelcarrier

Conversation

@hi-ogawa
Copy link
Copy Markdown
Collaborator

@hi-ogawa hi-ogawa commented May 7, 2026

Description

It looks like I had a weird indirection to propagate otelCarrier to orchestrator #9180.

Previously it did:

  • browser pool opens ?otelCarrier=... as orchestrator page (along with ?sessionId=...)
  • orchestrator page middleware then extract ?otelCarrier from request, which then inject back to shell html

This now becomes:

  • browser pool open orchestrator page as usual ?sessionId=.... we record otelCarrier on server side session object.
  • orchestrator page middleware then picks up otelCarrier associated with sessionId on the server side.

How to test

Manually verified running examples/opentelemetry

screenshot image

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 7, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1b8c147
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69fc04a7867d7e0008a3cae8
😎 Deploy Preview https://deploy-preview-10283--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Collaborator Author

@hi-ogawa hi-ogawa May 7, 2026

Choose a reason for hiding this comment

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

Opening /__vitest_test__/ without ?sessionId is allowed for preview, but for otelCarrier, it's legitimate to require proper sessionId -> session mapping on server side.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

To be honest, I have no idea how sessionId-less orchestrator is meant to work. Probably we should revisit the proper invariant around these fallback.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it just picks up the first available one

@hi-ogawa hi-ogawa force-pushed the refactor-browser-simplify-orchestrator-otelcarrier branch from 1b8c147 to d916650 Compare May 7, 2026 04:22
@hi-ogawa hi-ogawa requested a review from Copilot May 7, 2026 04:56
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors how OpenTelemetry context (otelCarrier) is propagated to the browser orchestrator, switching from URL query parameter propagation to server-side session storage keyed by sessionId.

Changes:

  • Store otelCarrier on the server-side browser session object when creating a browser session.
  • Stop appending otelCarrier to the orchestrator URL query parameters.
  • Inject __VITEST_OTEL_CARRIER__ into orchestrator HTML from the server-side session instead of url.searchParams.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/vitest/src/node/types/browser.ts Extends BrowserServerStateSession to optionally include otelCarrier.
packages/vitest/src/node/project.ts Stops adding otelCarrier to the orchestrator URL; passes it into session creation instead.
packages/vitest/src/node/browser/sessions.ts Adds optional otelCarrier to the created session record via createSession options.
packages/browser/src/node/serverOrchestrator.ts Reads otelCarrier from the server-side session and injects it into the orchestrator client payload.

Comment thread packages/vitest/src/node/browser/sessions.ts
Comment thread packages/browser/src/node/serverOrchestrator.ts
Comment thread packages/browser/src/node/serverOrchestrator.ts
@hi-ogawa hi-ogawa marked this pull request as ready for review May 7, 2026 07:56
@hi-ogawa hi-ogawa changed the title refactor(browser): simplify orchestrator otel carrier fix(browser): simplify orchestrator otel carrier May 7, 2026
@sheremet-va sheremet-va merged commit 3514f9f into vitest-dev:main May 7, 2026
20 checks passed
@hi-ogawa hi-ogawa deleted the refactor-browser-simplify-orchestrator-otelcarrier branch May 7, 2026 23:08
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.

3 participants