@veryfront/ext-content-mdx 0.1.1119 → 0.1.1122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/_dnt.polyfills.d.ts +6 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/deno.js +1 -1
- package/esm/src/config/defaults.d.ts +39 -0
- package/esm/src/config/defaults.d.ts.map +1 -0
- package/esm/src/config/defaults.js +65 -0
- package/esm/src/errors/error-registry/agent.d.ts +18 -0
- package/esm/src/errors/error-registry/agent.d.ts.map +1 -0
- package/esm/src/errors/error-registry/agent.js +60 -0
- package/esm/src/errors/error-registry/boundary.d.ts +16 -0
- package/esm/src/errors/error-registry/boundary.d.ts.map +1 -0
- package/esm/src/errors/error-registry/boundary.js +52 -0
- package/esm/src/errors/error-registry/build.d.ts +20 -0
- package/esm/src/errors/error-registry/build.d.ts.map +1 -0
- package/esm/src/errors/error-registry/build.js +68 -0
- package/esm/src/errors/error-registry/config.d.ts +31 -0
- package/esm/src/errors/error-registry/config.d.ts.map +1 -0
- package/esm/src/errors/error-registry/config.js +97 -0
- package/esm/src/errors/error-registry/deploy.d.ts +12 -0
- package/esm/src/errors/error-registry/deploy.d.ts.map +1 -0
- package/esm/src/errors/error-registry/deploy.js +36 -0
- package/esm/src/errors/error-registry/dev.d.ts +14 -0
- package/esm/src/errors/error-registry/dev.d.ts.map +1 -0
- package/esm/src/errors/error-registry/dev.js +44 -0
- package/esm/src/errors/error-registry/general.d.ts +29 -0
- package/esm/src/errors/error-registry/general.d.ts.map +1 -0
- package/esm/src/errors/error-registry/general.js +92 -0
- package/esm/src/errors/error-registry/module.d.ts +16 -0
- package/esm/src/errors/error-registry/module.d.ts.map +1 -0
- package/esm/src/errors/error-registry/module.js +52 -0
- package/esm/src/errors/error-registry/route.d.ts +16 -0
- package/esm/src/errors/error-registry/route.d.ts.map +1 -0
- package/esm/src/errors/error-registry/route.js +52 -0
- package/esm/src/errors/error-registry/runtime.d.ts +27 -0
- package/esm/src/errors/error-registry/runtime.d.ts.map +1 -0
- package/esm/src/errors/error-registry/runtime.js +87 -0
- package/esm/src/errors/error-registry/server.d.ts +39 -0
- package/esm/src/errors/error-registry/server.d.ts.map +1 -0
- package/esm/src/errors/error-registry/server.js +129 -0
- package/esm/src/errors/error-registry-helpers.d.ts +6 -0
- package/esm/src/errors/error-registry-helpers.d.ts.map +1 -0
- package/esm/src/errors/error-registry-helpers.js +9 -0
- package/esm/src/errors/error-registry.d.ts +120 -0
- package/esm/src/errors/error-registry.d.ts.map +1 -0
- package/esm/src/errors/error-registry.js +60 -0
- package/esm/src/errors/types.d.ts +84 -0
- package/esm/src/errors/types.d.ts.map +1 -0
- package/esm/src/errors/types.js +69 -0
- package/esm/src/errors/veryfront-error.d.ts +149 -0
- package/esm/src/errors/veryfront-error.d.ts.map +1 -0
- package/esm/src/errors/veryfront-error.js +61 -0
- package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.d.ts +13 -0
- package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.d.ts.map +1 -0
- package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.js +55 -0
- package/esm/src/observability/tracing/api-shim.d.ts +191 -0
- package/esm/src/observability/tracing/api-shim.d.ts.map +1 -0
- package/esm/src/observability/tracing/api-shim.js +281 -0
- package/esm/src/observability/tracing/otlp-setup.d.ts +63 -0
- package/esm/src/observability/tracing/otlp-setup.d.ts.map +1 -0
- package/esm/src/observability/tracing/otlp-setup.js +219 -0
- package/esm/src/observability/tracing/telemetry-env.d.ts +3 -0
- package/esm/src/observability/tracing/telemetry-env.d.ts.map +1 -0
- package/esm/src/observability/tracing/telemetry-env.js +10 -0
- package/esm/src/platform/adapters/base.d.ts +209 -0
- package/esm/src/platform/adapters/base.d.ts.map +1 -0
- package/esm/src/platform/adapters/base.js +15 -0
- package/esm/src/platform/compat/constants.d.ts +13 -0
- package/esm/src/platform/compat/constants.d.ts.map +1 -0
- package/esm/src/platform/compat/constants.js +12 -0
- package/esm/src/platform/compat/dynamic-import.d.ts +11 -0
- package/esm/src/platform/compat/dynamic-import.d.ts.map +1 -0
- package/esm/src/platform/compat/dynamic-import.js +10 -0
- package/esm/src/platform/compat/fs.d.ts +76 -0
- package/esm/src/platform/compat/fs.d.ts.map +1 -0
- package/esm/src/platform/compat/fs.js +336 -0
- package/esm/src/platform/compat/process/command.d.ts +33 -0
- package/esm/src/platform/compat/process/command.d.ts.map +1 -0
- package/esm/src/platform/compat/process/command.js +206 -0
- package/esm/src/platform/compat/process.d.ts +5 -0
- package/esm/src/platform/compat/process.d.ts.map +1 -0
- package/esm/src/platform/compat/process.js +4 -0
- package/esm/src/transforms/import-rewriter/url-builder.d.ts +70 -0
- package/esm/src/transforms/import-rewriter/url-builder.d.ts.map +1 -0
- package/esm/src/transforms/import-rewriter/url-builder.js +152 -0
- package/esm/src/transforms/mdx/compiler/import-rewriter.d.ts.map +1 -1
- package/esm/src/transforms/mdx/compiler/import-rewriter.js +2 -1
- package/esm/src/utils/base64url.d.ts +7 -0
- package/esm/src/utils/base64url.d.ts.map +1 -0
- package/esm/src/utils/base64url.js +39 -0
- package/esm/src/utils/bundle-manifest.d.ts +63 -0
- package/esm/src/utils/bundle-manifest.d.ts.map +1 -0
- package/esm/src/utils/bundle-manifest.js +96 -0
- package/esm/src/utils/constants/buffers.d.ts +24 -0
- package/esm/src/utils/constants/buffers.d.ts.map +1 -0
- package/esm/src/utils/constants/buffers.js +23 -0
- package/esm/src/utils/constants/build.d.ts +8 -0
- package/esm/src/utils/constants/build.d.ts.map +1 -0
- package/esm/src/utils/constants/build.js +7 -0
- package/esm/src/utils/constants/cache.d.ts +74 -0
- package/esm/src/utils/constants/cache.d.ts.map +1 -0
- package/esm/src/utils/constants/cache.js +133 -0
- package/esm/src/utils/constants/cdn.d.ts +29 -0
- package/esm/src/utils/constants/cdn.d.ts.map +1 -0
- package/esm/src/utils/constants/cdn.js +58 -0
- package/esm/src/utils/constants/crypto.d.ts +10 -0
- package/esm/src/utils/constants/crypto.d.ts.map +1 -0
- package/esm/src/utils/constants/crypto.js +9 -0
- package/esm/src/utils/constants/env.d.ts +16 -0
- package/esm/src/utils/constants/env.d.ts.map +1 -0
- package/esm/src/utils/constants/env.js +20 -0
- package/esm/src/utils/constants/hash.d.ts +5 -0
- package/esm/src/utils/constants/hash.d.ts.map +1 -0
- package/esm/src/utils/constants/hash.js +4 -0
- package/esm/src/utils/constants/hmr.d.ts +24 -0
- package/esm/src/utils/constants/hmr.d.ts.map +1 -0
- package/esm/src/utils/constants/hmr.js +26 -0
- package/esm/src/utils/constants/html.d.ts +13 -0
- package/esm/src/utils/constants/html.d.ts.map +1 -0
- package/esm/src/utils/constants/html.js +12 -0
- package/esm/src/utils/constants/http.d.ts +77 -0
- package/esm/src/utils/constants/http.d.ts.map +1 -0
- package/esm/src/utils/constants/http.js +76 -0
- package/esm/src/utils/constants/index.d.ts +23 -0
- package/esm/src/utils/constants/index.d.ts.map +1 -0
- package/esm/src/utils/constants/index.js +22 -0
- package/esm/src/utils/constants/limits.d.ts +27 -0
- package/esm/src/utils/constants/limits.d.ts.map +1 -0
- package/esm/src/utils/constants/limits.js +26 -0
- package/esm/src/utils/constants/metrics.d.ts +10 -0
- package/esm/src/utils/constants/metrics.d.ts.map +1 -0
- package/esm/src/utils/constants/metrics.js +34 -0
- package/esm/src/utils/constants/network.d.ts +23 -0
- package/esm/src/utils/constants/network.d.ts.map +1 -0
- package/esm/src/utils/constants/network.js +27 -0
- package/esm/src/utils/constants/priorities.d.ts +31 -0
- package/esm/src/utils/constants/priorities.d.ts.map +1 -0
- package/esm/src/utils/constants/priorities.js +30 -0
- package/esm/src/utils/constants/retry.d.ts +14 -0
- package/esm/src/utils/constants/retry.d.ts.map +1 -0
- package/esm/src/utils/constants/retry.js +13 -0
- package/esm/src/utils/constants/server.d.ts +107 -0
- package/esm/src/utils/constants/server.d.ts.map +1 -0
- package/esm/src/utils/constants/server.js +120 -0
- package/esm/src/utils/feature-flags.d.ts +7 -0
- package/esm/src/utils/feature-flags.d.ts.map +1 -0
- package/esm/src/utils/feature-flags.js +8 -0
- package/esm/src/utils/hash-utils.d.ts +22 -0
- package/esm/src/utils/hash-utils.d.ts.map +1 -0
- package/esm/src/utils/hash-utils.js +48 -0
- package/esm/src/utils/import-lockfile.d.ts +52 -0
- package/esm/src/utils/import-lockfile.d.ts.map +1 -0
- package/esm/src/utils/import-lockfile.js +187 -0
- package/esm/src/utils/index.d.ts +30 -0
- package/esm/src/utils/index.d.ts.map +1 -0
- package/esm/src/utils/index.js +29 -0
- package/esm/src/utils/logger/components.d.ts +73 -0
- package/esm/src/utils/logger/components.d.ts.map +1 -0
- package/esm/src/utils/logger/components.js +81 -0
- package/esm/src/utils/logger/index.d.ts +10 -0
- package/esm/src/utils/logger/index.d.ts.map +1 -0
- package/esm/src/utils/logger/index.js +9 -0
- package/esm/src/utils/logger/request-context.d.ts +27 -0
- package/esm/src/utils/logger/request-context.d.ts.map +1 -0
- package/esm/src/utils/logger/request-context.js +28 -0
- package/esm/src/utils/memoize.d.ts +19 -0
- package/esm/src/utils/memoize.d.ts.map +1 -0
- package/esm/src/utils/memoize.js +72 -0
- package/esm/src/utils/parallel.d.ts +21 -0
- package/esm/src/utils/parallel.d.ts.map +1 -0
- package/esm/src/utils/parallel.js +51 -0
- package/esm/src/utils/path-utils.d.ts +34 -0
- package/esm/src/utils/path-utils.d.ts.map +1 -0
- package/esm/src/utils/path-utils.js +138 -0
- package/esm/src/utils/perf-timer.d.ts +11 -0
- package/esm/src/utils/perf-timer.d.ts.map +1 -0
- package/esm/src/utils/perf-timer.js +114 -0
- package/esm/src/utils/platform.d.ts +9 -0
- package/esm/src/utils/platform.d.ts.map +1 -0
- package/esm/src/utils/platform.js +11 -0
- package/esm/src/utils/runtime-guards.d.ts +29 -0
- package/esm/src/utils/runtime-guards.d.ts.map +1 -0
- package/esm/src/utils/runtime-guards.js +23 -0
- package/esm/src/utils/sleep.d.ts +2 -0
- package/esm/src/utils/sleep.d.ts.map +1 -0
- package/esm/src/utils/sleep.js +19 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin in-process shim for `@opentelemetry/api`.
|
|
3
|
+
*
|
|
4
|
+
* Core files that previously imported directly from `@opentelemetry/api` now
|
|
5
|
+
* import from this module. When the `ext-observability-opentelemetry` extension is present
|
|
6
|
+
* the real SDK provider is wired in via `setGlobalTracerProvider`; otherwise
|
|
7
|
+
* every call falls back to a no-op implementation so the core boots without the
|
|
8
|
+
* extension installed.
|
|
9
|
+
*
|
|
10
|
+
* **Tracing types and constants** (exported for call-site use):
|
|
11
|
+
* `Span`, `Tracer`, `TracerProvider`, `Context`, `TextMapPropagator`
|
|
12
|
+
* `SpanKind`, `SpanStatusCode`
|
|
13
|
+
*
|
|
14
|
+
* **Metrics types** (re-exported structural shapes for the metrics subsystem;
|
|
15
|
+
* not backed by a live SDK — the metrics subsystem is wired separately):
|
|
16
|
+
* `Meter`, `Counter`, `Histogram`, `ObservableGauge`, `UpDownCounter`,
|
|
17
|
+
* `ObservableResult`
|
|
18
|
+
*
|
|
19
|
+
* @module observability/tracing/api-shim
|
|
20
|
+
*/
|
|
21
|
+
export type AttributePrimitive = string | number | boolean;
|
|
22
|
+
export type AttributeValue = AttributePrimitive | readonly AttributePrimitive[] | undefined;
|
|
23
|
+
export interface Span {
|
|
24
|
+
setAttribute(key: string, value: AttributeValue): Span;
|
|
25
|
+
setAttributes(attrs: Record<string, AttributeValue>): Span;
|
|
26
|
+
setStatus(status: {
|
|
27
|
+
code: number;
|
|
28
|
+
message?: string;
|
|
29
|
+
}): Span;
|
|
30
|
+
recordException(err: unknown): void;
|
|
31
|
+
addEvent(name: string, attrs?: Record<string, AttributeValue>): Span;
|
|
32
|
+
end(endTime?: number): void;
|
|
33
|
+
spanContext(): SpanContext;
|
|
34
|
+
updateName(name: string): void;
|
|
35
|
+
}
|
|
36
|
+
export interface SpanContext {
|
|
37
|
+
traceId: string;
|
|
38
|
+
spanId: string;
|
|
39
|
+
traceFlags: number;
|
|
40
|
+
}
|
|
41
|
+
export interface Tracer {
|
|
42
|
+
startSpan(name: string, options?: {
|
|
43
|
+
kind?: number;
|
|
44
|
+
attributes?: Record<string, AttributeValue>;
|
|
45
|
+
}, context?: Context): Span;
|
|
46
|
+
startActiveSpan<T>(name: string, fn: (span: Span) => T): T;
|
|
47
|
+
startActiveSpan<T>(name: string, options: {
|
|
48
|
+
kind?: number;
|
|
49
|
+
attributes?: Record<string, AttributeValue>;
|
|
50
|
+
}, fn: (span: Span) => T): T;
|
|
51
|
+
startActiveSpan<T>(name: string, options: {
|
|
52
|
+
kind?: number;
|
|
53
|
+
attributes?: Record<string, AttributeValue>;
|
|
54
|
+
}, context: Context, fn: (span: Span) => T): T;
|
|
55
|
+
}
|
|
56
|
+
export interface TracerProvider {
|
|
57
|
+
getTracer(name: string, version?: string): Tracer;
|
|
58
|
+
}
|
|
59
|
+
export interface Context {
|
|
60
|
+
getValue(key: symbol): unknown;
|
|
61
|
+
setValue(key: symbol, value: unknown): Context;
|
|
62
|
+
deleteValue(key: symbol): Context;
|
|
63
|
+
}
|
|
64
|
+
export interface TextMapGetter<C = Record<string, string>> {
|
|
65
|
+
keys(carrier: C): string[];
|
|
66
|
+
get(carrier: C, key: string): string | string[] | undefined;
|
|
67
|
+
}
|
|
68
|
+
export interface TextMapSetter<C = Record<string, string>> {
|
|
69
|
+
set(carrier: C, key: string, value: string): void;
|
|
70
|
+
}
|
|
71
|
+
export interface TextMapPropagator {
|
|
72
|
+
inject(context: Context, carrier: unknown, setter?: TextMapSetter<unknown>): void;
|
|
73
|
+
extract(context: Context, carrier: unknown, getter?: TextMapGetter<unknown>): Context;
|
|
74
|
+
fields(): string[];
|
|
75
|
+
}
|
|
76
|
+
export interface ContextAccessor {
|
|
77
|
+
active(): Context;
|
|
78
|
+
with<T>(ctx: Context, fn: () => T): T;
|
|
79
|
+
}
|
|
80
|
+
export interface ActiveSpanAccessor {
|
|
81
|
+
getActiveSpan(): Span | undefined;
|
|
82
|
+
getSpan(ctx: Context): Span | undefined;
|
|
83
|
+
setSpan?(ctx: Context, span: Span): Context;
|
|
84
|
+
}
|
|
85
|
+
export declare const SpanKind: {
|
|
86
|
+
readonly INTERNAL: 0;
|
|
87
|
+
readonly SERVER: 1;
|
|
88
|
+
readonly CLIENT: 2;
|
|
89
|
+
readonly PRODUCER: 3;
|
|
90
|
+
readonly CONSUMER: 4;
|
|
91
|
+
};
|
|
92
|
+
export type SpanKind = typeof SpanKind[keyof typeof SpanKind];
|
|
93
|
+
export declare const SpanStatusCode: {
|
|
94
|
+
readonly UNSET: 0;
|
|
95
|
+
readonly OK: 1;
|
|
96
|
+
readonly ERROR: 2;
|
|
97
|
+
};
|
|
98
|
+
export type SpanStatusCode = typeof SpanStatusCode[keyof typeof SpanStatusCode];
|
|
99
|
+
export interface ObservableResult {
|
|
100
|
+
observe(value: number, attributes?: Record<string, AttributeValue>): void;
|
|
101
|
+
}
|
|
102
|
+
export interface Counter {
|
|
103
|
+
add(value: number, attributes?: Record<string, AttributeValue>): void;
|
|
104
|
+
}
|
|
105
|
+
export interface UpDownCounter {
|
|
106
|
+
add(value: number, attributes?: Record<string, AttributeValue>): void;
|
|
107
|
+
}
|
|
108
|
+
export interface Histogram {
|
|
109
|
+
record(value: number, attributes?: Record<string, AttributeValue>): void;
|
|
110
|
+
}
|
|
111
|
+
export interface ObservableGauge {
|
|
112
|
+
addCallback(callback: (result: ObservableResult) => void): void;
|
|
113
|
+
}
|
|
114
|
+
export interface Meter {
|
|
115
|
+
createCounter(name: string, options?: {
|
|
116
|
+
description?: string;
|
|
117
|
+
unit?: string;
|
|
118
|
+
}): Counter;
|
|
119
|
+
createUpDownCounter(name: string, options?: {
|
|
120
|
+
description?: string;
|
|
121
|
+
unit?: string;
|
|
122
|
+
}): UpDownCounter;
|
|
123
|
+
createHistogram(name: string, options?: {
|
|
124
|
+
description?: string;
|
|
125
|
+
unit?: string;
|
|
126
|
+
advice?: {
|
|
127
|
+
explicitBucketBoundaries?: number[];
|
|
128
|
+
};
|
|
129
|
+
}): Histogram;
|
|
130
|
+
createObservableGauge(name: string, options?: {
|
|
131
|
+
description?: string;
|
|
132
|
+
unit?: string;
|
|
133
|
+
}): ObservableGauge;
|
|
134
|
+
getMeter?: never;
|
|
135
|
+
}
|
|
136
|
+
export interface MetricsAPI {
|
|
137
|
+
getMeter(name: string | undefined, version?: string): Meter;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Register the real OTel trace API's span accessors. Called by the
|
|
141
|
+
* ext-observability-opentelemetry extension after it wires the SDK so that the shim's
|
|
142
|
+
* `trace.getActiveSpan()` / `trace.getSpan()` can return real spans.
|
|
143
|
+
*/
|
|
144
|
+
export declare function setGlobalActiveSpanAccessor(accessor: ActiveSpanAccessor): void;
|
|
145
|
+
/**
|
|
146
|
+
* Register the real OTel context API. This lets the shim preserve active span
|
|
147
|
+
* context across async boundaries once the extension has installed the SDK's
|
|
148
|
+
* AsyncLocalStorageContextManager.
|
|
149
|
+
*/
|
|
150
|
+
export declare function setGlobalContextAccessor(accessor: ContextAccessor): void;
|
|
151
|
+
/**
|
|
152
|
+
* Wire in the real SDK TracerProvider.
|
|
153
|
+
* Called from `src/server/bootstrap.ts` after `orchestrateExtensions()` runs.
|
|
154
|
+
*/
|
|
155
|
+
export declare function setGlobalTracerProvider(p: TracerProvider): void;
|
|
156
|
+
export declare function getGlobalTracerProvider(): TracerProvider;
|
|
157
|
+
export declare function getTracerProviderRevision(): number;
|
|
158
|
+
/**
|
|
159
|
+
* Get a tracer from the active provider.
|
|
160
|
+
* Returns the no-op tracer when ext-observability-opentelemetry is not installed.
|
|
161
|
+
*/
|
|
162
|
+
export declare function getTracer(name: string, version?: string): Tracer;
|
|
163
|
+
export declare const context: {
|
|
164
|
+
active(): Context;
|
|
165
|
+
with<T>(ctx: Context, fn: () => T): T;
|
|
166
|
+
setGlobalContextManager(_mgr: unknown): void;
|
|
167
|
+
};
|
|
168
|
+
export declare const trace: {
|
|
169
|
+
getTracer(name: string, version?: string): Tracer;
|
|
170
|
+
setGlobalTracerProvider(p: TracerProvider): void;
|
|
171
|
+
getGlobalTracerProvider(): TracerProvider;
|
|
172
|
+
setSpan(ctx: Context, _span: Span): Context;
|
|
173
|
+
getSpan(ctx: Context): Span | undefined;
|
|
174
|
+
getActiveSpan(): Span | undefined;
|
|
175
|
+
};
|
|
176
|
+
export declare const propagation: {
|
|
177
|
+
setGlobalPropagator(p: TextMapPropagator): void;
|
|
178
|
+
extract<C>(ctx: Context, carrier: C, getter?: TextMapGetter<C>): Context;
|
|
179
|
+
inject<C>(ctx: Context, carrier: C, setter?: TextMapSetter<C>): void;
|
|
180
|
+
};
|
|
181
|
+
export declare const defaultTextMapGetter: TextMapGetter<Record<string, string>>;
|
|
182
|
+
export declare const defaultTextMapSetter: TextMapSetter<Record<string, string>>;
|
|
183
|
+
/**
|
|
184
|
+
* Register the OTel Metrics API (from the SDK).
|
|
185
|
+
* Called by ext-observability-opentelemetry in its setup hook so the metrics subsystem
|
|
186
|
+
* can use `getMeter()` when available.
|
|
187
|
+
*/
|
|
188
|
+
export declare function setGlobalMetricsAPI(api: MetricsAPI): void;
|
|
189
|
+
export declare function getGlobalMetricsAPI(): MetricsAPI | null;
|
|
190
|
+
export declare function _resetShimForTests(): void;
|
|
191
|
+
//# sourceMappingURL=api-shim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-shim.d.ts","sourceRoot":"","sources":["../../../../src/src/observability/tracing/api-shim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AASH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAC3D,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,SAAS,kB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QF;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CAEzD;AAED,wBAAgB,mBAAmB,IAAI,UAAU,GAAG,IAAI,CAEvD;AAMD,wBAAgB,kBAAkB,IAAI,IAAI,CAQzC"}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin in-process shim for `@opentelemetry/api`.
|
|
3
|
+
*
|
|
4
|
+
* Core files that previously imported directly from `@opentelemetry/api` now
|
|
5
|
+
* import from this module. When the `ext-observability-opentelemetry` extension is present
|
|
6
|
+
* the real SDK provider is wired in via `setGlobalTracerProvider`; otherwise
|
|
7
|
+
* every call falls back to a no-op implementation so the core boots without the
|
|
8
|
+
* extension installed.
|
|
9
|
+
*
|
|
10
|
+
* **Tracing types and constants** (exported for call-site use):
|
|
11
|
+
* `Span`, `Tracer`, `TracerProvider`, `Context`, `TextMapPropagator`
|
|
12
|
+
* `SpanKind`, `SpanStatusCode`
|
|
13
|
+
*
|
|
14
|
+
* **Metrics types** (re-exported structural shapes for the metrics subsystem;
|
|
15
|
+
* not backed by a live SDK — the metrics subsystem is wired separately):
|
|
16
|
+
* `Meter`, `Counter`, `Histogram`, `ObservableGauge`, `UpDownCounter`,
|
|
17
|
+
* `ObservableResult`
|
|
18
|
+
*
|
|
19
|
+
* @module observability/tracing/api-shim
|
|
20
|
+
*/
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Span kind + status constants
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
export const SpanKind = {
|
|
25
|
+
INTERNAL: 0,
|
|
26
|
+
SERVER: 1,
|
|
27
|
+
CLIENT: 2,
|
|
28
|
+
PRODUCER: 3,
|
|
29
|
+
CONSUMER: 4,
|
|
30
|
+
};
|
|
31
|
+
export const SpanStatusCode = {
|
|
32
|
+
UNSET: 0,
|
|
33
|
+
OK: 1,
|
|
34
|
+
ERROR: 2,
|
|
35
|
+
};
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// No-op provider (default when ext-observability-opentelemetry is not installed)
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
function createNoopContext() {
|
|
40
|
+
const store = new Map();
|
|
41
|
+
return {
|
|
42
|
+
getValue: (key) => store.get(key),
|
|
43
|
+
setValue(key, value) {
|
|
44
|
+
store.set(key, value);
|
|
45
|
+
return this;
|
|
46
|
+
},
|
|
47
|
+
deleteValue(key) {
|
|
48
|
+
store.delete(key);
|
|
49
|
+
return this;
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const NOOP_CONTEXT = createNoopContext();
|
|
54
|
+
const EMPTY_TRACE_ID = "00000000000000000000000000000000";
|
|
55
|
+
const EMPTY_SPAN_ID = "0000000000000000";
|
|
56
|
+
const NOOP_SPAN_CONTEXT = {
|
|
57
|
+
traceId: EMPTY_TRACE_ID,
|
|
58
|
+
spanId: EMPTY_SPAN_ID,
|
|
59
|
+
traceFlags: 0,
|
|
60
|
+
};
|
|
61
|
+
const NOOP_SPAN = {
|
|
62
|
+
setAttribute() {
|
|
63
|
+
return NOOP_SPAN;
|
|
64
|
+
},
|
|
65
|
+
setAttributes() {
|
|
66
|
+
return NOOP_SPAN;
|
|
67
|
+
},
|
|
68
|
+
setStatus() {
|
|
69
|
+
return NOOP_SPAN;
|
|
70
|
+
},
|
|
71
|
+
recordException() { },
|
|
72
|
+
addEvent() {
|
|
73
|
+
return NOOP_SPAN;
|
|
74
|
+
},
|
|
75
|
+
end() { },
|
|
76
|
+
spanContext() {
|
|
77
|
+
return NOOP_SPAN_CONTEXT;
|
|
78
|
+
},
|
|
79
|
+
updateName() { },
|
|
80
|
+
};
|
|
81
|
+
function createNoopTracer() {
|
|
82
|
+
return {
|
|
83
|
+
startSpan() {
|
|
84
|
+
return NOOP_SPAN;
|
|
85
|
+
},
|
|
86
|
+
startActiveSpan(_name, optionsOrFn, contextOrFn, fn) {
|
|
87
|
+
const callback = typeof optionsOrFn === "function"
|
|
88
|
+
? optionsOrFn
|
|
89
|
+
: typeof contextOrFn === "function"
|
|
90
|
+
? contextOrFn
|
|
91
|
+
: fn;
|
|
92
|
+
return callback(NOOP_SPAN);
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function createNoopProvider() {
|
|
97
|
+
const noopTracer = createNoopTracer();
|
|
98
|
+
return { getTracer: () => noopTracer };
|
|
99
|
+
}
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
// Global provider state
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
let _provider = createNoopProvider();
|
|
104
|
+
let _providerRevision = 0;
|
|
105
|
+
let _activeContext = NOOP_CONTEXT;
|
|
106
|
+
let _propagator = null;
|
|
107
|
+
let _contextAccessor = null;
|
|
108
|
+
const ACTIVE_SPAN_CONTEXT_KEY = Symbol.for("veryfront.observability.active_span");
|
|
109
|
+
/**
|
|
110
|
+
* Optional accessor for the currently active span. Wired by
|
|
111
|
+
* ext-observability-opentelemetry (via `setGlobalActiveSpanAccessor`) so `trace.getActiveSpan()`
|
|
112
|
+
* and `trace.getSpan()` return the real SDK span once the extension is active.
|
|
113
|
+
*/
|
|
114
|
+
let _activeSpanAccessor = null;
|
|
115
|
+
/**
|
|
116
|
+
* Register the real OTel trace API's span accessors. Called by the
|
|
117
|
+
* ext-observability-opentelemetry extension after it wires the SDK so that the shim's
|
|
118
|
+
* `trace.getActiveSpan()` / `trace.getSpan()` can return real spans.
|
|
119
|
+
*/
|
|
120
|
+
export function setGlobalActiveSpanAccessor(accessor) {
|
|
121
|
+
_activeSpanAccessor = accessor;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Register the real OTel context API. This lets the shim preserve active span
|
|
125
|
+
* context across async boundaries once the extension has installed the SDK's
|
|
126
|
+
* AsyncLocalStorageContextManager.
|
|
127
|
+
*/
|
|
128
|
+
export function setGlobalContextAccessor(accessor) {
|
|
129
|
+
_contextAccessor = accessor;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Wire in the real SDK TracerProvider.
|
|
133
|
+
* Called from `src/server/bootstrap.ts` after `orchestrateExtensions()` runs.
|
|
134
|
+
*/
|
|
135
|
+
export function setGlobalTracerProvider(p) {
|
|
136
|
+
_provider = p;
|
|
137
|
+
_providerRevision++;
|
|
138
|
+
}
|
|
139
|
+
export function getGlobalTracerProvider() {
|
|
140
|
+
return _provider;
|
|
141
|
+
}
|
|
142
|
+
export function getTracerProviderRevision() {
|
|
143
|
+
return _providerRevision;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get a tracer from the active provider.
|
|
147
|
+
* Returns the no-op tracer when ext-observability-opentelemetry is not installed.
|
|
148
|
+
*/
|
|
149
|
+
export function getTracer(name, version) {
|
|
150
|
+
return _provider.getTracer(name, version);
|
|
151
|
+
}
|
|
152
|
+
// ---------------------------------------------------------------------------
|
|
153
|
+
// Context API
|
|
154
|
+
// ---------------------------------------------------------------------------
|
|
155
|
+
export const context = {
|
|
156
|
+
active() {
|
|
157
|
+
return _contextAccessor?.active() ?? _activeContext;
|
|
158
|
+
},
|
|
159
|
+
with(ctx, fn) {
|
|
160
|
+
if (_contextAccessor) {
|
|
161
|
+
return _contextAccessor.with(ctx, fn);
|
|
162
|
+
}
|
|
163
|
+
const prev = _activeContext;
|
|
164
|
+
_activeContext = ctx;
|
|
165
|
+
try {
|
|
166
|
+
const result = fn();
|
|
167
|
+
if (result && typeof result.finally === "function") {
|
|
168
|
+
return result.finally(() => {
|
|
169
|
+
_activeContext = prev;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
_activeContext = prev;
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
_activeContext = prev;
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
setGlobalContextManager(_mgr) {
|
|
181
|
+
// no-op in shim; real SDK sets this via the real OTel API
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
// ---------------------------------------------------------------------------
|
|
185
|
+
// Trace API (simplified subset used by core)
|
|
186
|
+
// ---------------------------------------------------------------------------
|
|
187
|
+
export const trace = {
|
|
188
|
+
getTracer(name, version) {
|
|
189
|
+
return _provider.getTracer(name, version);
|
|
190
|
+
},
|
|
191
|
+
setGlobalTracerProvider(p) {
|
|
192
|
+
_provider = p;
|
|
193
|
+
_providerRevision++;
|
|
194
|
+
},
|
|
195
|
+
getGlobalTracerProvider() {
|
|
196
|
+
return _provider;
|
|
197
|
+
},
|
|
198
|
+
setSpan(ctx, _span) {
|
|
199
|
+
try {
|
|
200
|
+
const spanContext = _span.spanContext();
|
|
201
|
+
if (spanContext.traceId === EMPTY_TRACE_ID || spanContext.spanId === EMPTY_SPAN_ID) {
|
|
202
|
+
return ctx;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
// Keep structural test doubles usable even when they omit spanContext().
|
|
207
|
+
}
|
|
208
|
+
if (_activeSpanAccessor?.setSpan) {
|
|
209
|
+
return _activeSpanAccessor.setSpan(ctx, _span);
|
|
210
|
+
}
|
|
211
|
+
return ctx.setValue(ACTIVE_SPAN_CONTEXT_KEY, _span);
|
|
212
|
+
},
|
|
213
|
+
getSpan(ctx) {
|
|
214
|
+
return _activeSpanAccessor?.getSpan(ctx) ??
|
|
215
|
+
ctx.getValue(ACTIVE_SPAN_CONTEXT_KEY);
|
|
216
|
+
},
|
|
217
|
+
getActiveSpan() {
|
|
218
|
+
return _activeSpanAccessor?.getActiveSpan() ?? trace.getSpan(context.active());
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
// ---------------------------------------------------------------------------
|
|
222
|
+
// Propagation API
|
|
223
|
+
// ---------------------------------------------------------------------------
|
|
224
|
+
export const propagation = {
|
|
225
|
+
setGlobalPropagator(p) {
|
|
226
|
+
_propagator = p;
|
|
227
|
+
},
|
|
228
|
+
extract(ctx, carrier, getter) {
|
|
229
|
+
if (!_propagator)
|
|
230
|
+
return ctx;
|
|
231
|
+
return _propagator.extract(ctx, carrier, getter);
|
|
232
|
+
},
|
|
233
|
+
inject(ctx, carrier, setter) {
|
|
234
|
+
if (!_propagator)
|
|
235
|
+
return;
|
|
236
|
+
_propagator.inject(ctx, carrier, setter);
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
// ---------------------------------------------------------------------------
|
|
240
|
+
// defaultTextMapGetter / defaultTextMapSetter (used by proxy/tracing.ts)
|
|
241
|
+
// ---------------------------------------------------------------------------
|
|
242
|
+
export const defaultTextMapGetter = {
|
|
243
|
+
keys(carrier) {
|
|
244
|
+
return Object.keys(carrier);
|
|
245
|
+
},
|
|
246
|
+
get(carrier, key) {
|
|
247
|
+
return carrier[key];
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
export const defaultTextMapSetter = {
|
|
251
|
+
set(carrier, key, value) {
|
|
252
|
+
carrier[key] = value;
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
// ---------------------------------------------------------------------------
|
|
256
|
+
// Metrics API registry (injected by ext-observability-opentelemetry when active)
|
|
257
|
+
// ---------------------------------------------------------------------------
|
|
258
|
+
let _metricsApi = null;
|
|
259
|
+
/**
|
|
260
|
+
* Register the OTel Metrics API (from the SDK).
|
|
261
|
+
* Called by ext-observability-opentelemetry in its setup hook so the metrics subsystem
|
|
262
|
+
* can use `getMeter()` when available.
|
|
263
|
+
*/
|
|
264
|
+
export function setGlobalMetricsAPI(api) {
|
|
265
|
+
_metricsApi = api;
|
|
266
|
+
}
|
|
267
|
+
export function getGlobalMetricsAPI() {
|
|
268
|
+
return _metricsApi;
|
|
269
|
+
}
|
|
270
|
+
// ---------------------------------------------------------------------------
|
|
271
|
+
// Reset for tests
|
|
272
|
+
// ---------------------------------------------------------------------------
|
|
273
|
+
export function _resetShimForTests() {
|
|
274
|
+
_provider = createNoopProvider();
|
|
275
|
+
_providerRevision++;
|
|
276
|
+
_activeContext = NOOP_CONTEXT;
|
|
277
|
+
_propagator = null;
|
|
278
|
+
_contextAccessor = null;
|
|
279
|
+
_metricsApi = null;
|
|
280
|
+
_activeSpanAccessor = null;
|
|
281
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**************************
|
|
2
|
+
* OpenTelemetry OTLP Setup
|
|
3
|
+
*
|
|
4
|
+
* Thin wrapper that delegates to the `ext-observability-opentelemetry` extension via the
|
|
5
|
+
* `TracingExporter` contract. When the extension is not installed, all span
|
|
6
|
+
* operations silently no-op.
|
|
7
|
+
*
|
|
8
|
+
* Reads configuration from environment variables:
|
|
9
|
+
* - OTEL_TRACES_ENABLED: "true" to enable tracing
|
|
10
|
+
* - OTEL_SERVICE_NAME: Service name for traces
|
|
11
|
+
* - OTEL_EXPORTER_OTLP_ENDPOINT: OTLP endpoint
|
|
12
|
+
* - OTEL_EXPORTER_OTLP_HEADERS: Auth headers
|
|
13
|
+
**************************/
|
|
14
|
+
import { type AttributeValue, type Context, type Span, SpanKind } from "./api-shim.js";
|
|
15
|
+
/** Configuration used by otlpconfig. */
|
|
16
|
+
export interface OTLPConfig {
|
|
17
|
+
serviceName: string;
|
|
18
|
+
endpoint: string;
|
|
19
|
+
headers?: Record<string, string>;
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Initialize OTLP tracing export. */
|
|
23
|
+
export declare function initializeOTLP(): Promise<void>;
|
|
24
|
+
/** Shut down OTLP tracing export. */
|
|
25
|
+
export declare function shutdownOTLP(): Promise<void>;
|
|
26
|
+
/** Check whether OTLP export is enabled. */
|
|
27
|
+
export declare function isOTLPEnabled(): boolean;
|
|
28
|
+
/** Initialize OTLP tracing with explicit API adapters. */
|
|
29
|
+
export declare function initializeOTLPWithApis(): Promise<void>;
|
|
30
|
+
export type WithSpanOptions = {
|
|
31
|
+
kind?: SpanKind;
|
|
32
|
+
};
|
|
33
|
+
/** Applies span. */
|
|
34
|
+
export declare function withSpan<T>(name: string, fn: (span: Span) => Promise<T>, attributes?: Record<string, AttributeValue>, options?: WithSpanOptions): Promise<T>;
|
|
35
|
+
/** Applies span sync. */
|
|
36
|
+
export declare function withSpanSync<T>(name: string, fn: () => T, attributes?: Record<string, AttributeValue>, options?: WithSpanOptions): T;
|
|
37
|
+
/** Context for extract. */
|
|
38
|
+
export declare function extractContext(headers: Headers): Context | undefined;
|
|
39
|
+
/** Context for inject. */
|
|
40
|
+
export declare function injectContext(headers: Headers): void;
|
|
41
|
+
/** Starts server span. */
|
|
42
|
+
export declare function startServerSpan(method: string, path: string, parentContext?: unknown): {
|
|
43
|
+
span: Span;
|
|
44
|
+
context: Context;
|
|
45
|
+
} | null;
|
|
46
|
+
/** End an active server tracing span. */
|
|
47
|
+
export declare function endServerSpan(span: unknown, statusCode: number, error?: Error): void;
|
|
48
|
+
/** Sets span attributes. */
|
|
49
|
+
export declare function setSpanAttributes(span: unknown, attributes: Record<string, AttributeValue>): void;
|
|
50
|
+
/** Adds an event to a span. */
|
|
51
|
+
export declare function addSpanEvent(span: unknown, name: string, attributes?: Record<string, AttributeValue>): void;
|
|
52
|
+
/** Sets active span attributes. */
|
|
53
|
+
export declare function setActiveSpanAttributes(attributes: Record<string, AttributeValue>): void;
|
|
54
|
+
/** Marks the active span as failed. */
|
|
55
|
+
export declare function setActiveSpanErrorStatus(error: unknown): void;
|
|
56
|
+
/** Context for with. */
|
|
57
|
+
export declare function withContext<T>(spanContext: unknown, fn: () => Promise<T>): Promise<T>;
|
|
58
|
+
/** Context for get trace. */
|
|
59
|
+
export declare function getTraceContext(): {
|
|
60
|
+
traceId?: string;
|
|
61
|
+
spanId?: string;
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=otlp-setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otlp-setup.d.ts","sourceRoot":"","sources":["../../../../src/src/observability/tracing/otlp-setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;4BAY4B;AAI5B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