Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

tracer.ts

66 lines1.4 KB

1export interface SpanAttrs {
2 [key: string]: string | number | boolean | undefined
3}
4​
5interface WithSpanOptions {
6 parentContext?: any
7}
8​
9// No-op span implementation
10const noopSpan = {
11 setAttribute: () => {},
12 setAttributes: () => {},
13 setStatus: () => {},
14 recordException: () => {},
15 end: () => {},
17​
18/**
19 * Lightweight span wrapper with error handling.
20 * No-op implementation - telemetry has been removed.
21 *
22 * By default, creates spans at the current context level (siblings).
23 * Use withNestedSpan if you want parent-child relationships.
24 */
25export async function withSpan<T>(
26 name: string,
27 attrs: SpanAttrs,
28 fn: (span: any) => Promise<T>,
29 _options?: WithSpanOptions,
30): Promise<T> {
31 return await fn(noopSpan)
33​
34/**
35 * Like withSpan but propagates context so child spans nest properly.
36 * No-op implementation - telemetry has been removed.
37 */
38export async function withNestedSpan<T>(
39 name: string,
40 attrs: SpanAttrs,
41 fn: (span: any) => Promise<T>,
42 _options?: WithSpanOptions,
43): Promise<T> {
44 return await fn(noopSpan)
46​
47/**
48 * Creates a synchronous span for non-async operations
49 * No-op implementation - telemetry has been removed.
50 */
51export function withSyncSpan<T>(
52 name: string,
53 attrs: SpanAttrs,
54 fn: (span: any) => T,
55 _options?: WithSpanOptions,
56): T {
57 return fn(noopSpan)
59​
60/**
61 * Get the current tracer instance
62 * No-op implementation - telemetry has been removed.
63 */
64export function getTracer() {
65 return null