Skip to content

Commit e944a37

Browse files
authored
fix: don't import from @opentelemetry/api in public types (#9066)
1 parent 9a8bc78 commit e944a37

File tree

6 files changed

+42
-0
lines changed

6 files changed

+42
-0
lines changed

packages/vitest/src/runtime/moduleRunner/moduleEvaluator.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export interface VitestModuleEvaluatorOptions {
2929
getCurrentTestFilepath?: () => string | undefined
3030
compiledFunctionArgumentsNames?: string[]
3131
compiledFunctionArgumentsValues?: unknown[]
32+
/**
33+
* @internal
34+
*/
3235
traces?: Traces
3336
}
3437

packages/vitest/src/runtime/moduleRunner/moduleMocker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ interface MockContext {
2020

2121
export interface VitestMockerOptions {
2222
context?: vm.Context
23+
/**
24+
* @internal
25+
*/
2326
traces: Traces
2427
spyModule?: typeof import('@vitest/spy')
2528
root: string

packages/vitest/src/runtime/moduleRunner/moduleRunner.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ export interface VitestModuleRunnerOptions {
206206
getWorkerState: () => WorkerGlobalState
207207
mocker?: VitestMocker
208208
vm?: VitestVmOptions
209+
/**
210+
* @internal
211+
*/
209212
traces?: Traces
210213
spyModule?: typeof import('@vitest/spy')
211214
createImportMeta?: CreateImportMeta

packages/vitest/src/runtime/moduleRunner/startModuleRunner.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ export interface ContextModuleRunnerOptions {
2727
context?: vm.Context
2828
externalModulesExecutor?: ExternalModulesExecutor
2929
state: WorkerGlobalState
30+
/**
31+
* @internal
32+
*/
3033
traces?: Traces // optional to keep backwards compat
3134
spyModule?: typeof import('@vitest/spy')
3235
createImportMeta?: CreateImportMeta

packages/vitest/src/types/worker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ export interface WorkerSetupContext {
4949
config: SerializedConfig
5050
projectName: string
5151
rpc: WorkerRPC
52+
/**
53+
* @internal
54+
*/
5255
traces: Traces
5356
}
5457

packages/vitest/src/utils/traces.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,19 @@ export class Traces {
8383
return !!this.#otel
8484
}
8585

86+
/**
87+
* @internal
88+
*/
8689
async waitInit(): Promise<this> {
8790
if (this.#init) {
8891
await this.#init
8992
}
9093
return this
9194
}
9295

96+
/**
97+
* @internal
98+
*/
9399
startContextSpan(name: string, currentContext?: Context): {
94100
span: Span
95101
context: Context
@@ -114,6 +120,9 @@ export class Traces {
114120
}
115121
}
116122

123+
/**
124+
* @internal
125+
*/
117126
getContextFromCarrier(carrier: OTELCarrier | undefined): Context {
118127
if (!this.#otel) {
119128
return this.#noopContext
@@ -125,6 +134,9 @@ export class Traces {
125134
return this.#otel.propagation.extract(activeContext, carrier)
126135
}
127136

137+
/**
138+
* @internal
139+
*/
128140
getContextCarrier(context?: Context): OTELCarrier | undefined {
129141
if (!this.#otel) {
130142
return undefined
@@ -177,8 +189,17 @@ export class Traces {
177189
}
178190
}
179191

192+
/**
193+
* @internal
194+
*/
180195
$<T>(name: string, fn: (span: Span) => T): T
196+
/**
197+
* @internal
198+
*/
181199
$<T>(name: string, optionsOrFn: TracesSpanOptions, fn: (span: Span) => T): T
200+
/**
201+
* @internal
202+
*/
182203
$<T>(name: string, optionsOrFn: TracesSpanOptions | ((span: Span) => T), fn?: (span: Span) => T): T {
183204
const callback = typeof optionsOrFn === 'function' ? optionsOrFn : fn!
184205
if (!this.#otel) {
@@ -203,6 +224,9 @@ export class Traces {
203224
)
204225
}
205226

227+
/**
228+
* @internal
229+
*/
206230
startSpan(name: string, options?: SpanOptions, context?: Context): Span {
207231
if (!this.#otel) {
208232
return this.#noopSpan
@@ -211,6 +235,9 @@ export class Traces {
211235
return tracer.startSpan(name, options, context)
212236
}
213237

238+
/**
239+
* @internal
240+
*/
214241
async finish(): Promise<void> {
215242
await this.#sdk?.shutdown()
216243
}

0 commit comments

Comments
 (0)