Address valid review comments
Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
This commit is contained in:
@@ -89,6 +89,13 @@ export class DefaultTracingService implements TracingService {
|
||||
|
||||
readonly context: TracingServiceContextAPI = {
|
||||
active: () => fromOtelContext(otelContext.active()),
|
||||
// `otelContext.with` is synchronous: it activates `ctx`, invokes `fn`,
|
||||
// then restores the previous active context before this call returns.
|
||||
// When `fn` is async, the AsyncLocalStorage context manager installed
|
||||
// by the OTel SDK is what keeps `ctx` active across the callback's
|
||||
// `await`s. If no context manager is registered (e.g. in a test that
|
||||
// does not wire up the OTel SDK) the `await` continuations will run
|
||||
// outside `ctx`.
|
||||
with: async <T>(
|
||||
ctx: TracingServiceContext,
|
||||
fn: () => T | Promise<T>,
|
||||
|
||||
@@ -130,6 +130,12 @@ export interface MockedTracingServicePropagationAPI
|
||||
* `mockReturnValue` / `mockImplementation`, which takes precedence over
|
||||
* the default behaviour.
|
||||
*
|
||||
* Unlike the real `DefaultTracingService`, the mock's `startActiveSpan`
|
||||
* does **not** resolve `options.credentials` from `options.request` via
|
||||
* `httpAuth`. Tests that need principal-derived span attributes should
|
||||
* supply `options.credentials` directly on the span options, or assert
|
||||
* on the raw `options` captured by `startActiveSpan.mock.calls`.
|
||||
*
|
||||
* @alpha
|
||||
*/
|
||||
export interface TracingServiceMock extends TracingService {
|
||||
|
||||
Reference in New Issue
Block a user