-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathtelemetry.ts
More file actions
27 lines (24 loc) · 907 Bytes
/
telemetry.ts
File metadata and controls
27 lines (24 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
/**
* Trace-context helpers.
*
* The SDK does not depend on any OpenTelemetry packages. Instead, users
* provide an {@link TraceContextProvider} callback via client options.
*
* @module telemetry
*/
import type { TraceContext, TraceContextProvider } from "./types.js";
/**
* Calls the user-provided {@link TraceContextProvider} to obtain the current
* W3C Trace Context. Returns `{}` when no provider is configured.
*/
export async function getTraceContext(provider?: TraceContextProvider): Promise<TraceContext> {
if (!provider) return {};
try {
return (await provider()) ?? {};
} catch {
return {};
}
}