Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 18af98c

Browse filesBrowse files
authored
fix(browser): simplify orchestrator otel carrier (#10285)
1 parent 9f7b152 commit 18af98c
Copy full SHA for 18af98c

4 files changed

+12-5Lines changed: 12 additions & 5 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/browser/src/node/serverOrchestrator.ts‎

Copy file name to clipboardExpand all lines: packages/browser/src/node/serverOrchestrator.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export async function resolveOrchestrator(
4545
__VITEST_TYPE__: '"orchestrator"',
4646
__VITEST_SESSION_ID__: JSON.stringify(sessionId),
4747
__VITEST_TESTER_ID__: '"none"',
48-
__VITEST_OTEL_CARRIER__: url.searchParams.get('otelCarrier') ?? 'null',
48+
__VITEST_OTEL_CARRIER__: JSON.stringify(session?.otelCarrier ?? null),
4949
__VITEST_PROVIDED_CONTEXT__: JSON.stringify(stringify(browserProject.project.getProvidedContext())),
5050
__VITEST_API_TOKEN__: JSON.stringify(globalServer.vitest.config.api.token),
5151
})
Collapse file

‎packages/vitest/src/node/browser/sessions.ts‎

Copy file name to clipboardExpand all lines: packages/vitest/src/node/browser/sessions.ts
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { OTELCarrier } from '../../utils/traces'
12
import type { TestProject } from '../project'
23
import type { BrowserServerStateSession } from '../types/browser'
34
import { createDefer } from '@vitest/utils/helpers'
@@ -15,7 +16,12 @@ export class BrowserSessions {
1516
this.sessions.delete(sessionId)
1617
}
1718

18-
createSession(sessionId: string, project: TestProject, pool: { reject: (error: Error) => void }): Promise<void> {
19+
createSession(
20+
sessionId: string,
21+
project: TestProject,
22+
pool: { reject: (error: Error) => void },
23+
options?: { otelCarrier?: OTELCarrier },
24+
): Promise<void> {
1925
// this promise only waits for the WS connection with the orchestrator to be established
2026
const defer = createDefer<void>()
2127

@@ -25,6 +31,7 @@ export class BrowserSessions {
2531

2632
this.sessions.set(sessionId, {
2733
project,
34+
otelCarrier: options?.otelCarrier,
2835
connected: () => {
2936
defer.resolve()
3037
clearTimeout(timeout)
Collapse file

‎packages/vitest/src/node/project.ts‎

Copy file name to clipboardExpand all lines: packages/vitest/src/node/project.ts
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,14 +626,12 @@ export class TestProject {
626626
const url = new URL('/__vitest_test__/', origin)
627627
url.searchParams.set('sessionId', sessionId)
628628
const otelCarrier = this.vitest._traces.getContextCarrier()
629-
if (otelCarrier) {
630-
url.searchParams.set('otelCarrier', JSON.stringify(otelCarrier))
631-
}
632629
this.vitest._browserSessions.sessionIds.add(sessionId)
633630
const sessionPromise = this.vitest._browserSessions.createSession(
634631
sessionId,
635632
this,
636633
pool,
634+
{ otelCarrier },
637635
)
638636
const pagePromise = this.browser.provider.openPage(
639637
sessionId,
Collapse file

‎packages/vitest/src/node/types/browser.ts‎

Copy file name to clipboardExpand all lines: packages/vitest/src/node/types/browser.ts
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { Plugin, ViteDevServer } from 'vite'
66
import type { BrowserCommands, CDPSession } from 'vitest/browser'
77
import type { BrowserTraceViewMode } from '../../runtime/config'
88
import type { BrowserTesterOptions } from '../../types/browser'
9+
import type { OTELCarrier } from '../../utils/traces'
910
import type { TestProject } from '../project'
1011
import type { ApiConfig, ProjectConfig } from './config'
1112

@@ -309,6 +310,7 @@ export interface BrowserCommandContext {
309310

310311
export interface BrowserServerStateSession {
311312
project: TestProject
313+
otelCarrier?: OTELCarrier
312314
connected: () => void
313315
fail: (v: Error) => void
314316
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.