braintrust 0.1.0 → 0.2.0
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/dev/dist/index.d.mts +156 -0
- package/dev/dist/index.d.ts +156 -0
- package/dev/dist/index.js +16 -9
- package/dev/dist/index.mjs +16 -9
- package/dist/browser.d.mts +514 -0
- package/dist/browser.d.ts +514 -0
- package/dist/chunk-CDBUTZMH.js +1713 -0
- package/dist/chunk-NB5AEJPK.mjs +19 -0
- package/dist/chunk-VKR7HDRS.js +19 -0
- package/dist/chunk-WKBXJQ57.mjs +1713 -0
- package/dist/cli.js +23 -14
- package/dist/getMachineId-bsd-7YM2UMB4.js +37 -0
- package/dist/getMachineId-bsd-L7QQYES7.mjs +37 -0
- package/dist/getMachineId-darwin-QV3NVG7H.js +37 -0
- package/dist/getMachineId-darwin-YXDFFCXM.mjs +37 -0
- package/dist/getMachineId-linux-HKJ2YLJC.js +29 -0
- package/dist/getMachineId-linux-LWEEVKPU.mjs +29 -0
- package/dist/getMachineId-unsupported-EGJSIDYQ.mjs +20 -0
- package/dist/getMachineId-unsupported-TX34Q66M.js +20 -0
- package/dist/getMachineId-win-M5YW2KGK.js +39 -0
- package/dist/getMachineId-win-UDA4B6X2.mjs +39 -0
- package/dist/index.d.mts +905 -27
- package/dist/index.d.ts +905 -27
- package/dist/index.js +3664 -237
- package/dist/index.mjs +3460 -33
- package/package.json +7 -5
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,3197 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
INVALID_SPAN_CONTEXT,
|
|
3
|
+
SamplingDecision,
|
|
4
|
+
SpanKind,
|
|
5
|
+
SpanStatusCode,
|
|
6
|
+
TraceFlags,
|
|
7
|
+
__esm,
|
|
8
|
+
__export,
|
|
9
|
+
__toCommonJS,
|
|
10
|
+
baggageEntryMetadataFromString,
|
|
11
|
+
context,
|
|
12
|
+
createContextKey,
|
|
13
|
+
diag,
|
|
14
|
+
esm_exports,
|
|
15
|
+
init_esm,
|
|
16
|
+
isSpanContextValid,
|
|
17
|
+
isValidTraceId,
|
|
18
|
+
trace
|
|
19
|
+
} from "./chunk-WKBXJQ57.mjs";
|
|
20
|
+
|
|
21
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.js
|
|
22
|
+
function suppressTracing(context2) {
|
|
23
|
+
return context2.setValue(SUPPRESS_TRACING_KEY, true);
|
|
24
|
+
}
|
|
25
|
+
function isTracingSuppressed(context2) {
|
|
26
|
+
return context2.getValue(SUPPRESS_TRACING_KEY) === true;
|
|
27
|
+
}
|
|
28
|
+
var SUPPRESS_TRACING_KEY;
|
|
29
|
+
var init_suppress_tracing = __esm({
|
|
30
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.js"() {
|
|
31
|
+
"use strict";
|
|
32
|
+
init_esm();
|
|
33
|
+
SUPPRESS_TRACING_KEY = createContextKey("OpenTelemetry SDK Context Key SUPPRESS_TRACING");
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/attributes.js
|
|
38
|
+
function sanitizeAttributes(attributes) {
|
|
39
|
+
const out = {};
|
|
40
|
+
if (typeof attributes !== "object" || attributes == null) {
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
for (const [key, val] of Object.entries(attributes)) {
|
|
44
|
+
if (!isAttributeKey(key)) {
|
|
45
|
+
diag.warn(`Invalid attribute key: ${key}`);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (!isAttributeValue(val)) {
|
|
49
|
+
diag.warn(`Invalid attribute value set for key: ${key}`);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (Array.isArray(val)) {
|
|
53
|
+
out[key] = val.slice();
|
|
54
|
+
} else {
|
|
55
|
+
out[key] = val;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
function isAttributeKey(key) {
|
|
61
|
+
return typeof key === "string" && key.length > 0;
|
|
62
|
+
}
|
|
63
|
+
function isAttributeValue(val) {
|
|
64
|
+
if (val == null) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
if (Array.isArray(val)) {
|
|
68
|
+
return isHomogeneousAttributeValueArray(val);
|
|
69
|
+
}
|
|
70
|
+
return isValidPrimitiveAttributeValue(val);
|
|
71
|
+
}
|
|
72
|
+
function isHomogeneousAttributeValueArray(arr) {
|
|
73
|
+
let type;
|
|
74
|
+
for (const element of arr) {
|
|
75
|
+
if (element == null)
|
|
76
|
+
continue;
|
|
77
|
+
if (!type) {
|
|
78
|
+
if (isValidPrimitiveAttributeValue(element)) {
|
|
79
|
+
type = typeof element;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
if (typeof element === type) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
function isValidPrimitiveAttributeValue(val) {
|
|
92
|
+
switch (typeof val) {
|
|
93
|
+
case "number":
|
|
94
|
+
case "boolean":
|
|
95
|
+
case "string":
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
var init_attributes = __esm({
|
|
101
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/attributes.js"() {
|
|
102
|
+
"use strict";
|
|
103
|
+
init_esm();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.js
|
|
108
|
+
function loggingErrorHandler() {
|
|
109
|
+
return (ex) => {
|
|
110
|
+
diag.error(stringifyException(ex));
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function stringifyException(ex) {
|
|
114
|
+
if (typeof ex === "string") {
|
|
115
|
+
return ex;
|
|
116
|
+
} else {
|
|
117
|
+
return JSON.stringify(flattenException(ex));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function flattenException(ex) {
|
|
121
|
+
const result = {};
|
|
122
|
+
let current = ex;
|
|
123
|
+
while (current !== null) {
|
|
124
|
+
Object.getOwnPropertyNames(current).forEach((propertyName) => {
|
|
125
|
+
if (result[propertyName])
|
|
126
|
+
return;
|
|
127
|
+
const value = current[propertyName];
|
|
128
|
+
if (value) {
|
|
129
|
+
result[propertyName] = String(value);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
current = Object.getPrototypeOf(current);
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
var init_logging_error_handler = __esm({
|
|
137
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/logging-error-handler.js"() {
|
|
138
|
+
"use strict";
|
|
139
|
+
init_esm();
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/global-error-handler.js
|
|
144
|
+
function globalErrorHandler(ex) {
|
|
145
|
+
try {
|
|
146
|
+
delegateHandler(ex);
|
|
147
|
+
} catch {
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
var delegateHandler;
|
|
151
|
+
var init_global_error_handler = __esm({
|
|
152
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/global-error-handler.js"() {
|
|
153
|
+
"use strict";
|
|
154
|
+
init_logging_error_handler();
|
|
155
|
+
delegateHandler = loggingErrorHandler();
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/environment.js
|
|
160
|
+
import { inspect } from "util";
|
|
161
|
+
function getNumberFromEnv(key) {
|
|
162
|
+
const raw = process.env[key];
|
|
163
|
+
if (raw == null || raw.trim() === "") {
|
|
164
|
+
return void 0;
|
|
165
|
+
}
|
|
166
|
+
const value = Number(raw);
|
|
167
|
+
if (isNaN(value)) {
|
|
168
|
+
diag.warn(`Unknown value ${inspect(raw)} for ${key}, expected a number, using defaults`);
|
|
169
|
+
return void 0;
|
|
170
|
+
}
|
|
171
|
+
return value;
|
|
172
|
+
}
|
|
173
|
+
function getStringFromEnv(key) {
|
|
174
|
+
const raw = process.env[key];
|
|
175
|
+
if (raw == null || raw.trim() === "") {
|
|
176
|
+
return void 0;
|
|
177
|
+
}
|
|
178
|
+
return raw;
|
|
179
|
+
}
|
|
180
|
+
var init_environment = __esm({
|
|
181
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/environment.js"() {
|
|
182
|
+
"use strict";
|
|
183
|
+
init_esm();
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/performance.js
|
|
188
|
+
import { performance } from "perf_hooks";
|
|
189
|
+
var otperformance;
|
|
190
|
+
var init_performance = __esm({
|
|
191
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/performance.js"() {
|
|
192
|
+
"use strict";
|
|
193
|
+
otperformance = performance;
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/version.js
|
|
198
|
+
var VERSION;
|
|
199
|
+
var init_version = __esm({
|
|
200
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/version.js"() {
|
|
201
|
+
"use strict";
|
|
202
|
+
VERSION = "2.0.1";
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js
|
|
207
|
+
var init_SemanticAttributes = __esm({
|
|
208
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/SemanticAttributes.js"() {
|
|
209
|
+
"use strict";
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js
|
|
214
|
+
var init_trace = __esm({
|
|
215
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/trace/index.js"() {
|
|
216
|
+
"use strict";
|
|
217
|
+
init_SemanticAttributes();
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js
|
|
222
|
+
var init_SemanticResourceAttributes = __esm({
|
|
223
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js"() {
|
|
224
|
+
"use strict";
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js
|
|
229
|
+
var init_resource = __esm({
|
|
230
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/resource/index.js"() {
|
|
231
|
+
"use strict";
|
|
232
|
+
init_SemanticResourceAttributes();
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js
|
|
237
|
+
var ATTR_EXCEPTION_MESSAGE, ATTR_EXCEPTION_STACKTRACE, ATTR_EXCEPTION_TYPE, ATTR_SERVICE_NAME, ATTR_TELEMETRY_SDK_LANGUAGE, TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS, ATTR_TELEMETRY_SDK_NAME, ATTR_TELEMETRY_SDK_VERSION;
|
|
238
|
+
var init_stable_attributes = __esm({
|
|
239
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js"() {
|
|
240
|
+
"use strict";
|
|
241
|
+
ATTR_EXCEPTION_MESSAGE = "exception.message";
|
|
242
|
+
ATTR_EXCEPTION_STACKTRACE = "exception.stacktrace";
|
|
243
|
+
ATTR_EXCEPTION_TYPE = "exception.type";
|
|
244
|
+
ATTR_SERVICE_NAME = "service.name";
|
|
245
|
+
ATTR_TELEMETRY_SDK_LANGUAGE = "telemetry.sdk.language";
|
|
246
|
+
TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS = "nodejs";
|
|
247
|
+
ATTR_TELEMETRY_SDK_NAME = "telemetry.sdk.name";
|
|
248
|
+
ATTR_TELEMETRY_SDK_VERSION = "telemetry.sdk.version";
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.js
|
|
253
|
+
var init_stable_metrics = __esm({
|
|
254
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_metrics.js"() {
|
|
255
|
+
"use strict";
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js
|
|
260
|
+
var init_esm2 = __esm({
|
|
261
|
+
"../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.32.0/node_modules/@opentelemetry/semantic-conventions/build/esm/index.js"() {
|
|
262
|
+
"use strict";
|
|
263
|
+
init_trace();
|
|
264
|
+
init_resource();
|
|
265
|
+
init_stable_attributes();
|
|
266
|
+
init_stable_metrics();
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/semconv.js
|
|
271
|
+
var ATTR_PROCESS_RUNTIME_NAME;
|
|
272
|
+
var init_semconv = __esm({
|
|
273
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/semconv.js"() {
|
|
274
|
+
"use strict";
|
|
275
|
+
ATTR_PROCESS_RUNTIME_NAME = "process.runtime.name";
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js
|
|
280
|
+
var SDK_INFO;
|
|
281
|
+
var init_sdk_info = __esm({
|
|
282
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/sdk-info.js"() {
|
|
283
|
+
"use strict";
|
|
284
|
+
init_version();
|
|
285
|
+
init_esm2();
|
|
286
|
+
init_semconv();
|
|
287
|
+
SDK_INFO = {
|
|
288
|
+
[ATTR_TELEMETRY_SDK_NAME]: "opentelemetry",
|
|
289
|
+
[ATTR_PROCESS_RUNTIME_NAME]: "node",
|
|
290
|
+
[ATTR_TELEMETRY_SDK_LANGUAGE]: TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS,
|
|
291
|
+
[ATTR_TELEMETRY_SDK_VERSION]: VERSION
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/timer-util.js
|
|
297
|
+
function unrefTimer(timer) {
|
|
298
|
+
timer.unref();
|
|
299
|
+
}
|
|
300
|
+
var init_timer_util = __esm({
|
|
301
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/timer-util.js"() {
|
|
302
|
+
"use strict";
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/index.js
|
|
307
|
+
var init_node = __esm({
|
|
308
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/node/index.js"() {
|
|
309
|
+
"use strict";
|
|
310
|
+
init_environment();
|
|
311
|
+
init_performance();
|
|
312
|
+
init_sdk_info();
|
|
313
|
+
init_timer_util();
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/index.js
|
|
318
|
+
var init_platform = __esm({
|
|
319
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/platform/index.js"() {
|
|
320
|
+
"use strict";
|
|
321
|
+
init_node();
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/time.js
|
|
326
|
+
function millisToHrTime(epochMillis) {
|
|
327
|
+
const epochSeconds = epochMillis / 1e3;
|
|
328
|
+
const seconds = Math.trunc(epochSeconds);
|
|
329
|
+
const nanos = Math.round(epochMillis % 1e3 * MILLISECONDS_TO_NANOSECONDS);
|
|
330
|
+
return [seconds, nanos];
|
|
331
|
+
}
|
|
332
|
+
function getTimeOrigin() {
|
|
333
|
+
let timeOrigin = otperformance.timeOrigin;
|
|
334
|
+
if (typeof timeOrigin !== "number") {
|
|
335
|
+
const perf = otperformance;
|
|
336
|
+
timeOrigin = perf.timing && perf.timing.fetchStart;
|
|
337
|
+
}
|
|
338
|
+
return timeOrigin;
|
|
339
|
+
}
|
|
340
|
+
function hrTime(performanceNow) {
|
|
341
|
+
const timeOrigin = millisToHrTime(getTimeOrigin());
|
|
342
|
+
const now2 = millisToHrTime(typeof performanceNow === "number" ? performanceNow : otperformance.now());
|
|
343
|
+
return addHrTimes(timeOrigin, now2);
|
|
344
|
+
}
|
|
345
|
+
function hrTimeDuration(startTime, endTime) {
|
|
346
|
+
let seconds = endTime[0] - startTime[0];
|
|
347
|
+
let nanos = endTime[1] - startTime[1];
|
|
348
|
+
if (nanos < 0) {
|
|
349
|
+
seconds -= 1;
|
|
350
|
+
nanos += SECOND_TO_NANOSECONDS;
|
|
351
|
+
}
|
|
352
|
+
return [seconds, nanos];
|
|
353
|
+
}
|
|
354
|
+
function hrTimeToMicroseconds(time) {
|
|
355
|
+
return time[0] * 1e6 + time[1] / 1e3;
|
|
356
|
+
}
|
|
357
|
+
function isTimeInputHrTime(value) {
|
|
358
|
+
return Array.isArray(value) && value.length === 2 && typeof value[0] === "number" && typeof value[1] === "number";
|
|
359
|
+
}
|
|
360
|
+
function isTimeInput(value) {
|
|
361
|
+
return isTimeInputHrTime(value) || typeof value === "number" || value instanceof Date;
|
|
362
|
+
}
|
|
363
|
+
function addHrTimes(time1, time2) {
|
|
364
|
+
const out = [time1[0] + time2[0], time1[1] + time2[1]];
|
|
365
|
+
if (out[1] >= SECOND_TO_NANOSECONDS) {
|
|
366
|
+
out[1] -= SECOND_TO_NANOSECONDS;
|
|
367
|
+
out[0] += 1;
|
|
368
|
+
}
|
|
369
|
+
return out;
|
|
370
|
+
}
|
|
371
|
+
var NANOSECOND_DIGITS, NANOSECOND_DIGITS_IN_MILLIS, MILLISECONDS_TO_NANOSECONDS, SECOND_TO_NANOSECONDS;
|
|
372
|
+
var init_time = __esm({
|
|
373
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/time.js"() {
|
|
374
|
+
"use strict";
|
|
375
|
+
init_platform();
|
|
376
|
+
NANOSECOND_DIGITS = 9;
|
|
377
|
+
NANOSECOND_DIGITS_IN_MILLIS = 6;
|
|
378
|
+
MILLISECONDS_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS_IN_MILLIS);
|
|
379
|
+
SECOND_TO_NANOSECONDS = Math.pow(10, NANOSECOND_DIGITS);
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/ExportResult.js
|
|
384
|
+
var ExportResultCode;
|
|
385
|
+
var init_ExportResult = __esm({
|
|
386
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/ExportResult.js"() {
|
|
387
|
+
"use strict";
|
|
388
|
+
(function(ExportResultCode3) {
|
|
389
|
+
ExportResultCode3[ExportResultCode3["SUCCESS"] = 0] = "SUCCESS";
|
|
390
|
+
ExportResultCode3[ExportResultCode3["FAILED"] = 1] = "FAILED";
|
|
391
|
+
})(ExportResultCode || (ExportResultCode = {}));
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/lodash.merge.js
|
|
396
|
+
function isPlainObject(value) {
|
|
397
|
+
if (!isObjectLike(value) || baseGetTag(value) !== objectTag) {
|
|
398
|
+
return false;
|
|
399
|
+
}
|
|
400
|
+
const proto = getPrototypeOf(value);
|
|
401
|
+
if (proto === null) {
|
|
402
|
+
return true;
|
|
403
|
+
}
|
|
404
|
+
const Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
405
|
+
return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) === objectCtorString;
|
|
406
|
+
}
|
|
407
|
+
function isObjectLike(value) {
|
|
408
|
+
return value != null && typeof value == "object";
|
|
409
|
+
}
|
|
410
|
+
function baseGetTag(value) {
|
|
411
|
+
if (value == null) {
|
|
412
|
+
return value === void 0 ? undefinedTag : nullTag;
|
|
413
|
+
}
|
|
414
|
+
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
415
|
+
}
|
|
416
|
+
function getRawTag(value) {
|
|
417
|
+
const isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
|
|
418
|
+
let unmasked = false;
|
|
419
|
+
try {
|
|
420
|
+
value[symToStringTag] = void 0;
|
|
421
|
+
unmasked = true;
|
|
422
|
+
} catch (e) {
|
|
423
|
+
}
|
|
424
|
+
const result = nativeObjectToString.call(value);
|
|
425
|
+
if (unmasked) {
|
|
426
|
+
if (isOwn) {
|
|
427
|
+
value[symToStringTag] = tag;
|
|
428
|
+
} else {
|
|
429
|
+
delete value[symToStringTag];
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return result;
|
|
433
|
+
}
|
|
434
|
+
function objectToString(value) {
|
|
435
|
+
return nativeObjectToString.call(value);
|
|
436
|
+
}
|
|
437
|
+
var objectTag, nullTag, undefinedTag, funcProto, funcToString, objectCtorString, getPrototypeOf, objectProto, hasOwnProperty, symToStringTag, nativeObjectToString;
|
|
438
|
+
var init_lodash_merge = __esm({
|
|
439
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/lodash.merge.js"() {
|
|
440
|
+
"use strict";
|
|
441
|
+
objectTag = "[object Object]";
|
|
442
|
+
nullTag = "[object Null]";
|
|
443
|
+
undefinedTag = "[object Undefined]";
|
|
444
|
+
funcProto = Function.prototype;
|
|
445
|
+
funcToString = funcProto.toString;
|
|
446
|
+
objectCtorString = funcToString.call(Object);
|
|
447
|
+
getPrototypeOf = Object.getPrototypeOf;
|
|
448
|
+
objectProto = Object.prototype;
|
|
449
|
+
hasOwnProperty = objectProto.hasOwnProperty;
|
|
450
|
+
symToStringTag = Symbol ? Symbol.toStringTag : void 0;
|
|
451
|
+
nativeObjectToString = objectProto.toString;
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/merge.js
|
|
456
|
+
function merge(...args) {
|
|
457
|
+
let result = args.shift();
|
|
458
|
+
const objects = /* @__PURE__ */ new WeakMap();
|
|
459
|
+
while (args.length > 0) {
|
|
460
|
+
result = mergeTwoObjects(result, args.shift(), 0, objects);
|
|
461
|
+
}
|
|
462
|
+
return result;
|
|
463
|
+
}
|
|
464
|
+
function takeValue(value) {
|
|
465
|
+
if (isArray2(value)) {
|
|
466
|
+
return value.slice();
|
|
467
|
+
}
|
|
468
|
+
return value;
|
|
469
|
+
}
|
|
470
|
+
function mergeTwoObjects(one, two, level = 0, objects) {
|
|
471
|
+
let result;
|
|
472
|
+
if (level > MAX_LEVEL) {
|
|
473
|
+
return void 0;
|
|
474
|
+
}
|
|
475
|
+
level++;
|
|
476
|
+
if (isPrimitive(one) || isPrimitive(two) || isFunction(two)) {
|
|
477
|
+
result = takeValue(two);
|
|
478
|
+
} else if (isArray2(one)) {
|
|
479
|
+
result = one.slice();
|
|
480
|
+
if (isArray2(two)) {
|
|
481
|
+
for (let i = 0, j = two.length; i < j; i++) {
|
|
482
|
+
result.push(takeValue(two[i]));
|
|
483
|
+
}
|
|
484
|
+
} else if (isObject2(two)) {
|
|
485
|
+
const keys = Object.keys(two);
|
|
486
|
+
for (let i = 0, j = keys.length; i < j; i++) {
|
|
487
|
+
const key = keys[i];
|
|
488
|
+
result[key] = takeValue(two[key]);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
} else if (isObject2(one)) {
|
|
492
|
+
if (isObject2(two)) {
|
|
493
|
+
if (!shouldMerge(one, two)) {
|
|
494
|
+
return two;
|
|
495
|
+
}
|
|
496
|
+
result = Object.assign({}, one);
|
|
497
|
+
const keys = Object.keys(two);
|
|
498
|
+
for (let i = 0, j = keys.length; i < j; i++) {
|
|
499
|
+
const key = keys[i];
|
|
500
|
+
const twoValue = two[key];
|
|
501
|
+
if (isPrimitive(twoValue)) {
|
|
502
|
+
if (typeof twoValue === "undefined") {
|
|
503
|
+
delete result[key];
|
|
504
|
+
} else {
|
|
505
|
+
result[key] = twoValue;
|
|
506
|
+
}
|
|
507
|
+
} else {
|
|
508
|
+
const obj1 = result[key];
|
|
509
|
+
const obj2 = twoValue;
|
|
510
|
+
if (wasObjectReferenced(one, key, objects) || wasObjectReferenced(two, key, objects)) {
|
|
511
|
+
delete result[key];
|
|
512
|
+
} else {
|
|
513
|
+
if (isObject2(obj1) && isObject2(obj2)) {
|
|
514
|
+
const arr1 = objects.get(obj1) || [];
|
|
515
|
+
const arr2 = objects.get(obj2) || [];
|
|
516
|
+
arr1.push({ obj: one, key });
|
|
517
|
+
arr2.push({ obj: two, key });
|
|
518
|
+
objects.set(obj1, arr1);
|
|
519
|
+
objects.set(obj2, arr2);
|
|
520
|
+
}
|
|
521
|
+
result[key] = mergeTwoObjects(result[key], twoValue, level, objects);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
} else {
|
|
526
|
+
result = two;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return result;
|
|
530
|
+
}
|
|
531
|
+
function wasObjectReferenced(obj, key, objects) {
|
|
532
|
+
const arr = objects.get(obj[key]) || [];
|
|
533
|
+
for (let i = 0, j = arr.length; i < j; i++) {
|
|
534
|
+
const info = arr[i];
|
|
535
|
+
if (info.key === key && info.obj === obj) {
|
|
536
|
+
return true;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return false;
|
|
540
|
+
}
|
|
541
|
+
function isArray2(value) {
|
|
542
|
+
return Array.isArray(value);
|
|
543
|
+
}
|
|
544
|
+
function isFunction(value) {
|
|
545
|
+
return typeof value === "function";
|
|
546
|
+
}
|
|
547
|
+
function isObject2(value) {
|
|
548
|
+
return !isPrimitive(value) && !isArray2(value) && !isFunction(value) && typeof value === "object";
|
|
549
|
+
}
|
|
550
|
+
function isPrimitive(value) {
|
|
551
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "undefined" || value instanceof Date || value instanceof RegExp || value === null;
|
|
552
|
+
}
|
|
553
|
+
function shouldMerge(one, two) {
|
|
554
|
+
if (!isPlainObject(one) || !isPlainObject(two)) {
|
|
555
|
+
return false;
|
|
556
|
+
}
|
|
557
|
+
return true;
|
|
558
|
+
}
|
|
559
|
+
var MAX_LEVEL;
|
|
560
|
+
var init_merge = __esm({
|
|
561
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/merge.js"() {
|
|
562
|
+
"use strict";
|
|
563
|
+
init_lodash_merge();
|
|
564
|
+
MAX_LEVEL = 20;
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/promise.js
|
|
569
|
+
var Deferred;
|
|
570
|
+
var init_promise = __esm({
|
|
571
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/promise.js"() {
|
|
572
|
+
"use strict";
|
|
573
|
+
Deferred = class {
|
|
574
|
+
_promise;
|
|
575
|
+
_resolve;
|
|
576
|
+
_reject;
|
|
577
|
+
constructor() {
|
|
578
|
+
this._promise = new Promise((resolve, reject2) => {
|
|
579
|
+
this._resolve = resolve;
|
|
580
|
+
this._reject = reject2;
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
get promise() {
|
|
584
|
+
return this._promise;
|
|
585
|
+
}
|
|
586
|
+
resolve(val) {
|
|
587
|
+
this._resolve(val);
|
|
588
|
+
}
|
|
589
|
+
reject(err) {
|
|
590
|
+
this._reject(err);
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/callback.js
|
|
597
|
+
var BindOnceFuture;
|
|
598
|
+
var init_callback = __esm({
|
|
599
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/utils/callback.js"() {
|
|
600
|
+
"use strict";
|
|
601
|
+
init_promise();
|
|
602
|
+
BindOnceFuture = class {
|
|
603
|
+
_callback;
|
|
604
|
+
_that;
|
|
605
|
+
_isCalled = false;
|
|
606
|
+
_deferred = new Deferred();
|
|
607
|
+
constructor(_callback, _that) {
|
|
608
|
+
this._callback = _callback;
|
|
609
|
+
this._that = _that;
|
|
610
|
+
}
|
|
611
|
+
get isCalled() {
|
|
612
|
+
return this._isCalled;
|
|
613
|
+
}
|
|
614
|
+
get promise() {
|
|
615
|
+
return this._deferred.promise;
|
|
616
|
+
}
|
|
617
|
+
call(...args) {
|
|
618
|
+
if (!this._isCalled) {
|
|
619
|
+
this._isCalled = true;
|
|
620
|
+
try {
|
|
621
|
+
Promise.resolve(this._callback.call(this._that, ...args)).then((val) => this._deferred.resolve(val), (err) => this._deferred.reject(err));
|
|
622
|
+
} catch (err) {
|
|
623
|
+
this._deferred.reject(err);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return this._deferred.promise;
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/internal/exporter.js
|
|
633
|
+
function _export(exporter, arg) {
|
|
634
|
+
return new Promise((resolve) => {
|
|
635
|
+
context.with(suppressTracing(context.active()), () => {
|
|
636
|
+
exporter.export(arg, (result) => {
|
|
637
|
+
resolve(result);
|
|
638
|
+
});
|
|
639
|
+
});
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
var init_exporter = __esm({
|
|
643
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/internal/exporter.js"() {
|
|
644
|
+
"use strict";
|
|
645
|
+
init_esm();
|
|
646
|
+
init_suppress_tracing();
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/index.js
|
|
651
|
+
var internal;
|
|
652
|
+
var init_esm3 = __esm({
|
|
653
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/index.js"() {
|
|
654
|
+
"use strict";
|
|
655
|
+
init_attributes();
|
|
656
|
+
init_global_error_handler();
|
|
657
|
+
init_time();
|
|
658
|
+
init_ExportResult();
|
|
659
|
+
init_platform();
|
|
660
|
+
init_suppress_tracing();
|
|
661
|
+
init_merge();
|
|
662
|
+
init_callback();
|
|
663
|
+
init_exporter();
|
|
664
|
+
internal = {
|
|
665
|
+
_export
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
// ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/platform/node/default-service-name.js
|
|
671
|
+
function defaultServiceName() {
|
|
672
|
+
return `unknown_service:${process.argv0}`;
|
|
673
|
+
}
|
|
674
|
+
var init_default_service_name = __esm({
|
|
675
|
+
"../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/platform/node/default-service-name.js"() {
|
|
676
|
+
"use strict";
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
// ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/platform/node/index.js
|
|
681
|
+
var init_node2 = __esm({
|
|
682
|
+
"../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/platform/node/index.js"() {
|
|
683
|
+
"use strict";
|
|
684
|
+
init_default_service_name();
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
// ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/platform/index.js
|
|
689
|
+
var init_platform2 = __esm({
|
|
690
|
+
"../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/platform/index.js"() {
|
|
691
|
+
"use strict";
|
|
692
|
+
init_node2();
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
// ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/utils.js
|
|
697
|
+
var isPromiseLike;
|
|
698
|
+
var init_utils = __esm({
|
|
699
|
+
"../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/utils.js"() {
|
|
700
|
+
"use strict";
|
|
701
|
+
isPromiseLike = (val) => {
|
|
702
|
+
return val !== null && typeof val === "object" && typeof val.then === "function";
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
// ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/ResourceImpl.js
|
|
708
|
+
function resourceFromAttributes(attributes) {
|
|
709
|
+
return ResourceImpl.FromAttributeList(Object.entries(attributes));
|
|
710
|
+
}
|
|
711
|
+
function defaultResource() {
|
|
712
|
+
return resourceFromAttributes({
|
|
713
|
+
[ATTR_SERVICE_NAME]: defaultServiceName(),
|
|
714
|
+
[ATTR_TELEMETRY_SDK_LANGUAGE]: SDK_INFO[ATTR_TELEMETRY_SDK_LANGUAGE],
|
|
715
|
+
[ATTR_TELEMETRY_SDK_NAME]: SDK_INFO[ATTR_TELEMETRY_SDK_NAME],
|
|
716
|
+
[ATTR_TELEMETRY_SDK_VERSION]: SDK_INFO[ATTR_TELEMETRY_SDK_VERSION]
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
function guardedRawAttributes(attributes) {
|
|
720
|
+
return attributes.map(([k, v]) => {
|
|
721
|
+
if (isPromiseLike(v)) {
|
|
722
|
+
return [
|
|
723
|
+
k,
|
|
724
|
+
v.catch((err) => {
|
|
725
|
+
diag.debug("promise rejection for resource attribute: %s - %s", k, err);
|
|
726
|
+
return void 0;
|
|
727
|
+
})
|
|
728
|
+
];
|
|
729
|
+
}
|
|
730
|
+
return [k, v];
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
var ResourceImpl;
|
|
734
|
+
var init_ResourceImpl = __esm({
|
|
735
|
+
"../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/ResourceImpl.js"() {
|
|
736
|
+
"use strict";
|
|
737
|
+
init_esm();
|
|
738
|
+
init_esm3();
|
|
739
|
+
init_esm2();
|
|
740
|
+
init_platform2();
|
|
741
|
+
init_utils();
|
|
742
|
+
ResourceImpl = class _ResourceImpl {
|
|
743
|
+
_rawAttributes;
|
|
744
|
+
_asyncAttributesPending = false;
|
|
745
|
+
_memoizedAttributes;
|
|
746
|
+
static FromAttributeList(attributes) {
|
|
747
|
+
const res = new _ResourceImpl({});
|
|
748
|
+
res._rawAttributes = guardedRawAttributes(attributes);
|
|
749
|
+
res._asyncAttributesPending = attributes.filter(([_, val]) => isPromiseLike(val)).length > 0;
|
|
750
|
+
return res;
|
|
751
|
+
}
|
|
752
|
+
constructor(resource) {
|
|
753
|
+
const attributes = resource.attributes ?? {};
|
|
754
|
+
this._rawAttributes = Object.entries(attributes).map(([k, v]) => {
|
|
755
|
+
if (isPromiseLike(v)) {
|
|
756
|
+
this._asyncAttributesPending = true;
|
|
757
|
+
}
|
|
758
|
+
return [k, v];
|
|
759
|
+
});
|
|
760
|
+
this._rawAttributes = guardedRawAttributes(this._rawAttributes);
|
|
761
|
+
}
|
|
762
|
+
get asyncAttributesPending() {
|
|
763
|
+
return this._asyncAttributesPending;
|
|
764
|
+
}
|
|
765
|
+
async waitForAsyncAttributes() {
|
|
766
|
+
if (!this.asyncAttributesPending) {
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
for (let i = 0; i < this._rawAttributes.length; i++) {
|
|
770
|
+
const [k, v] = this._rawAttributes[i];
|
|
771
|
+
this._rawAttributes[i] = [k, isPromiseLike(v) ? await v : v];
|
|
772
|
+
}
|
|
773
|
+
this._asyncAttributesPending = false;
|
|
774
|
+
}
|
|
775
|
+
get attributes() {
|
|
776
|
+
if (this.asyncAttributesPending) {
|
|
777
|
+
diag.error("Accessing resource attributes before async attributes settled");
|
|
778
|
+
}
|
|
779
|
+
if (this._memoizedAttributes) {
|
|
780
|
+
return this._memoizedAttributes;
|
|
781
|
+
}
|
|
782
|
+
const attrs = {};
|
|
783
|
+
for (const [k, v] of this._rawAttributes) {
|
|
784
|
+
if (isPromiseLike(v)) {
|
|
785
|
+
diag.debug(`Unsettled resource attribute ${k} skipped`);
|
|
786
|
+
continue;
|
|
787
|
+
}
|
|
788
|
+
if (v != null) {
|
|
789
|
+
attrs[k] ??= v;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
if (!this._asyncAttributesPending) {
|
|
793
|
+
this._memoizedAttributes = attrs;
|
|
794
|
+
}
|
|
795
|
+
return attrs;
|
|
796
|
+
}
|
|
797
|
+
getRawAttributes() {
|
|
798
|
+
return this._rawAttributes;
|
|
799
|
+
}
|
|
800
|
+
merge(resource) {
|
|
801
|
+
if (resource == null)
|
|
802
|
+
return this;
|
|
803
|
+
return _ResourceImpl.FromAttributeList([
|
|
804
|
+
...resource.getRawAttributes(),
|
|
805
|
+
...this.getRawAttributes()
|
|
806
|
+
]);
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
});
|
|
811
|
+
|
|
812
|
+
// ../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/index.js
|
|
813
|
+
var init_esm4 = __esm({
|
|
814
|
+
"../../node_modules/.pnpm/@opentelemetry+resources@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/index.js"() {
|
|
815
|
+
"use strict";
|
|
816
|
+
init_ResourceImpl();
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/enums.js
|
|
821
|
+
var ExceptionEventName;
|
|
822
|
+
var init_enums = __esm({
|
|
823
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/enums.js"() {
|
|
824
|
+
"use strict";
|
|
825
|
+
ExceptionEventName = "exception";
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/Span.js
|
|
830
|
+
var SpanImpl2;
|
|
831
|
+
var init_Span = __esm({
|
|
832
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/Span.js"() {
|
|
833
|
+
"use strict";
|
|
834
|
+
init_esm();
|
|
835
|
+
init_esm3();
|
|
836
|
+
init_esm2();
|
|
837
|
+
init_enums();
|
|
838
|
+
SpanImpl2 = class {
|
|
839
|
+
// Below properties are included to implement ReadableSpan for export
|
|
840
|
+
// purposes but are not intended to be written-to directly.
|
|
841
|
+
_spanContext;
|
|
842
|
+
kind;
|
|
843
|
+
parentSpanContext;
|
|
844
|
+
attributes = {};
|
|
845
|
+
links = [];
|
|
846
|
+
events = [];
|
|
847
|
+
startTime;
|
|
848
|
+
resource;
|
|
849
|
+
instrumentationScope;
|
|
850
|
+
_droppedAttributesCount = 0;
|
|
851
|
+
_droppedEventsCount = 0;
|
|
852
|
+
_droppedLinksCount = 0;
|
|
853
|
+
name;
|
|
854
|
+
status = {
|
|
855
|
+
code: SpanStatusCode.UNSET
|
|
856
|
+
};
|
|
857
|
+
endTime = [0, 0];
|
|
858
|
+
_ended = false;
|
|
859
|
+
_duration = [-1, -1];
|
|
860
|
+
_spanProcessor;
|
|
861
|
+
_spanLimits;
|
|
862
|
+
_attributeValueLengthLimit;
|
|
863
|
+
_performanceStartTime;
|
|
864
|
+
_performanceOffset;
|
|
865
|
+
_startTimeProvided;
|
|
866
|
+
/**
|
|
867
|
+
* Constructs a new SpanImpl instance.
|
|
868
|
+
*/
|
|
869
|
+
constructor(opts) {
|
|
870
|
+
const now2 = Date.now();
|
|
871
|
+
this._spanContext = opts.spanContext;
|
|
872
|
+
this._performanceStartTime = otperformance.now();
|
|
873
|
+
this._performanceOffset = now2 - (this._performanceStartTime + getTimeOrigin());
|
|
874
|
+
this._startTimeProvided = opts.startTime != null;
|
|
875
|
+
this._spanLimits = opts.spanLimits;
|
|
876
|
+
this._attributeValueLengthLimit = this._spanLimits.attributeValueLengthLimit || 0;
|
|
877
|
+
this._spanProcessor = opts.spanProcessor;
|
|
878
|
+
this.name = opts.name;
|
|
879
|
+
this.parentSpanContext = opts.parentSpanContext;
|
|
880
|
+
this.kind = opts.kind;
|
|
881
|
+
this.links = opts.links || [];
|
|
882
|
+
this.startTime = this._getTime(opts.startTime ?? now2);
|
|
883
|
+
this.resource = opts.resource;
|
|
884
|
+
this.instrumentationScope = opts.scope;
|
|
885
|
+
if (opts.attributes != null) {
|
|
886
|
+
this.setAttributes(opts.attributes);
|
|
887
|
+
}
|
|
888
|
+
this._spanProcessor.onStart(this, opts.context);
|
|
889
|
+
}
|
|
890
|
+
spanContext() {
|
|
891
|
+
return this._spanContext;
|
|
892
|
+
}
|
|
893
|
+
setAttribute(key, value) {
|
|
894
|
+
if (value == null || this._isSpanEnded())
|
|
895
|
+
return this;
|
|
896
|
+
if (key.length === 0) {
|
|
897
|
+
diag.warn(`Invalid attribute key: ${key}`);
|
|
898
|
+
return this;
|
|
899
|
+
}
|
|
900
|
+
if (!isAttributeValue(value)) {
|
|
901
|
+
diag.warn(`Invalid attribute value set for key: ${key}`);
|
|
902
|
+
return this;
|
|
903
|
+
}
|
|
904
|
+
const { attributeCountLimit } = this._spanLimits;
|
|
905
|
+
if (attributeCountLimit !== void 0 && Object.keys(this.attributes).length >= attributeCountLimit && !Object.prototype.hasOwnProperty.call(this.attributes, key)) {
|
|
906
|
+
this._droppedAttributesCount++;
|
|
907
|
+
return this;
|
|
908
|
+
}
|
|
909
|
+
this.attributes[key] = this._truncateToSize(value);
|
|
910
|
+
return this;
|
|
911
|
+
}
|
|
912
|
+
setAttributes(attributes) {
|
|
913
|
+
for (const [k, v] of Object.entries(attributes)) {
|
|
914
|
+
this.setAttribute(k, v);
|
|
915
|
+
}
|
|
916
|
+
return this;
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
*
|
|
920
|
+
* @param name Span Name
|
|
921
|
+
* @param [attributesOrStartTime] Span attributes or start time
|
|
922
|
+
* if type is {@type TimeInput} and 3rd param is undefined
|
|
923
|
+
* @param [timeStamp] Specified time stamp for the event
|
|
924
|
+
*/
|
|
925
|
+
addEvent(name, attributesOrStartTime, timeStamp) {
|
|
926
|
+
if (this._isSpanEnded())
|
|
927
|
+
return this;
|
|
928
|
+
const { eventCountLimit } = this._spanLimits;
|
|
929
|
+
if (eventCountLimit === 0) {
|
|
930
|
+
diag.warn("No events allowed.");
|
|
931
|
+
this._droppedEventsCount++;
|
|
932
|
+
return this;
|
|
933
|
+
}
|
|
934
|
+
if (eventCountLimit !== void 0 && this.events.length >= eventCountLimit) {
|
|
935
|
+
if (this._droppedEventsCount === 0) {
|
|
936
|
+
diag.debug("Dropping extra events.");
|
|
937
|
+
}
|
|
938
|
+
this.events.shift();
|
|
939
|
+
this._droppedEventsCount++;
|
|
940
|
+
}
|
|
941
|
+
if (isTimeInput(attributesOrStartTime)) {
|
|
942
|
+
if (!isTimeInput(timeStamp)) {
|
|
943
|
+
timeStamp = attributesOrStartTime;
|
|
944
|
+
}
|
|
945
|
+
attributesOrStartTime = void 0;
|
|
946
|
+
}
|
|
947
|
+
const attributes = sanitizeAttributes(attributesOrStartTime);
|
|
948
|
+
this.events.push({
|
|
949
|
+
name,
|
|
950
|
+
attributes,
|
|
951
|
+
time: this._getTime(timeStamp),
|
|
952
|
+
droppedAttributesCount: 0
|
|
953
|
+
});
|
|
954
|
+
return this;
|
|
955
|
+
}
|
|
956
|
+
addLink(link) {
|
|
957
|
+
this.links.push(link);
|
|
958
|
+
return this;
|
|
959
|
+
}
|
|
960
|
+
addLinks(links) {
|
|
961
|
+
this.links.push(...links);
|
|
962
|
+
return this;
|
|
963
|
+
}
|
|
964
|
+
setStatus(status) {
|
|
965
|
+
if (this._isSpanEnded())
|
|
966
|
+
return this;
|
|
967
|
+
this.status = { ...status };
|
|
968
|
+
if (this.status.message != null && typeof status.message !== "string") {
|
|
969
|
+
diag.warn(`Dropping invalid status.message of type '${typeof status.message}', expected 'string'`);
|
|
970
|
+
delete this.status.message;
|
|
971
|
+
}
|
|
972
|
+
return this;
|
|
973
|
+
}
|
|
974
|
+
updateName(name) {
|
|
975
|
+
if (this._isSpanEnded())
|
|
976
|
+
return this;
|
|
977
|
+
this.name = name;
|
|
978
|
+
return this;
|
|
979
|
+
}
|
|
980
|
+
end(endTime) {
|
|
981
|
+
if (this._isSpanEnded()) {
|
|
982
|
+
diag.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
this._ended = true;
|
|
986
|
+
this.endTime = this._getTime(endTime);
|
|
987
|
+
this._duration = hrTimeDuration(this.startTime, this.endTime);
|
|
988
|
+
if (this._duration[0] < 0) {
|
|
989
|
+
diag.warn("Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.", this.startTime, this.endTime);
|
|
990
|
+
this.endTime = this.startTime.slice();
|
|
991
|
+
this._duration = [0, 0];
|
|
992
|
+
}
|
|
993
|
+
if (this._droppedEventsCount > 0) {
|
|
994
|
+
diag.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`);
|
|
995
|
+
}
|
|
996
|
+
this._spanProcessor.onEnd(this);
|
|
997
|
+
}
|
|
998
|
+
_getTime(inp) {
|
|
999
|
+
if (typeof inp === "number" && inp <= otperformance.now()) {
|
|
1000
|
+
return hrTime(inp + this._performanceOffset);
|
|
1001
|
+
}
|
|
1002
|
+
if (typeof inp === "number") {
|
|
1003
|
+
return millisToHrTime(inp);
|
|
1004
|
+
}
|
|
1005
|
+
if (inp instanceof Date) {
|
|
1006
|
+
return millisToHrTime(inp.getTime());
|
|
1007
|
+
}
|
|
1008
|
+
if (isTimeInputHrTime(inp)) {
|
|
1009
|
+
return inp;
|
|
1010
|
+
}
|
|
1011
|
+
if (this._startTimeProvided) {
|
|
1012
|
+
return millisToHrTime(Date.now());
|
|
1013
|
+
}
|
|
1014
|
+
const msDuration = otperformance.now() - this._performanceStartTime;
|
|
1015
|
+
return addHrTimes(this.startTime, millisToHrTime(msDuration));
|
|
1016
|
+
}
|
|
1017
|
+
isRecording() {
|
|
1018
|
+
return this._ended === false;
|
|
1019
|
+
}
|
|
1020
|
+
recordException(exception, time) {
|
|
1021
|
+
const attributes = {};
|
|
1022
|
+
if (typeof exception === "string") {
|
|
1023
|
+
attributes[ATTR_EXCEPTION_MESSAGE] = exception;
|
|
1024
|
+
} else if (exception) {
|
|
1025
|
+
if (exception.code) {
|
|
1026
|
+
attributes[ATTR_EXCEPTION_TYPE] = exception.code.toString();
|
|
1027
|
+
} else if (exception.name) {
|
|
1028
|
+
attributes[ATTR_EXCEPTION_TYPE] = exception.name;
|
|
1029
|
+
}
|
|
1030
|
+
if (exception.message) {
|
|
1031
|
+
attributes[ATTR_EXCEPTION_MESSAGE] = exception.message;
|
|
1032
|
+
}
|
|
1033
|
+
if (exception.stack) {
|
|
1034
|
+
attributes[ATTR_EXCEPTION_STACKTRACE] = exception.stack;
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
if (attributes[ATTR_EXCEPTION_TYPE] || attributes[ATTR_EXCEPTION_MESSAGE]) {
|
|
1038
|
+
this.addEvent(ExceptionEventName, attributes, time);
|
|
1039
|
+
} else {
|
|
1040
|
+
diag.warn(`Failed to record an exception ${exception}`);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
get duration() {
|
|
1044
|
+
return this._duration;
|
|
1045
|
+
}
|
|
1046
|
+
get ended() {
|
|
1047
|
+
return this._ended;
|
|
1048
|
+
}
|
|
1049
|
+
get droppedAttributesCount() {
|
|
1050
|
+
return this._droppedAttributesCount;
|
|
1051
|
+
}
|
|
1052
|
+
get droppedEventsCount() {
|
|
1053
|
+
return this._droppedEventsCount;
|
|
1054
|
+
}
|
|
1055
|
+
get droppedLinksCount() {
|
|
1056
|
+
return this._droppedLinksCount;
|
|
1057
|
+
}
|
|
1058
|
+
_isSpanEnded() {
|
|
1059
|
+
if (this._ended) {
|
|
1060
|
+
const error2 = new Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);
|
|
1061
|
+
diag.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`, error2);
|
|
1062
|
+
}
|
|
1063
|
+
return this._ended;
|
|
1064
|
+
}
|
|
1065
|
+
// Utility function to truncate given value within size
|
|
1066
|
+
// for value type of string, will truncate to given limit
|
|
1067
|
+
// for type of non-string, will return same value
|
|
1068
|
+
_truncateToLimitUtil(value, limit) {
|
|
1069
|
+
if (value.length <= limit) {
|
|
1070
|
+
return value;
|
|
1071
|
+
}
|
|
1072
|
+
return value.substring(0, limit);
|
|
1073
|
+
}
|
|
1074
|
+
/**
|
|
1075
|
+
* If the given attribute value is of type string and has more characters than given {@code attributeValueLengthLimit} then
|
|
1076
|
+
* return string with truncated to {@code attributeValueLengthLimit} characters
|
|
1077
|
+
*
|
|
1078
|
+
* If the given attribute value is array of strings then
|
|
1079
|
+
* return new array of strings with each element truncated to {@code attributeValueLengthLimit} characters
|
|
1080
|
+
*
|
|
1081
|
+
* Otherwise return same Attribute {@code value}
|
|
1082
|
+
*
|
|
1083
|
+
* @param value Attribute value
|
|
1084
|
+
* @returns truncated attribute value if required, otherwise same value
|
|
1085
|
+
*/
|
|
1086
|
+
_truncateToSize(value) {
|
|
1087
|
+
const limit = this._attributeValueLengthLimit;
|
|
1088
|
+
if (limit <= 0) {
|
|
1089
|
+
diag.warn(`Attribute value limit must be positive, got ${limit}`);
|
|
1090
|
+
return value;
|
|
1091
|
+
}
|
|
1092
|
+
if (typeof value === "string") {
|
|
1093
|
+
return this._truncateToLimitUtil(value, limit);
|
|
1094
|
+
}
|
|
1095
|
+
if (Array.isArray(value)) {
|
|
1096
|
+
return value.map((val) => typeof val === "string" ? this._truncateToLimitUtil(val, limit) : val);
|
|
1097
|
+
}
|
|
1098
|
+
return value;
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
|
|
1104
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/Sampler.js
|
|
1105
|
+
var SamplingDecision2;
|
|
1106
|
+
var init_Sampler = __esm({
|
|
1107
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/Sampler.js"() {
|
|
1108
|
+
"use strict";
|
|
1109
|
+
(function(SamplingDecision3) {
|
|
1110
|
+
SamplingDecision3[SamplingDecision3["NOT_RECORD"] = 0] = "NOT_RECORD";
|
|
1111
|
+
SamplingDecision3[SamplingDecision3["RECORD"] = 1] = "RECORD";
|
|
1112
|
+
SamplingDecision3[SamplingDecision3["RECORD_AND_SAMPLED"] = 2] = "RECORD_AND_SAMPLED";
|
|
1113
|
+
})(SamplingDecision2 || (SamplingDecision2 = {}));
|
|
1114
|
+
}
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1117
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOffSampler.js
|
|
1118
|
+
var AlwaysOffSampler;
|
|
1119
|
+
var init_AlwaysOffSampler = __esm({
|
|
1120
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOffSampler.js"() {
|
|
1121
|
+
"use strict";
|
|
1122
|
+
init_Sampler();
|
|
1123
|
+
AlwaysOffSampler = class {
|
|
1124
|
+
shouldSample() {
|
|
1125
|
+
return {
|
|
1126
|
+
decision: SamplingDecision2.NOT_RECORD
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
toString() {
|
|
1130
|
+
return "AlwaysOffSampler";
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
});
|
|
1135
|
+
|
|
1136
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOnSampler.js
|
|
1137
|
+
var AlwaysOnSampler;
|
|
1138
|
+
var init_AlwaysOnSampler = __esm({
|
|
1139
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/AlwaysOnSampler.js"() {
|
|
1140
|
+
"use strict";
|
|
1141
|
+
init_Sampler();
|
|
1142
|
+
AlwaysOnSampler = class {
|
|
1143
|
+
shouldSample() {
|
|
1144
|
+
return {
|
|
1145
|
+
decision: SamplingDecision2.RECORD_AND_SAMPLED
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
toString() {
|
|
1149
|
+
return "AlwaysOnSampler";
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
});
|
|
1154
|
+
|
|
1155
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/ParentBasedSampler.js
|
|
1156
|
+
var ParentBasedSampler;
|
|
1157
|
+
var init_ParentBasedSampler = __esm({
|
|
1158
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/ParentBasedSampler.js"() {
|
|
1159
|
+
"use strict";
|
|
1160
|
+
init_esm();
|
|
1161
|
+
init_esm3();
|
|
1162
|
+
init_AlwaysOffSampler();
|
|
1163
|
+
init_AlwaysOnSampler();
|
|
1164
|
+
ParentBasedSampler = class {
|
|
1165
|
+
_root;
|
|
1166
|
+
_remoteParentSampled;
|
|
1167
|
+
_remoteParentNotSampled;
|
|
1168
|
+
_localParentSampled;
|
|
1169
|
+
_localParentNotSampled;
|
|
1170
|
+
constructor(config) {
|
|
1171
|
+
this._root = config.root;
|
|
1172
|
+
if (!this._root) {
|
|
1173
|
+
globalErrorHandler(new Error("ParentBasedSampler must have a root sampler configured"));
|
|
1174
|
+
this._root = new AlwaysOnSampler();
|
|
1175
|
+
}
|
|
1176
|
+
this._remoteParentSampled = config.remoteParentSampled ?? new AlwaysOnSampler();
|
|
1177
|
+
this._remoteParentNotSampled = config.remoteParentNotSampled ?? new AlwaysOffSampler();
|
|
1178
|
+
this._localParentSampled = config.localParentSampled ?? new AlwaysOnSampler();
|
|
1179
|
+
this._localParentNotSampled = config.localParentNotSampled ?? new AlwaysOffSampler();
|
|
1180
|
+
}
|
|
1181
|
+
shouldSample(context2, traceId, spanName, spanKind, attributes, links) {
|
|
1182
|
+
const parentContext = trace.getSpanContext(context2);
|
|
1183
|
+
if (!parentContext || !isSpanContextValid(parentContext)) {
|
|
1184
|
+
return this._root.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
|
|
1185
|
+
}
|
|
1186
|
+
if (parentContext.isRemote) {
|
|
1187
|
+
if (parentContext.traceFlags & TraceFlags.SAMPLED) {
|
|
1188
|
+
return this._remoteParentSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
|
|
1189
|
+
}
|
|
1190
|
+
return this._remoteParentNotSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
|
|
1191
|
+
}
|
|
1192
|
+
if (parentContext.traceFlags & TraceFlags.SAMPLED) {
|
|
1193
|
+
return this._localParentSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
|
|
1194
|
+
}
|
|
1195
|
+
return this._localParentNotSampled.shouldSample(context2, traceId, spanName, spanKind, attributes, links);
|
|
1196
|
+
}
|
|
1197
|
+
toString() {
|
|
1198
|
+
return `ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`;
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
});
|
|
1203
|
+
|
|
1204
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/TraceIdRatioBasedSampler.js
|
|
1205
|
+
var TraceIdRatioBasedSampler;
|
|
1206
|
+
var init_TraceIdRatioBasedSampler = __esm({
|
|
1207
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/sampler/TraceIdRatioBasedSampler.js"() {
|
|
1208
|
+
"use strict";
|
|
1209
|
+
init_esm();
|
|
1210
|
+
init_Sampler();
|
|
1211
|
+
TraceIdRatioBasedSampler = class {
|
|
1212
|
+
_ratio;
|
|
1213
|
+
_upperBound;
|
|
1214
|
+
constructor(_ratio = 0) {
|
|
1215
|
+
this._ratio = _ratio;
|
|
1216
|
+
this._ratio = this._normalize(_ratio);
|
|
1217
|
+
this._upperBound = Math.floor(this._ratio * 4294967295);
|
|
1218
|
+
}
|
|
1219
|
+
shouldSample(context2, traceId) {
|
|
1220
|
+
return {
|
|
1221
|
+
decision: isValidTraceId(traceId) && this._accumulate(traceId) < this._upperBound ? SamplingDecision2.RECORD_AND_SAMPLED : SamplingDecision2.NOT_RECORD
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
toString() {
|
|
1225
|
+
return `TraceIdRatioBased{${this._ratio}}`;
|
|
1226
|
+
}
|
|
1227
|
+
_normalize(ratio) {
|
|
1228
|
+
if (typeof ratio !== "number" || isNaN(ratio))
|
|
1229
|
+
return 0;
|
|
1230
|
+
return ratio >= 1 ? 1 : ratio <= 0 ? 0 : ratio;
|
|
1231
|
+
}
|
|
1232
|
+
_accumulate(traceId) {
|
|
1233
|
+
let accumulation = 0;
|
|
1234
|
+
for (let i = 0; i < traceId.length / 8; i++) {
|
|
1235
|
+
const pos = i * 8;
|
|
1236
|
+
const part = parseInt(traceId.slice(pos, pos + 8), 16);
|
|
1237
|
+
accumulation = (accumulation ^ part) >>> 0;
|
|
1238
|
+
}
|
|
1239
|
+
return accumulation;
|
|
1240
|
+
}
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
});
|
|
1244
|
+
|
|
1245
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/config.js
|
|
1246
|
+
function loadDefaultConfig() {
|
|
1247
|
+
return {
|
|
1248
|
+
sampler: buildSamplerFromEnv(),
|
|
1249
|
+
forceFlushTimeoutMillis: 3e4,
|
|
1250
|
+
generalLimits: {
|
|
1251
|
+
attributeValueLengthLimit: getNumberFromEnv("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT") ?? Infinity,
|
|
1252
|
+
attributeCountLimit: getNumberFromEnv("OTEL_ATTRIBUTE_COUNT_LIMIT") ?? 128
|
|
1253
|
+
},
|
|
1254
|
+
spanLimits: {
|
|
1255
|
+
attributeValueLengthLimit: getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT") ?? Infinity,
|
|
1256
|
+
attributeCountLimit: getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT") ?? 128,
|
|
1257
|
+
linkCountLimit: getNumberFromEnv("OTEL_SPAN_LINK_COUNT_LIMIT") ?? 128,
|
|
1258
|
+
eventCountLimit: getNumberFromEnv("OTEL_SPAN_EVENT_COUNT_LIMIT") ?? 128,
|
|
1259
|
+
attributePerEventCountLimit: getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT") ?? 128,
|
|
1260
|
+
attributePerLinkCountLimit: getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT") ?? 128
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
function buildSamplerFromEnv() {
|
|
1265
|
+
const sampler = getStringFromEnv("OTEL_TRACES_SAMPLER") ?? "parentbased_always_on";
|
|
1266
|
+
switch (sampler) {
|
|
1267
|
+
case "always_on":
|
|
1268
|
+
return new AlwaysOnSampler();
|
|
1269
|
+
case "always_off":
|
|
1270
|
+
return new AlwaysOffSampler();
|
|
1271
|
+
case "parentbased_always_on":
|
|
1272
|
+
return new ParentBasedSampler({
|
|
1273
|
+
root: new AlwaysOnSampler()
|
|
1274
|
+
});
|
|
1275
|
+
case "parentbased_always_off":
|
|
1276
|
+
return new ParentBasedSampler({
|
|
1277
|
+
root: new AlwaysOffSampler()
|
|
1278
|
+
});
|
|
1279
|
+
case "traceidratio":
|
|
1280
|
+
return new TraceIdRatioBasedSampler(getSamplerProbabilityFromEnv());
|
|
1281
|
+
case "parentbased_traceidratio":
|
|
1282
|
+
return new ParentBasedSampler({
|
|
1283
|
+
root: new TraceIdRatioBasedSampler(getSamplerProbabilityFromEnv())
|
|
1284
|
+
});
|
|
1285
|
+
default:
|
|
1286
|
+
diag.error(`OTEL_TRACES_SAMPLER value "${sampler}" invalid, defaulting to "${"parentbased_always_on"}".`);
|
|
1287
|
+
return new ParentBasedSampler({
|
|
1288
|
+
root: new AlwaysOnSampler()
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
function getSamplerProbabilityFromEnv() {
|
|
1293
|
+
const probability = getNumberFromEnv("OTEL_TRACES_SAMPLER_ARG");
|
|
1294
|
+
if (probability == null) {
|
|
1295
|
+
diag.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${DEFAULT_RATIO}.`);
|
|
1296
|
+
return DEFAULT_RATIO;
|
|
1297
|
+
}
|
|
1298
|
+
if (probability < 0 || probability > 1) {
|
|
1299
|
+
diag.error(`OTEL_TRACES_SAMPLER_ARG=${probability} was given, but it is out of range ([0..1]), defaulting to ${DEFAULT_RATIO}.`);
|
|
1300
|
+
return DEFAULT_RATIO;
|
|
1301
|
+
}
|
|
1302
|
+
return probability;
|
|
1303
|
+
}
|
|
1304
|
+
var DEFAULT_RATIO;
|
|
1305
|
+
var init_config = __esm({
|
|
1306
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/config.js"() {
|
|
1307
|
+
"use strict";
|
|
1308
|
+
init_esm();
|
|
1309
|
+
init_esm3();
|
|
1310
|
+
init_AlwaysOffSampler();
|
|
1311
|
+
init_AlwaysOnSampler();
|
|
1312
|
+
init_ParentBasedSampler();
|
|
1313
|
+
init_TraceIdRatioBasedSampler();
|
|
1314
|
+
DEFAULT_RATIO = 1;
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
|
|
1318
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/utility.js
|
|
1319
|
+
function mergeConfig(userConfig) {
|
|
1320
|
+
const perInstanceDefaults = {
|
|
1321
|
+
sampler: buildSamplerFromEnv()
|
|
1322
|
+
};
|
|
1323
|
+
const DEFAULT_CONFIG = loadDefaultConfig();
|
|
1324
|
+
const target = Object.assign({}, DEFAULT_CONFIG, perInstanceDefaults, userConfig);
|
|
1325
|
+
target.generalLimits = Object.assign({}, DEFAULT_CONFIG.generalLimits, userConfig.generalLimits || {});
|
|
1326
|
+
target.spanLimits = Object.assign({}, DEFAULT_CONFIG.spanLimits, userConfig.spanLimits || {});
|
|
1327
|
+
return target;
|
|
1328
|
+
}
|
|
1329
|
+
function reconfigureLimits(userConfig) {
|
|
1330
|
+
const spanLimits = Object.assign({}, userConfig.spanLimits);
|
|
1331
|
+
spanLimits.attributeCountLimit = userConfig.spanLimits?.attributeCountLimit ?? userConfig.generalLimits?.attributeCountLimit ?? getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT") ?? getNumberFromEnv("OTEL_ATTRIBUTE_COUNT_LIMIT") ?? DEFAULT_ATTRIBUTE_COUNT_LIMIT;
|
|
1332
|
+
spanLimits.attributeValueLengthLimit = userConfig.spanLimits?.attributeValueLengthLimit ?? userConfig.generalLimits?.attributeValueLengthLimit ?? getNumberFromEnv("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT") ?? getNumberFromEnv("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT") ?? DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT;
|
|
1333
|
+
return Object.assign({}, userConfig, { spanLimits });
|
|
1334
|
+
}
|
|
1335
|
+
var DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT;
|
|
1336
|
+
var init_utility = __esm({
|
|
1337
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/utility.js"() {
|
|
1338
|
+
"use strict";
|
|
1339
|
+
init_config();
|
|
1340
|
+
init_esm3();
|
|
1341
|
+
DEFAULT_ATTRIBUTE_COUNT_LIMIT = 128;
|
|
1342
|
+
DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT = Infinity;
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
|
|
1346
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/BatchSpanProcessorBase.js
|
|
1347
|
+
var BatchSpanProcessorBase;
|
|
1348
|
+
var init_BatchSpanProcessorBase = __esm({
|
|
1349
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/BatchSpanProcessorBase.js"() {
|
|
1350
|
+
"use strict";
|
|
1351
|
+
init_esm();
|
|
1352
|
+
init_esm3();
|
|
1353
|
+
BatchSpanProcessorBase = class {
|
|
1354
|
+
_exporter;
|
|
1355
|
+
_maxExportBatchSize;
|
|
1356
|
+
_maxQueueSize;
|
|
1357
|
+
_scheduledDelayMillis;
|
|
1358
|
+
_exportTimeoutMillis;
|
|
1359
|
+
_isExporting = false;
|
|
1360
|
+
_finishedSpans = [];
|
|
1361
|
+
_timer;
|
|
1362
|
+
_shutdownOnce;
|
|
1363
|
+
_droppedSpansCount = 0;
|
|
1364
|
+
constructor(_exporter, config) {
|
|
1365
|
+
this._exporter = _exporter;
|
|
1366
|
+
this._maxExportBatchSize = typeof config?.maxExportBatchSize === "number" ? config.maxExportBatchSize : getNumberFromEnv("OTEL_BSP_MAX_EXPORT_BATCH_SIZE") ?? 512;
|
|
1367
|
+
this._maxQueueSize = typeof config?.maxQueueSize === "number" ? config.maxQueueSize : getNumberFromEnv("OTEL_BSP_MAX_QUEUE_SIZE") ?? 2048;
|
|
1368
|
+
this._scheduledDelayMillis = typeof config?.scheduledDelayMillis === "number" ? config.scheduledDelayMillis : getNumberFromEnv("OTEL_BSP_SCHEDULE_DELAY") ?? 5e3;
|
|
1369
|
+
this._exportTimeoutMillis = typeof config?.exportTimeoutMillis === "number" ? config.exportTimeoutMillis : getNumberFromEnv("OTEL_BSP_EXPORT_TIMEOUT") ?? 3e4;
|
|
1370
|
+
this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
|
|
1371
|
+
if (this._maxExportBatchSize > this._maxQueueSize) {
|
|
1372
|
+
diag.warn("BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize");
|
|
1373
|
+
this._maxExportBatchSize = this._maxQueueSize;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
forceFlush() {
|
|
1377
|
+
if (this._shutdownOnce.isCalled) {
|
|
1378
|
+
return this._shutdownOnce.promise;
|
|
1379
|
+
}
|
|
1380
|
+
return this._flushAll();
|
|
1381
|
+
}
|
|
1382
|
+
// does nothing.
|
|
1383
|
+
onStart(_span, _parentContext) {
|
|
1384
|
+
}
|
|
1385
|
+
onEnd(span) {
|
|
1386
|
+
if (this._shutdownOnce.isCalled) {
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1389
|
+
if ((span.spanContext().traceFlags & TraceFlags.SAMPLED) === 0) {
|
|
1390
|
+
return;
|
|
1391
|
+
}
|
|
1392
|
+
this._addToBuffer(span);
|
|
1393
|
+
}
|
|
1394
|
+
shutdown() {
|
|
1395
|
+
return this._shutdownOnce.call();
|
|
1396
|
+
}
|
|
1397
|
+
_shutdown() {
|
|
1398
|
+
return Promise.resolve().then(() => {
|
|
1399
|
+
return this.onShutdown();
|
|
1400
|
+
}).then(() => {
|
|
1401
|
+
return this._flushAll();
|
|
1402
|
+
}).then(() => {
|
|
1403
|
+
return this._exporter.shutdown();
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
/** Add a span in the buffer. */
|
|
1407
|
+
_addToBuffer(span) {
|
|
1408
|
+
if (this._finishedSpans.length >= this._maxQueueSize) {
|
|
1409
|
+
if (this._droppedSpansCount === 0) {
|
|
1410
|
+
diag.debug("maxQueueSize reached, dropping spans");
|
|
1411
|
+
}
|
|
1412
|
+
this._droppedSpansCount++;
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
if (this._droppedSpansCount > 0) {
|
|
1416
|
+
diag.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`);
|
|
1417
|
+
this._droppedSpansCount = 0;
|
|
1418
|
+
}
|
|
1419
|
+
this._finishedSpans.push(span);
|
|
1420
|
+
this._maybeStartTimer();
|
|
1421
|
+
}
|
|
1422
|
+
/**
|
|
1423
|
+
* Send all spans to the exporter respecting the batch size limit
|
|
1424
|
+
* This function is used only on forceFlush or shutdown,
|
|
1425
|
+
* for all other cases _flush should be used
|
|
1426
|
+
* */
|
|
1427
|
+
_flushAll() {
|
|
1428
|
+
return new Promise((resolve, reject2) => {
|
|
1429
|
+
const promises = [];
|
|
1430
|
+
const count = Math.ceil(this._finishedSpans.length / this._maxExportBatchSize);
|
|
1431
|
+
for (let i = 0, j = count; i < j; i++) {
|
|
1432
|
+
promises.push(this._flushOneBatch());
|
|
1433
|
+
}
|
|
1434
|
+
Promise.all(promises).then(() => {
|
|
1435
|
+
resolve();
|
|
1436
|
+
}).catch(reject2);
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
_flushOneBatch() {
|
|
1440
|
+
this._clearTimer();
|
|
1441
|
+
if (this._finishedSpans.length === 0) {
|
|
1442
|
+
return Promise.resolve();
|
|
1443
|
+
}
|
|
1444
|
+
return new Promise((resolve, reject2) => {
|
|
1445
|
+
const timer = setTimeout(() => {
|
|
1446
|
+
reject2(new Error("Timeout"));
|
|
1447
|
+
}, this._exportTimeoutMillis);
|
|
1448
|
+
context.with(suppressTracing(context.active()), () => {
|
|
1449
|
+
let spans;
|
|
1450
|
+
if (this._finishedSpans.length <= this._maxExportBatchSize) {
|
|
1451
|
+
spans = this._finishedSpans;
|
|
1452
|
+
this._finishedSpans = [];
|
|
1453
|
+
} else {
|
|
1454
|
+
spans = this._finishedSpans.splice(0, this._maxExportBatchSize);
|
|
1455
|
+
}
|
|
1456
|
+
const doExport = () => this._exporter.export(spans, (result) => {
|
|
1457
|
+
clearTimeout(timer);
|
|
1458
|
+
if (result.code === ExportResultCode.SUCCESS) {
|
|
1459
|
+
resolve();
|
|
1460
|
+
} else {
|
|
1461
|
+
reject2(result.error ?? new Error("BatchSpanProcessor: span export failed"));
|
|
1462
|
+
}
|
|
1463
|
+
});
|
|
1464
|
+
let pendingResources = null;
|
|
1465
|
+
for (let i = 0, len = spans.length; i < len; i++) {
|
|
1466
|
+
const span = spans[i];
|
|
1467
|
+
if (span.resource.asyncAttributesPending && span.resource.waitForAsyncAttributes) {
|
|
1468
|
+
pendingResources ??= [];
|
|
1469
|
+
pendingResources.push(span.resource.waitForAsyncAttributes());
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
if (pendingResources === null) {
|
|
1473
|
+
doExport();
|
|
1474
|
+
} else {
|
|
1475
|
+
Promise.all(pendingResources).then(doExport, (err) => {
|
|
1476
|
+
globalErrorHandler(err);
|
|
1477
|
+
reject2(err);
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
});
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
_maybeStartTimer() {
|
|
1484
|
+
if (this._isExporting)
|
|
1485
|
+
return;
|
|
1486
|
+
const flush2 = () => {
|
|
1487
|
+
this._isExporting = true;
|
|
1488
|
+
this._flushOneBatch().finally(() => {
|
|
1489
|
+
this._isExporting = false;
|
|
1490
|
+
if (this._finishedSpans.length > 0) {
|
|
1491
|
+
this._clearTimer();
|
|
1492
|
+
this._maybeStartTimer();
|
|
1493
|
+
}
|
|
1494
|
+
}).catch((e) => {
|
|
1495
|
+
this._isExporting = false;
|
|
1496
|
+
globalErrorHandler(e);
|
|
1497
|
+
});
|
|
1498
|
+
};
|
|
1499
|
+
if (this._finishedSpans.length >= this._maxExportBatchSize) {
|
|
1500
|
+
return flush2();
|
|
1501
|
+
}
|
|
1502
|
+
if (this._timer !== void 0)
|
|
1503
|
+
return;
|
|
1504
|
+
this._timer = setTimeout(() => flush2(), this._scheduledDelayMillis);
|
|
1505
|
+
unrefTimer(this._timer);
|
|
1506
|
+
}
|
|
1507
|
+
_clearTimer() {
|
|
1508
|
+
if (this._timer !== void 0) {
|
|
1509
|
+
clearTimeout(this._timer);
|
|
1510
|
+
this._timer = void 0;
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
});
|
|
1516
|
+
|
|
1517
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/export/BatchSpanProcessor.js
|
|
1518
|
+
var BatchSpanProcessor;
|
|
1519
|
+
var init_BatchSpanProcessor = __esm({
|
|
1520
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/export/BatchSpanProcessor.js"() {
|
|
1521
|
+
"use strict";
|
|
1522
|
+
init_BatchSpanProcessorBase();
|
|
1523
|
+
BatchSpanProcessor = class extends BatchSpanProcessorBase {
|
|
1524
|
+
onShutdown() {
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
});
|
|
1529
|
+
|
|
1530
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/RandomIdGenerator.js
|
|
1531
|
+
function getIdGenerator(bytes) {
|
|
1532
|
+
return function generateId() {
|
|
1533
|
+
for (let i = 0; i < bytes / 4; i++) {
|
|
1534
|
+
SHARED_BUFFER.writeUInt32BE(Math.random() * 2 ** 32 >>> 0, i * 4);
|
|
1535
|
+
}
|
|
1536
|
+
for (let i = 0; i < bytes; i++) {
|
|
1537
|
+
if (SHARED_BUFFER[i] > 0) {
|
|
1538
|
+
break;
|
|
1539
|
+
} else if (i === bytes - 1) {
|
|
1540
|
+
SHARED_BUFFER[bytes - 1] = 1;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
return SHARED_BUFFER.toString("hex", 0, bytes);
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
var SPAN_ID_BYTES, TRACE_ID_BYTES, RandomIdGenerator, SHARED_BUFFER;
|
|
1547
|
+
var init_RandomIdGenerator = __esm({
|
|
1548
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/RandomIdGenerator.js"() {
|
|
1549
|
+
"use strict";
|
|
1550
|
+
SPAN_ID_BYTES = 8;
|
|
1551
|
+
TRACE_ID_BYTES = 16;
|
|
1552
|
+
RandomIdGenerator = class {
|
|
1553
|
+
/**
|
|
1554
|
+
* Returns a random 16-byte trace ID formatted/encoded as a 32 lowercase hex
|
|
1555
|
+
* characters corresponding to 128 bits.
|
|
1556
|
+
*/
|
|
1557
|
+
generateTraceId = getIdGenerator(TRACE_ID_BYTES);
|
|
1558
|
+
/**
|
|
1559
|
+
* Returns a random 8-byte span ID formatted/encoded as a 16 lowercase hex
|
|
1560
|
+
* characters corresponding to 64 bits.
|
|
1561
|
+
*/
|
|
1562
|
+
generateSpanId = getIdGenerator(SPAN_ID_BYTES);
|
|
1563
|
+
};
|
|
1564
|
+
SHARED_BUFFER = Buffer.allocUnsafe(TRACE_ID_BYTES);
|
|
1565
|
+
}
|
|
1566
|
+
});
|
|
1567
|
+
|
|
1568
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/index.js
|
|
1569
|
+
var init_node3 = __esm({
|
|
1570
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/node/index.js"() {
|
|
1571
|
+
"use strict";
|
|
1572
|
+
init_BatchSpanProcessor();
|
|
1573
|
+
init_RandomIdGenerator();
|
|
1574
|
+
}
|
|
1575
|
+
});
|
|
1576
|
+
|
|
1577
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/index.js
|
|
1578
|
+
var init_platform3 = __esm({
|
|
1579
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/index.js"() {
|
|
1580
|
+
"use strict";
|
|
1581
|
+
init_node3();
|
|
1582
|
+
}
|
|
1583
|
+
});
|
|
1584
|
+
|
|
1585
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/Tracer.js
|
|
1586
|
+
var Tracer;
|
|
1587
|
+
var init_Tracer = __esm({
|
|
1588
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/Tracer.js"() {
|
|
1589
|
+
"use strict";
|
|
1590
|
+
init_esm();
|
|
1591
|
+
init_esm3();
|
|
1592
|
+
init_Span();
|
|
1593
|
+
init_utility();
|
|
1594
|
+
init_platform3();
|
|
1595
|
+
Tracer = class {
|
|
1596
|
+
_sampler;
|
|
1597
|
+
_generalLimits;
|
|
1598
|
+
_spanLimits;
|
|
1599
|
+
_idGenerator;
|
|
1600
|
+
instrumentationScope;
|
|
1601
|
+
_resource;
|
|
1602
|
+
_spanProcessor;
|
|
1603
|
+
/**
|
|
1604
|
+
* Constructs a new Tracer instance.
|
|
1605
|
+
*/
|
|
1606
|
+
constructor(instrumentationScope, config, resource, spanProcessor) {
|
|
1607
|
+
const localConfig = mergeConfig(config);
|
|
1608
|
+
this._sampler = localConfig.sampler;
|
|
1609
|
+
this._generalLimits = localConfig.generalLimits;
|
|
1610
|
+
this._spanLimits = localConfig.spanLimits;
|
|
1611
|
+
this._idGenerator = config.idGenerator || new RandomIdGenerator();
|
|
1612
|
+
this._resource = resource;
|
|
1613
|
+
this._spanProcessor = spanProcessor;
|
|
1614
|
+
this.instrumentationScope = instrumentationScope;
|
|
1615
|
+
}
|
|
1616
|
+
/**
|
|
1617
|
+
* Starts a new Span or returns the default NoopSpan based on the sampling
|
|
1618
|
+
* decision.
|
|
1619
|
+
*/
|
|
1620
|
+
startSpan(name, options = {}, context2 = context.active()) {
|
|
1621
|
+
if (options.root) {
|
|
1622
|
+
context2 = trace.deleteSpan(context2);
|
|
1623
|
+
}
|
|
1624
|
+
const parentSpan = trace.getSpan(context2);
|
|
1625
|
+
if (isTracingSuppressed(context2)) {
|
|
1626
|
+
diag.debug("Instrumentation suppressed, returning Noop Span");
|
|
1627
|
+
const nonRecordingSpan = trace.wrapSpanContext(INVALID_SPAN_CONTEXT);
|
|
1628
|
+
return nonRecordingSpan;
|
|
1629
|
+
}
|
|
1630
|
+
const parentSpanContext = parentSpan?.spanContext();
|
|
1631
|
+
const spanId = this._idGenerator.generateSpanId();
|
|
1632
|
+
let validParentSpanContext;
|
|
1633
|
+
let traceId;
|
|
1634
|
+
let traceState;
|
|
1635
|
+
if (!parentSpanContext || !trace.isSpanContextValid(parentSpanContext)) {
|
|
1636
|
+
traceId = this._idGenerator.generateTraceId();
|
|
1637
|
+
} else {
|
|
1638
|
+
traceId = parentSpanContext.traceId;
|
|
1639
|
+
traceState = parentSpanContext.traceState;
|
|
1640
|
+
validParentSpanContext = parentSpanContext;
|
|
1641
|
+
}
|
|
1642
|
+
const spanKind = options.kind ?? SpanKind.INTERNAL;
|
|
1643
|
+
const links = (options.links ?? []).map((link) => {
|
|
1644
|
+
return {
|
|
1645
|
+
context: link.context,
|
|
1646
|
+
attributes: sanitizeAttributes(link.attributes)
|
|
1647
|
+
};
|
|
1648
|
+
});
|
|
1649
|
+
const attributes = sanitizeAttributes(options.attributes);
|
|
1650
|
+
const samplingResult = this._sampler.shouldSample(context2, traceId, name, spanKind, attributes, links);
|
|
1651
|
+
traceState = samplingResult.traceState ?? traceState;
|
|
1652
|
+
const traceFlags = samplingResult.decision === SamplingDecision.RECORD_AND_SAMPLED ? TraceFlags.SAMPLED : TraceFlags.NONE;
|
|
1653
|
+
const spanContext = { traceId, spanId, traceFlags, traceState };
|
|
1654
|
+
if (samplingResult.decision === SamplingDecision.NOT_RECORD) {
|
|
1655
|
+
diag.debug("Recording is off, propagating context in a non-recording span");
|
|
1656
|
+
const nonRecordingSpan = trace.wrapSpanContext(spanContext);
|
|
1657
|
+
return nonRecordingSpan;
|
|
1658
|
+
}
|
|
1659
|
+
const initAttributes = sanitizeAttributes(Object.assign(attributes, samplingResult.attributes));
|
|
1660
|
+
const span = new SpanImpl2({
|
|
1661
|
+
resource: this._resource,
|
|
1662
|
+
scope: this.instrumentationScope,
|
|
1663
|
+
context: context2,
|
|
1664
|
+
spanContext,
|
|
1665
|
+
name,
|
|
1666
|
+
kind: spanKind,
|
|
1667
|
+
links,
|
|
1668
|
+
parentSpanContext: validParentSpanContext,
|
|
1669
|
+
attributes: initAttributes,
|
|
1670
|
+
startTime: options.startTime,
|
|
1671
|
+
spanProcessor: this._spanProcessor,
|
|
1672
|
+
spanLimits: this._spanLimits
|
|
1673
|
+
});
|
|
1674
|
+
return span;
|
|
1675
|
+
}
|
|
1676
|
+
startActiveSpan(name, arg2, arg3, arg4) {
|
|
1677
|
+
let opts;
|
|
1678
|
+
let ctx;
|
|
1679
|
+
let fn;
|
|
1680
|
+
if (arguments.length < 2) {
|
|
1681
|
+
return;
|
|
1682
|
+
} else if (arguments.length === 2) {
|
|
1683
|
+
fn = arg2;
|
|
1684
|
+
} else if (arguments.length === 3) {
|
|
1685
|
+
opts = arg2;
|
|
1686
|
+
fn = arg3;
|
|
1687
|
+
} else {
|
|
1688
|
+
opts = arg2;
|
|
1689
|
+
ctx = arg3;
|
|
1690
|
+
fn = arg4;
|
|
1691
|
+
}
|
|
1692
|
+
const parentContext = ctx ?? context.active();
|
|
1693
|
+
const span = this.startSpan(name, opts, parentContext);
|
|
1694
|
+
const contextWithSpanSet = trace.setSpan(parentContext, span);
|
|
1695
|
+
return context.with(contextWithSpanSet, fn, void 0, span);
|
|
1696
|
+
}
|
|
1697
|
+
/** Returns the active {@link GeneralLimits}. */
|
|
1698
|
+
getGeneralLimits() {
|
|
1699
|
+
return this._generalLimits;
|
|
1700
|
+
}
|
|
1701
|
+
/** Returns the active {@link SpanLimits}. */
|
|
1702
|
+
getSpanLimits() {
|
|
1703
|
+
return this._spanLimits;
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
});
|
|
1708
|
+
|
|
1709
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/MultiSpanProcessor.js
|
|
1710
|
+
var MultiSpanProcessor;
|
|
1711
|
+
var init_MultiSpanProcessor = __esm({
|
|
1712
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/MultiSpanProcessor.js"() {
|
|
1713
|
+
"use strict";
|
|
1714
|
+
init_esm3();
|
|
1715
|
+
MultiSpanProcessor = class {
|
|
1716
|
+
_spanProcessors;
|
|
1717
|
+
constructor(_spanProcessors) {
|
|
1718
|
+
this._spanProcessors = _spanProcessors;
|
|
1719
|
+
}
|
|
1720
|
+
forceFlush() {
|
|
1721
|
+
const promises = [];
|
|
1722
|
+
for (const spanProcessor of this._spanProcessors) {
|
|
1723
|
+
promises.push(spanProcessor.forceFlush());
|
|
1724
|
+
}
|
|
1725
|
+
return new Promise((resolve) => {
|
|
1726
|
+
Promise.all(promises).then(() => {
|
|
1727
|
+
resolve();
|
|
1728
|
+
}).catch((error2) => {
|
|
1729
|
+
globalErrorHandler(error2 || new Error("MultiSpanProcessor: forceFlush failed"));
|
|
1730
|
+
resolve();
|
|
1731
|
+
});
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
onStart(span, context2) {
|
|
1735
|
+
for (const spanProcessor of this._spanProcessors) {
|
|
1736
|
+
spanProcessor.onStart(span, context2);
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
onEnd(span) {
|
|
1740
|
+
for (const spanProcessor of this._spanProcessors) {
|
|
1741
|
+
spanProcessor.onEnd(span);
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
shutdown() {
|
|
1745
|
+
const promises = [];
|
|
1746
|
+
for (const spanProcessor of this._spanProcessors) {
|
|
1747
|
+
promises.push(spanProcessor.shutdown());
|
|
1748
|
+
}
|
|
1749
|
+
return new Promise((resolve, reject2) => {
|
|
1750
|
+
Promise.all(promises).then(() => {
|
|
1751
|
+
resolve();
|
|
1752
|
+
}, reject2);
|
|
1753
|
+
});
|
|
1754
|
+
}
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
});
|
|
1758
|
+
|
|
1759
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/BasicTracerProvider.js
|
|
1760
|
+
var ForceFlushState, BasicTracerProvider;
|
|
1761
|
+
var init_BasicTracerProvider = __esm({
|
|
1762
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/BasicTracerProvider.js"() {
|
|
1763
|
+
"use strict";
|
|
1764
|
+
init_esm3();
|
|
1765
|
+
init_esm4();
|
|
1766
|
+
init_Tracer();
|
|
1767
|
+
init_config();
|
|
1768
|
+
init_MultiSpanProcessor();
|
|
1769
|
+
init_utility();
|
|
1770
|
+
(function(ForceFlushState2) {
|
|
1771
|
+
ForceFlushState2[ForceFlushState2["resolved"] = 0] = "resolved";
|
|
1772
|
+
ForceFlushState2[ForceFlushState2["timeout"] = 1] = "timeout";
|
|
1773
|
+
ForceFlushState2[ForceFlushState2["error"] = 2] = "error";
|
|
1774
|
+
ForceFlushState2[ForceFlushState2["unresolved"] = 3] = "unresolved";
|
|
1775
|
+
})(ForceFlushState || (ForceFlushState = {}));
|
|
1776
|
+
BasicTracerProvider = class {
|
|
1777
|
+
_config;
|
|
1778
|
+
_tracers = /* @__PURE__ */ new Map();
|
|
1779
|
+
_resource;
|
|
1780
|
+
_activeSpanProcessor;
|
|
1781
|
+
constructor(config = {}) {
|
|
1782
|
+
const mergedConfig = merge({}, loadDefaultConfig(), reconfigureLimits(config));
|
|
1783
|
+
this._resource = mergedConfig.resource ?? defaultResource();
|
|
1784
|
+
this._config = Object.assign({}, mergedConfig, {
|
|
1785
|
+
resource: this._resource
|
|
1786
|
+
});
|
|
1787
|
+
const spanProcessors = [];
|
|
1788
|
+
if (config.spanProcessors?.length) {
|
|
1789
|
+
spanProcessors.push(...config.spanProcessors);
|
|
1790
|
+
}
|
|
1791
|
+
this._activeSpanProcessor = new MultiSpanProcessor(spanProcessors);
|
|
1792
|
+
}
|
|
1793
|
+
getTracer(name, version, options) {
|
|
1794
|
+
const key = `${name}@${version || ""}:${options?.schemaUrl || ""}`;
|
|
1795
|
+
if (!this._tracers.has(key)) {
|
|
1796
|
+
this._tracers.set(key, new Tracer({ name, version, schemaUrl: options?.schemaUrl }, this._config, this._resource, this._activeSpanProcessor));
|
|
1797
|
+
}
|
|
1798
|
+
return this._tracers.get(key);
|
|
1799
|
+
}
|
|
1800
|
+
forceFlush() {
|
|
1801
|
+
const timeout = this._config.forceFlushTimeoutMillis;
|
|
1802
|
+
const promises = this._activeSpanProcessor["_spanProcessors"].map((spanProcessor) => {
|
|
1803
|
+
return new Promise((resolve) => {
|
|
1804
|
+
let state;
|
|
1805
|
+
const timeoutInterval = setTimeout(() => {
|
|
1806
|
+
resolve(new Error(`Span processor did not completed within timeout period of ${timeout} ms`));
|
|
1807
|
+
state = ForceFlushState.timeout;
|
|
1808
|
+
}, timeout);
|
|
1809
|
+
spanProcessor.forceFlush().then(() => {
|
|
1810
|
+
clearTimeout(timeoutInterval);
|
|
1811
|
+
if (state !== ForceFlushState.timeout) {
|
|
1812
|
+
state = ForceFlushState.resolved;
|
|
1813
|
+
resolve(state);
|
|
1814
|
+
}
|
|
1815
|
+
}).catch((error2) => {
|
|
1816
|
+
clearTimeout(timeoutInterval);
|
|
1817
|
+
state = ForceFlushState.error;
|
|
1818
|
+
resolve(error2);
|
|
1819
|
+
});
|
|
1820
|
+
});
|
|
1821
|
+
});
|
|
1822
|
+
return new Promise((resolve, reject2) => {
|
|
1823
|
+
Promise.all(promises).then((results) => {
|
|
1824
|
+
const errors = results.filter((result) => result !== ForceFlushState.resolved);
|
|
1825
|
+
if (errors.length > 0) {
|
|
1826
|
+
reject2(errors);
|
|
1827
|
+
} else {
|
|
1828
|
+
resolve();
|
|
1829
|
+
}
|
|
1830
|
+
}).catch((error2) => reject2([error2]));
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
shutdown() {
|
|
1834
|
+
return this._activeSpanProcessor.shutdown();
|
|
1835
|
+
}
|
|
1836
|
+
};
|
|
1837
|
+
}
|
|
1838
|
+
});
|
|
1839
|
+
|
|
1840
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/ConsoleSpanExporter.js
|
|
1841
|
+
var ConsoleSpanExporter;
|
|
1842
|
+
var init_ConsoleSpanExporter = __esm({
|
|
1843
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/ConsoleSpanExporter.js"() {
|
|
1844
|
+
"use strict";
|
|
1845
|
+
init_esm3();
|
|
1846
|
+
ConsoleSpanExporter = class {
|
|
1847
|
+
/**
|
|
1848
|
+
* Export spans.
|
|
1849
|
+
* @param spans
|
|
1850
|
+
* @param resultCallback
|
|
1851
|
+
*/
|
|
1852
|
+
export(spans, resultCallback) {
|
|
1853
|
+
return this._sendSpans(spans, resultCallback);
|
|
1854
|
+
}
|
|
1855
|
+
/**
|
|
1856
|
+
* Shutdown the exporter.
|
|
1857
|
+
*/
|
|
1858
|
+
shutdown() {
|
|
1859
|
+
this._sendSpans([]);
|
|
1860
|
+
return this.forceFlush();
|
|
1861
|
+
}
|
|
1862
|
+
/**
|
|
1863
|
+
* Exports any pending spans in exporter
|
|
1864
|
+
*/
|
|
1865
|
+
forceFlush() {
|
|
1866
|
+
return Promise.resolve();
|
|
1867
|
+
}
|
|
1868
|
+
/**
|
|
1869
|
+
* converts span info into more readable format
|
|
1870
|
+
* @param span
|
|
1871
|
+
*/
|
|
1872
|
+
_exportInfo(span) {
|
|
1873
|
+
return {
|
|
1874
|
+
resource: {
|
|
1875
|
+
attributes: span.resource.attributes
|
|
1876
|
+
},
|
|
1877
|
+
instrumentationScope: span.instrumentationScope,
|
|
1878
|
+
traceId: span.spanContext().traceId,
|
|
1879
|
+
parentSpanContext: span.parentSpanContext,
|
|
1880
|
+
traceState: span.spanContext().traceState?.serialize(),
|
|
1881
|
+
name: span.name,
|
|
1882
|
+
id: span.spanContext().spanId,
|
|
1883
|
+
kind: span.kind,
|
|
1884
|
+
timestamp: hrTimeToMicroseconds(span.startTime),
|
|
1885
|
+
duration: hrTimeToMicroseconds(span.duration),
|
|
1886
|
+
attributes: span.attributes,
|
|
1887
|
+
status: span.status,
|
|
1888
|
+
events: span.events,
|
|
1889
|
+
links: span.links
|
|
1890
|
+
};
|
|
1891
|
+
}
|
|
1892
|
+
/**
|
|
1893
|
+
* Showing spans in console
|
|
1894
|
+
* @param spans
|
|
1895
|
+
* @param done
|
|
1896
|
+
*/
|
|
1897
|
+
_sendSpans(spans, done) {
|
|
1898
|
+
for (const span of spans) {
|
|
1899
|
+
console.dir(this._exportInfo(span), { depth: 3 });
|
|
1900
|
+
}
|
|
1901
|
+
if (done) {
|
|
1902
|
+
return done({ code: ExportResultCode.SUCCESS });
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1907
|
+
});
|
|
1908
|
+
|
|
1909
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/InMemorySpanExporter.js
|
|
1910
|
+
var InMemorySpanExporter;
|
|
1911
|
+
var init_InMemorySpanExporter = __esm({
|
|
1912
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/InMemorySpanExporter.js"() {
|
|
1913
|
+
"use strict";
|
|
1914
|
+
init_esm3();
|
|
1915
|
+
InMemorySpanExporter = class {
|
|
1916
|
+
_finishedSpans = [];
|
|
1917
|
+
/**
|
|
1918
|
+
* Indicates if the exporter has been "shutdown."
|
|
1919
|
+
* When false, exported spans will not be stored in-memory.
|
|
1920
|
+
*/
|
|
1921
|
+
_stopped = false;
|
|
1922
|
+
export(spans, resultCallback) {
|
|
1923
|
+
if (this._stopped)
|
|
1924
|
+
return resultCallback({
|
|
1925
|
+
code: ExportResultCode.FAILED,
|
|
1926
|
+
error: new Error("Exporter has been stopped")
|
|
1927
|
+
});
|
|
1928
|
+
this._finishedSpans.push(...spans);
|
|
1929
|
+
setTimeout(() => resultCallback({ code: ExportResultCode.SUCCESS }), 0);
|
|
1930
|
+
}
|
|
1931
|
+
shutdown() {
|
|
1932
|
+
this._stopped = true;
|
|
1933
|
+
this._finishedSpans = [];
|
|
1934
|
+
return this.forceFlush();
|
|
1935
|
+
}
|
|
1936
|
+
/**
|
|
1937
|
+
* Exports any pending spans in the exporter
|
|
1938
|
+
*/
|
|
1939
|
+
forceFlush() {
|
|
1940
|
+
return Promise.resolve();
|
|
1941
|
+
}
|
|
1942
|
+
reset() {
|
|
1943
|
+
this._finishedSpans = [];
|
|
1944
|
+
}
|
|
1945
|
+
getFinishedSpans() {
|
|
1946
|
+
return this._finishedSpans;
|
|
1947
|
+
}
|
|
1948
|
+
};
|
|
1949
|
+
}
|
|
1950
|
+
});
|
|
1951
|
+
|
|
1952
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/SimpleSpanProcessor.js
|
|
1953
|
+
var SimpleSpanProcessor;
|
|
1954
|
+
var init_SimpleSpanProcessor = __esm({
|
|
1955
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/SimpleSpanProcessor.js"() {
|
|
1956
|
+
"use strict";
|
|
1957
|
+
init_esm();
|
|
1958
|
+
init_esm3();
|
|
1959
|
+
SimpleSpanProcessor = class {
|
|
1960
|
+
_exporter;
|
|
1961
|
+
_shutdownOnce;
|
|
1962
|
+
_pendingExports;
|
|
1963
|
+
constructor(_exporter) {
|
|
1964
|
+
this._exporter = _exporter;
|
|
1965
|
+
this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
|
|
1966
|
+
this._pendingExports = /* @__PURE__ */ new Set();
|
|
1967
|
+
}
|
|
1968
|
+
async forceFlush() {
|
|
1969
|
+
await Promise.all(Array.from(this._pendingExports));
|
|
1970
|
+
if (this._exporter.forceFlush) {
|
|
1971
|
+
await this._exporter.forceFlush();
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
onStart(_span, _parentContext) {
|
|
1975
|
+
}
|
|
1976
|
+
onEnd(span) {
|
|
1977
|
+
if (this._shutdownOnce.isCalled) {
|
|
1978
|
+
return;
|
|
1979
|
+
}
|
|
1980
|
+
if ((span.spanContext().traceFlags & TraceFlags.SAMPLED) === 0) {
|
|
1981
|
+
return;
|
|
1982
|
+
}
|
|
1983
|
+
const pendingExport = this._doExport(span).catch((err) => globalErrorHandler(err));
|
|
1984
|
+
this._pendingExports.add(pendingExport);
|
|
1985
|
+
pendingExport.finally(() => this._pendingExports.delete(pendingExport));
|
|
1986
|
+
}
|
|
1987
|
+
async _doExport(span) {
|
|
1988
|
+
if (span.resource.asyncAttributesPending) {
|
|
1989
|
+
await span.resource.waitForAsyncAttributes?.();
|
|
1990
|
+
}
|
|
1991
|
+
const result = await internal._export(this._exporter, [span]);
|
|
1992
|
+
if (result.code !== ExportResultCode.SUCCESS) {
|
|
1993
|
+
throw result.error ?? new Error(`SimpleSpanProcessor: span export failed (status ${result})`);
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
shutdown() {
|
|
1997
|
+
return this._shutdownOnce.call();
|
|
1998
|
+
}
|
|
1999
|
+
_shutdown() {
|
|
2000
|
+
return this._exporter.shutdown();
|
|
2001
|
+
}
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
2004
|
+
});
|
|
2005
|
+
|
|
2006
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/NoopSpanProcessor.js
|
|
2007
|
+
var NoopSpanProcessor;
|
|
2008
|
+
var init_NoopSpanProcessor = __esm({
|
|
2009
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/export/NoopSpanProcessor.js"() {
|
|
2010
|
+
"use strict";
|
|
2011
|
+
NoopSpanProcessor = class {
|
|
2012
|
+
onStart(_span, _context) {
|
|
2013
|
+
}
|
|
2014
|
+
onEnd(_span) {
|
|
2015
|
+
}
|
|
2016
|
+
shutdown() {
|
|
2017
|
+
return Promise.resolve();
|
|
2018
|
+
}
|
|
2019
|
+
forceFlush() {
|
|
2020
|
+
return Promise.resolve();
|
|
2021
|
+
}
|
|
2022
|
+
};
|
|
2023
|
+
}
|
|
2024
|
+
});
|
|
2025
|
+
|
|
2026
|
+
// ../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/index.js
|
|
2027
|
+
var esm_exports2 = {};
|
|
2028
|
+
__export(esm_exports2, {
|
|
2029
|
+
AlwaysOffSampler: () => AlwaysOffSampler,
|
|
2030
|
+
AlwaysOnSampler: () => AlwaysOnSampler,
|
|
2031
|
+
BasicTracerProvider: () => BasicTracerProvider,
|
|
2032
|
+
BatchSpanProcessor: () => BatchSpanProcessor,
|
|
2033
|
+
ConsoleSpanExporter: () => ConsoleSpanExporter,
|
|
2034
|
+
InMemorySpanExporter: () => InMemorySpanExporter,
|
|
2035
|
+
NoopSpanProcessor: () => NoopSpanProcessor,
|
|
2036
|
+
ParentBasedSampler: () => ParentBasedSampler,
|
|
2037
|
+
RandomIdGenerator: () => RandomIdGenerator,
|
|
2038
|
+
SamplingDecision: () => SamplingDecision2,
|
|
2039
|
+
SimpleSpanProcessor: () => SimpleSpanProcessor,
|
|
2040
|
+
TraceIdRatioBasedSampler: () => TraceIdRatioBasedSampler
|
|
2041
|
+
});
|
|
2042
|
+
var init_esm5 = __esm({
|
|
2043
|
+
"../../node_modules/.pnpm/@opentelemetry+sdk-trace-base@2.0.1_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/sdk-trace-base/build/esm/index.js"() {
|
|
2044
|
+
"use strict";
|
|
2045
|
+
init_BasicTracerProvider();
|
|
2046
|
+
init_platform3();
|
|
2047
|
+
init_ConsoleSpanExporter();
|
|
2048
|
+
init_InMemorySpanExporter();
|
|
2049
|
+
init_SimpleSpanProcessor();
|
|
2050
|
+
init_NoopSpanProcessor();
|
|
2051
|
+
init_AlwaysOffSampler();
|
|
2052
|
+
init_AlwaysOnSampler();
|
|
2053
|
+
init_ParentBasedSampler();
|
|
2054
|
+
init_TraceIdRatioBasedSampler();
|
|
2055
|
+
init_Sampler();
|
|
2056
|
+
}
|
|
2057
|
+
});
|
|
2058
|
+
|
|
2059
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js
|
|
2060
|
+
var OTLPExporterBase;
|
|
2061
|
+
var init_OTLPExporterBase = __esm({
|
|
2062
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js"() {
|
|
2063
|
+
"use strict";
|
|
2064
|
+
OTLPExporterBase = class {
|
|
2065
|
+
_delegate;
|
|
2066
|
+
constructor(_delegate) {
|
|
2067
|
+
this._delegate = _delegate;
|
|
2068
|
+
}
|
|
2069
|
+
/**
|
|
2070
|
+
* Export items.
|
|
2071
|
+
* @param items
|
|
2072
|
+
* @param resultCallback
|
|
2073
|
+
*/
|
|
2074
|
+
export(items, resultCallback) {
|
|
2075
|
+
this._delegate.export(items, resultCallback);
|
|
2076
|
+
}
|
|
2077
|
+
forceFlush() {
|
|
2078
|
+
return this._delegate.forceFlush();
|
|
2079
|
+
}
|
|
2080
|
+
shutdown() {
|
|
2081
|
+
return this._delegate.shutdown();
|
|
2082
|
+
}
|
|
2083
|
+
};
|
|
2084
|
+
}
|
|
2085
|
+
});
|
|
2086
|
+
|
|
2087
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/types.js
|
|
2088
|
+
var OTLPExporterError;
|
|
2089
|
+
var init_types = __esm({
|
|
2090
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/types.js"() {
|
|
2091
|
+
"use strict";
|
|
2092
|
+
OTLPExporterError = class extends Error {
|
|
2093
|
+
code;
|
|
2094
|
+
name = "OTLPExporterError";
|
|
2095
|
+
data;
|
|
2096
|
+
constructor(message, code, data) {
|
|
2097
|
+
super(message);
|
|
2098
|
+
this.data = data;
|
|
2099
|
+
this.code = code;
|
|
2100
|
+
}
|
|
2101
|
+
};
|
|
2102
|
+
}
|
|
2103
|
+
});
|
|
2104
|
+
|
|
2105
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.js
|
|
2106
|
+
function validateTimeoutMillis(timeoutMillis) {
|
|
2107
|
+
if (Number.isFinite(timeoutMillis) && timeoutMillis > 0) {
|
|
2108
|
+
return timeoutMillis;
|
|
2109
|
+
}
|
|
2110
|
+
throw new Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${timeoutMillis}')`);
|
|
2111
|
+
}
|
|
2112
|
+
function wrapStaticHeadersInFunction(headers) {
|
|
2113
|
+
if (headers == null) {
|
|
2114
|
+
return void 0;
|
|
2115
|
+
}
|
|
2116
|
+
return () => headers;
|
|
2117
|
+
}
|
|
2118
|
+
function mergeOtlpSharedConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
|
|
2119
|
+
return {
|
|
2120
|
+
timeoutMillis: validateTimeoutMillis(userProvidedConfiguration.timeoutMillis ?? fallbackConfiguration.timeoutMillis ?? defaultConfiguration.timeoutMillis),
|
|
2121
|
+
concurrencyLimit: userProvidedConfiguration.concurrencyLimit ?? fallbackConfiguration.concurrencyLimit ?? defaultConfiguration.concurrencyLimit,
|
|
2122
|
+
compression: userProvidedConfiguration.compression ?? fallbackConfiguration.compression ?? defaultConfiguration.compression
|
|
2123
|
+
};
|
|
2124
|
+
}
|
|
2125
|
+
function getSharedConfigurationDefaults() {
|
|
2126
|
+
return {
|
|
2127
|
+
timeoutMillis: 1e4,
|
|
2128
|
+
concurrencyLimit: 30,
|
|
2129
|
+
compression: "none"
|
|
2130
|
+
};
|
|
2131
|
+
}
|
|
2132
|
+
var init_shared_configuration = __esm({
|
|
2133
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-configuration.js"() {
|
|
2134
|
+
"use strict";
|
|
2135
|
+
}
|
|
2136
|
+
});
|
|
2137
|
+
|
|
2138
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/bounded-queue-export-promise-handler.js
|
|
2139
|
+
function createBoundedQueueExportPromiseHandler(options) {
|
|
2140
|
+
return new BoundedQueueExportPromiseHandler(options.concurrencyLimit);
|
|
2141
|
+
}
|
|
2142
|
+
var BoundedQueueExportPromiseHandler;
|
|
2143
|
+
var init_bounded_queue_export_promise_handler = __esm({
|
|
2144
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/bounded-queue-export-promise-handler.js"() {
|
|
2145
|
+
"use strict";
|
|
2146
|
+
BoundedQueueExportPromiseHandler = class {
|
|
2147
|
+
_concurrencyLimit;
|
|
2148
|
+
_sendingPromises = [];
|
|
2149
|
+
/**
|
|
2150
|
+
* @param concurrencyLimit maximum promises allowed in a queue at the same time.
|
|
2151
|
+
*/
|
|
2152
|
+
constructor(concurrencyLimit) {
|
|
2153
|
+
this._concurrencyLimit = concurrencyLimit;
|
|
2154
|
+
}
|
|
2155
|
+
pushPromise(promise) {
|
|
2156
|
+
if (this.hasReachedLimit()) {
|
|
2157
|
+
throw new Error("Concurrency Limit reached");
|
|
2158
|
+
}
|
|
2159
|
+
this._sendingPromises.push(promise);
|
|
2160
|
+
const popPromise = () => {
|
|
2161
|
+
const index = this._sendingPromises.indexOf(promise);
|
|
2162
|
+
this._sendingPromises.splice(index, 1);
|
|
2163
|
+
};
|
|
2164
|
+
promise.then(popPromise, popPromise);
|
|
2165
|
+
}
|
|
2166
|
+
hasReachedLimit() {
|
|
2167
|
+
return this._sendingPromises.length >= this._concurrencyLimit;
|
|
2168
|
+
}
|
|
2169
|
+
async awaitAll() {
|
|
2170
|
+
await Promise.all(this._sendingPromises);
|
|
2171
|
+
}
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
});
|
|
2175
|
+
|
|
2176
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/baggage/constants.js
|
|
2177
|
+
var BAGGAGE_KEY_PAIR_SEPARATOR, BAGGAGE_PROPERTIES_SEPARATOR, BAGGAGE_ITEMS_SEPARATOR;
|
|
2178
|
+
var init_constants = __esm({
|
|
2179
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/baggage/constants.js"() {
|
|
2180
|
+
"use strict";
|
|
2181
|
+
BAGGAGE_KEY_PAIR_SEPARATOR = "=";
|
|
2182
|
+
BAGGAGE_PROPERTIES_SEPARATOR = ";";
|
|
2183
|
+
BAGGAGE_ITEMS_SEPARATOR = ",";
|
|
2184
|
+
}
|
|
2185
|
+
});
|
|
2186
|
+
|
|
2187
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/baggage/utils.js
|
|
2188
|
+
function parsePairKeyValue(entry) {
|
|
2189
|
+
const valueProps = entry.split(BAGGAGE_PROPERTIES_SEPARATOR);
|
|
2190
|
+
if (valueProps.length <= 0)
|
|
2191
|
+
return;
|
|
2192
|
+
const keyPairPart = valueProps.shift();
|
|
2193
|
+
if (!keyPairPart)
|
|
2194
|
+
return;
|
|
2195
|
+
const separatorIndex = keyPairPart.indexOf(BAGGAGE_KEY_PAIR_SEPARATOR);
|
|
2196
|
+
if (separatorIndex <= 0)
|
|
2197
|
+
return;
|
|
2198
|
+
const key = decodeURIComponent(keyPairPart.substring(0, separatorIndex).trim());
|
|
2199
|
+
const value = decodeURIComponent(keyPairPart.substring(separatorIndex + 1).trim());
|
|
2200
|
+
let metadata;
|
|
2201
|
+
if (valueProps.length > 0) {
|
|
2202
|
+
metadata = baggageEntryMetadataFromString(valueProps.join(BAGGAGE_PROPERTIES_SEPARATOR));
|
|
2203
|
+
}
|
|
2204
|
+
return { key, value, metadata };
|
|
2205
|
+
}
|
|
2206
|
+
function parseKeyPairsIntoRecord(value) {
|
|
2207
|
+
if (typeof value !== "string" || value.length === 0)
|
|
2208
|
+
return {};
|
|
2209
|
+
return value.split(BAGGAGE_ITEMS_SEPARATOR).map((entry) => {
|
|
2210
|
+
return parsePairKeyValue(entry);
|
|
2211
|
+
}).filter((keyPair) => keyPair !== void 0 && keyPair.value.length > 0).reduce((headers, keyPair) => {
|
|
2212
|
+
headers[keyPair.key] = keyPair.value;
|
|
2213
|
+
return headers;
|
|
2214
|
+
}, {});
|
|
2215
|
+
}
|
|
2216
|
+
var init_utils2 = __esm({
|
|
2217
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/baggage/utils.js"() {
|
|
2218
|
+
"use strict";
|
|
2219
|
+
init_esm();
|
|
2220
|
+
init_constants();
|
|
2221
|
+
}
|
|
2222
|
+
});
|
|
2223
|
+
|
|
2224
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/time.js
|
|
2225
|
+
function hrTimeToNanoseconds2(time) {
|
|
2226
|
+
return time[0] * SECOND_TO_NANOSECONDS2 + time[1];
|
|
2227
|
+
}
|
|
2228
|
+
var NANOSECOND_DIGITS2, NANOSECOND_DIGITS_IN_MILLIS2, MILLISECONDS_TO_NANOSECONDS2, SECOND_TO_NANOSECONDS2;
|
|
2229
|
+
var init_time2 = __esm({
|
|
2230
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/common/time.js"() {
|
|
2231
|
+
"use strict";
|
|
2232
|
+
NANOSECOND_DIGITS2 = 9;
|
|
2233
|
+
NANOSECOND_DIGITS_IN_MILLIS2 = 6;
|
|
2234
|
+
MILLISECONDS_TO_NANOSECONDS2 = Math.pow(10, NANOSECOND_DIGITS_IN_MILLIS2);
|
|
2235
|
+
SECOND_TO_NANOSECONDS2 = Math.pow(10, NANOSECOND_DIGITS2);
|
|
2236
|
+
}
|
|
2237
|
+
});
|
|
2238
|
+
|
|
2239
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/ExportResult.js
|
|
2240
|
+
var ExportResultCode2;
|
|
2241
|
+
var init_ExportResult2 = __esm({
|
|
2242
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/ExportResult.js"() {
|
|
2243
|
+
"use strict";
|
|
2244
|
+
(function(ExportResultCode3) {
|
|
2245
|
+
ExportResultCode3[ExportResultCode3["SUCCESS"] = 0] = "SUCCESS";
|
|
2246
|
+
ExportResultCode3[ExportResultCode3["FAILED"] = 1] = "FAILED";
|
|
2247
|
+
})(ExportResultCode2 || (ExportResultCode2 = {}));
|
|
2248
|
+
}
|
|
2249
|
+
});
|
|
2250
|
+
|
|
2251
|
+
// ../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/index.js
|
|
2252
|
+
var init_esm6 = __esm({
|
|
2253
|
+
"../../node_modules/.pnpm/@opentelemetry+core@2.0.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/core/build/esm/index.js"() {
|
|
2254
|
+
"use strict";
|
|
2255
|
+
init_time2();
|
|
2256
|
+
init_ExportResult2();
|
|
2257
|
+
init_utils2();
|
|
2258
|
+
}
|
|
2259
|
+
});
|
|
2260
|
+
|
|
2261
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/logging-response-handler.js
|
|
2262
|
+
function isPartialSuccessResponse(response) {
|
|
2263
|
+
return Object.prototype.hasOwnProperty.call(response, "partialSuccess");
|
|
2264
|
+
}
|
|
2265
|
+
function createLoggingPartialSuccessResponseHandler() {
|
|
2266
|
+
return {
|
|
2267
|
+
handleResponse(response) {
|
|
2268
|
+
if (response == null || !isPartialSuccessResponse(response) || response.partialSuccess == null || Object.keys(response.partialSuccess).length === 0) {
|
|
2269
|
+
return;
|
|
2270
|
+
}
|
|
2271
|
+
diag.warn("Received Partial Success response:", JSON.stringify(response.partialSuccess));
|
|
2272
|
+
}
|
|
2273
|
+
};
|
|
2274
|
+
}
|
|
2275
|
+
var init_logging_response_handler = __esm({
|
|
2276
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/logging-response-handler.js"() {
|
|
2277
|
+
"use strict";
|
|
2278
|
+
init_esm();
|
|
2279
|
+
}
|
|
2280
|
+
});
|
|
2281
|
+
|
|
2282
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-export-delegate.js
|
|
2283
|
+
function createOtlpExportDelegate(components, settings) {
|
|
2284
|
+
return new OTLPExportDelegate(components.transport, components.serializer, createLoggingPartialSuccessResponseHandler(), components.promiseHandler, settings.timeout);
|
|
2285
|
+
}
|
|
2286
|
+
var OTLPExportDelegate;
|
|
2287
|
+
var init_otlp_export_delegate = __esm({
|
|
2288
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-export-delegate.js"() {
|
|
2289
|
+
"use strict";
|
|
2290
|
+
init_esm6();
|
|
2291
|
+
init_types();
|
|
2292
|
+
init_logging_response_handler();
|
|
2293
|
+
init_esm();
|
|
2294
|
+
OTLPExportDelegate = class {
|
|
2295
|
+
_transport;
|
|
2296
|
+
_serializer;
|
|
2297
|
+
_responseHandler;
|
|
2298
|
+
_promiseQueue;
|
|
2299
|
+
_timeout;
|
|
2300
|
+
_diagLogger;
|
|
2301
|
+
constructor(_transport, _serializer, _responseHandler, _promiseQueue, _timeout) {
|
|
2302
|
+
this._transport = _transport;
|
|
2303
|
+
this._serializer = _serializer;
|
|
2304
|
+
this._responseHandler = _responseHandler;
|
|
2305
|
+
this._promiseQueue = _promiseQueue;
|
|
2306
|
+
this._timeout = _timeout;
|
|
2307
|
+
this._diagLogger = diag.createComponentLogger({
|
|
2308
|
+
namespace: "OTLPExportDelegate"
|
|
2309
|
+
});
|
|
2310
|
+
}
|
|
2311
|
+
export(internalRepresentation, resultCallback) {
|
|
2312
|
+
this._diagLogger.debug("items to be sent", internalRepresentation);
|
|
2313
|
+
if (this._promiseQueue.hasReachedLimit()) {
|
|
2314
|
+
resultCallback({
|
|
2315
|
+
code: ExportResultCode2.FAILED,
|
|
2316
|
+
error: new Error("Concurrent export limit reached")
|
|
2317
|
+
});
|
|
2318
|
+
return;
|
|
2319
|
+
}
|
|
2320
|
+
const serializedRequest = this._serializer.serializeRequest(internalRepresentation);
|
|
2321
|
+
if (serializedRequest == null) {
|
|
2322
|
+
resultCallback({
|
|
2323
|
+
code: ExportResultCode2.FAILED,
|
|
2324
|
+
error: new Error("Nothing to send")
|
|
2325
|
+
});
|
|
2326
|
+
return;
|
|
2327
|
+
}
|
|
2328
|
+
this._promiseQueue.pushPromise(this._transport.send(serializedRequest, this._timeout).then((response) => {
|
|
2329
|
+
if (response.status === "success") {
|
|
2330
|
+
if (response.data != null) {
|
|
2331
|
+
try {
|
|
2332
|
+
this._responseHandler.handleResponse(this._serializer.deserializeResponse(response.data));
|
|
2333
|
+
} catch (e) {
|
|
2334
|
+
this._diagLogger.warn("Export succeeded but could not deserialize response - is the response specification compliant?", e, response.data);
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
resultCallback({
|
|
2338
|
+
code: ExportResultCode2.SUCCESS
|
|
2339
|
+
});
|
|
2340
|
+
return;
|
|
2341
|
+
} else if (response.status === "failure" && response.error) {
|
|
2342
|
+
resultCallback({
|
|
2343
|
+
code: ExportResultCode2.FAILED,
|
|
2344
|
+
error: response.error
|
|
2345
|
+
});
|
|
2346
|
+
return;
|
|
2347
|
+
} else if (response.status === "retryable") {
|
|
2348
|
+
resultCallback({
|
|
2349
|
+
code: ExportResultCode2.FAILED,
|
|
2350
|
+
error: new OTLPExporterError("Export failed with retryable status")
|
|
2351
|
+
});
|
|
2352
|
+
} else {
|
|
2353
|
+
resultCallback({
|
|
2354
|
+
code: ExportResultCode2.FAILED,
|
|
2355
|
+
error: new OTLPExporterError("Export failed with unknown error")
|
|
2356
|
+
});
|
|
2357
|
+
}
|
|
2358
|
+
}, (reason) => resultCallback({
|
|
2359
|
+
code: ExportResultCode2.FAILED,
|
|
2360
|
+
error: reason
|
|
2361
|
+
})));
|
|
2362
|
+
}
|
|
2363
|
+
forceFlush() {
|
|
2364
|
+
return this._promiseQueue.awaitAll();
|
|
2365
|
+
}
|
|
2366
|
+
async shutdown() {
|
|
2367
|
+
this._diagLogger.debug("shutdown started");
|
|
2368
|
+
await this.forceFlush();
|
|
2369
|
+
this._transport.shutdown();
|
|
2370
|
+
}
|
|
2371
|
+
};
|
|
2372
|
+
}
|
|
2373
|
+
});
|
|
2374
|
+
|
|
2375
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index.js
|
|
2376
|
+
var init_esm7 = __esm({
|
|
2377
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index.js"() {
|
|
2378
|
+
"use strict";
|
|
2379
|
+
init_OTLPExporterBase();
|
|
2380
|
+
}
|
|
2381
|
+
});
|
|
2382
|
+
|
|
2383
|
+
// ../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/version.js
|
|
2384
|
+
var VERSION2;
|
|
2385
|
+
var init_version2 = __esm({
|
|
2386
|
+
"../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/version.js"() {
|
|
2387
|
+
"use strict";
|
|
2388
|
+
VERSION2 = "0.200.0";
|
|
2389
|
+
}
|
|
2390
|
+
});
|
|
2391
|
+
|
|
2392
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/common/hex-to-binary.js
|
|
2393
|
+
function intValue(charCode) {
|
|
2394
|
+
if (charCode >= 48 && charCode <= 57) {
|
|
2395
|
+
return charCode - 48;
|
|
2396
|
+
}
|
|
2397
|
+
if (charCode >= 97 && charCode <= 102) {
|
|
2398
|
+
return charCode - 87;
|
|
2399
|
+
}
|
|
2400
|
+
return charCode - 55;
|
|
2401
|
+
}
|
|
2402
|
+
function hexToBinary(hexStr) {
|
|
2403
|
+
const buf = new Uint8Array(hexStr.length / 2);
|
|
2404
|
+
let offset = 0;
|
|
2405
|
+
for (let i = 0; i < hexStr.length; i += 2) {
|
|
2406
|
+
const hi = intValue(hexStr.charCodeAt(i));
|
|
2407
|
+
const lo = intValue(hexStr.charCodeAt(i + 1));
|
|
2408
|
+
buf[offset++] = hi << 4 | lo;
|
|
2409
|
+
}
|
|
2410
|
+
return buf;
|
|
2411
|
+
}
|
|
2412
|
+
var init_hex_to_binary = __esm({
|
|
2413
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/common/hex-to-binary.js"() {
|
|
2414
|
+
"use strict";
|
|
2415
|
+
}
|
|
2416
|
+
});
|
|
2417
|
+
|
|
2418
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/common/utils.js
|
|
2419
|
+
function hrTimeToNanos(hrTime3) {
|
|
2420
|
+
const NANOSECONDS = BigInt(1e9);
|
|
2421
|
+
return BigInt(hrTime3[0]) * NANOSECONDS + BigInt(hrTime3[1]);
|
|
2422
|
+
}
|
|
2423
|
+
function toLongBits(value) {
|
|
2424
|
+
const low = Number(BigInt.asUintN(32, value));
|
|
2425
|
+
const high = Number(BigInt.asUintN(32, value >> BigInt(32)));
|
|
2426
|
+
return { low, high };
|
|
2427
|
+
}
|
|
2428
|
+
function encodeAsLongBits(hrTime3) {
|
|
2429
|
+
const nanos = hrTimeToNanos(hrTime3);
|
|
2430
|
+
return toLongBits(nanos);
|
|
2431
|
+
}
|
|
2432
|
+
function encodeAsString(hrTime3) {
|
|
2433
|
+
const nanos = hrTimeToNanos(hrTime3);
|
|
2434
|
+
return nanos.toString();
|
|
2435
|
+
}
|
|
2436
|
+
function identity(value) {
|
|
2437
|
+
return value;
|
|
2438
|
+
}
|
|
2439
|
+
function optionalHexToBinary(str) {
|
|
2440
|
+
if (str === void 0)
|
|
2441
|
+
return void 0;
|
|
2442
|
+
return hexToBinary(str);
|
|
2443
|
+
}
|
|
2444
|
+
function getOtlpEncoder(options) {
|
|
2445
|
+
if (options === void 0) {
|
|
2446
|
+
return DEFAULT_ENCODER;
|
|
2447
|
+
}
|
|
2448
|
+
const useLongBits = options.useLongBits ?? true;
|
|
2449
|
+
const useHex = options.useHex ?? false;
|
|
2450
|
+
return {
|
|
2451
|
+
encodeHrTime: useLongBits ? encodeAsLongBits : encodeTimestamp,
|
|
2452
|
+
encodeSpanContext: useHex ? identity : hexToBinary,
|
|
2453
|
+
encodeOptionalSpanContext: useHex ? identity : optionalHexToBinary
|
|
2454
|
+
};
|
|
2455
|
+
}
|
|
2456
|
+
var encodeTimestamp, DEFAULT_ENCODER;
|
|
2457
|
+
var init_utils3 = __esm({
|
|
2458
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/common/utils.js"() {
|
|
2459
|
+
"use strict";
|
|
2460
|
+
init_esm6();
|
|
2461
|
+
init_hex_to_binary();
|
|
2462
|
+
encodeTimestamp = typeof BigInt !== "undefined" ? encodeAsString : hrTimeToNanoseconds2;
|
|
2463
|
+
DEFAULT_ENCODER = {
|
|
2464
|
+
encodeHrTime: encodeAsLongBits,
|
|
2465
|
+
encodeSpanContext: hexToBinary,
|
|
2466
|
+
encodeOptionalSpanContext: optionalHexToBinary
|
|
2467
|
+
};
|
|
2468
|
+
}
|
|
2469
|
+
});
|
|
2470
|
+
|
|
2471
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/common/internal.js
|
|
2472
|
+
function createResource(resource) {
|
|
2473
|
+
return {
|
|
2474
|
+
attributes: toAttributes(resource.attributes),
|
|
2475
|
+
droppedAttributesCount: 0
|
|
2476
|
+
};
|
|
2477
|
+
}
|
|
2478
|
+
function createInstrumentationScope(scope) {
|
|
2479
|
+
return {
|
|
2480
|
+
name: scope.name,
|
|
2481
|
+
version: scope.version
|
|
2482
|
+
};
|
|
2483
|
+
}
|
|
2484
|
+
function toAttributes(attributes) {
|
|
2485
|
+
return Object.keys(attributes).map((key) => toKeyValue(key, attributes[key]));
|
|
2486
|
+
}
|
|
2487
|
+
function toKeyValue(key, value) {
|
|
2488
|
+
return {
|
|
2489
|
+
key,
|
|
2490
|
+
value: toAnyValue(value)
|
|
2491
|
+
};
|
|
2492
|
+
}
|
|
2493
|
+
function toAnyValue(value) {
|
|
2494
|
+
const t = typeof value;
|
|
2495
|
+
if (t === "string")
|
|
2496
|
+
return { stringValue: value };
|
|
2497
|
+
if (t === "number") {
|
|
2498
|
+
if (!Number.isInteger(value))
|
|
2499
|
+
return { doubleValue: value };
|
|
2500
|
+
return { intValue: value };
|
|
2501
|
+
}
|
|
2502
|
+
if (t === "boolean")
|
|
2503
|
+
return { boolValue: value };
|
|
2504
|
+
if (value instanceof Uint8Array)
|
|
2505
|
+
return { bytesValue: value };
|
|
2506
|
+
if (Array.isArray(value))
|
|
2507
|
+
return { arrayValue: { values: value.map(toAnyValue) } };
|
|
2508
|
+
if (t === "object" && value != null)
|
|
2509
|
+
return {
|
|
2510
|
+
kvlistValue: {
|
|
2511
|
+
values: Object.entries(value).map(([k, v]) => toKeyValue(k, v))
|
|
2512
|
+
}
|
|
2513
|
+
};
|
|
2514
|
+
return {};
|
|
2515
|
+
}
|
|
2516
|
+
var init_internal = __esm({
|
|
2517
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/common/internal.js"() {
|
|
2518
|
+
"use strict";
|
|
2519
|
+
}
|
|
2520
|
+
});
|
|
2521
|
+
|
|
2522
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/internal.js
|
|
2523
|
+
function sdkSpanToOtlpSpan(span, encoder) {
|
|
2524
|
+
const ctx = span.spanContext();
|
|
2525
|
+
const status = span.status;
|
|
2526
|
+
const parentSpanId = span.parentSpanContext?.spanId ? encoder.encodeSpanContext(span.parentSpanContext?.spanId) : void 0;
|
|
2527
|
+
return {
|
|
2528
|
+
traceId: encoder.encodeSpanContext(ctx.traceId),
|
|
2529
|
+
spanId: encoder.encodeSpanContext(ctx.spanId),
|
|
2530
|
+
parentSpanId,
|
|
2531
|
+
traceState: ctx.traceState?.serialize(),
|
|
2532
|
+
name: span.name,
|
|
2533
|
+
// Span kind is offset by 1 because the API does not define a value for unset
|
|
2534
|
+
kind: span.kind == null ? 0 : span.kind + 1,
|
|
2535
|
+
startTimeUnixNano: encoder.encodeHrTime(span.startTime),
|
|
2536
|
+
endTimeUnixNano: encoder.encodeHrTime(span.endTime),
|
|
2537
|
+
attributes: toAttributes(span.attributes),
|
|
2538
|
+
droppedAttributesCount: span.droppedAttributesCount,
|
|
2539
|
+
events: span.events.map((event) => toOtlpSpanEvent(event, encoder)),
|
|
2540
|
+
droppedEventsCount: span.droppedEventsCount,
|
|
2541
|
+
status: {
|
|
2542
|
+
// API and proto enums share the same values
|
|
2543
|
+
code: status.code,
|
|
2544
|
+
message: status.message
|
|
2545
|
+
},
|
|
2546
|
+
links: span.links.map((link) => toOtlpLink(link, encoder)),
|
|
2547
|
+
droppedLinksCount: span.droppedLinksCount
|
|
2548
|
+
};
|
|
2549
|
+
}
|
|
2550
|
+
function toOtlpLink(link, encoder) {
|
|
2551
|
+
return {
|
|
2552
|
+
attributes: link.attributes ? toAttributes(link.attributes) : [],
|
|
2553
|
+
spanId: encoder.encodeSpanContext(link.context.spanId),
|
|
2554
|
+
traceId: encoder.encodeSpanContext(link.context.traceId),
|
|
2555
|
+
traceState: link.context.traceState?.serialize(),
|
|
2556
|
+
droppedAttributesCount: link.droppedAttributesCount || 0
|
|
2557
|
+
};
|
|
2558
|
+
}
|
|
2559
|
+
function toOtlpSpanEvent(timedEvent, encoder) {
|
|
2560
|
+
return {
|
|
2561
|
+
attributes: timedEvent.attributes ? toAttributes(timedEvent.attributes) : [],
|
|
2562
|
+
name: timedEvent.name,
|
|
2563
|
+
timeUnixNano: encoder.encodeHrTime(timedEvent.time),
|
|
2564
|
+
droppedAttributesCount: timedEvent.droppedAttributesCount || 0
|
|
2565
|
+
};
|
|
2566
|
+
}
|
|
2567
|
+
function createExportTraceServiceRequest(spans, options) {
|
|
2568
|
+
const encoder = getOtlpEncoder(options);
|
|
2569
|
+
return {
|
|
2570
|
+
resourceSpans: spanRecordsToResourceSpans(spans, encoder)
|
|
2571
|
+
};
|
|
2572
|
+
}
|
|
2573
|
+
function createResourceMap(readableSpans) {
|
|
2574
|
+
const resourceMap = /* @__PURE__ */ new Map();
|
|
2575
|
+
for (const record of readableSpans) {
|
|
2576
|
+
let ilsMap = resourceMap.get(record.resource);
|
|
2577
|
+
if (!ilsMap) {
|
|
2578
|
+
ilsMap = /* @__PURE__ */ new Map();
|
|
2579
|
+
resourceMap.set(record.resource, ilsMap);
|
|
2580
|
+
}
|
|
2581
|
+
const instrumentationScopeKey = `${record.instrumentationScope.name}@${record.instrumentationScope.version || ""}:${record.instrumentationScope.schemaUrl || ""}`;
|
|
2582
|
+
let records = ilsMap.get(instrumentationScopeKey);
|
|
2583
|
+
if (!records) {
|
|
2584
|
+
records = [];
|
|
2585
|
+
ilsMap.set(instrumentationScopeKey, records);
|
|
2586
|
+
}
|
|
2587
|
+
records.push(record);
|
|
2588
|
+
}
|
|
2589
|
+
return resourceMap;
|
|
2590
|
+
}
|
|
2591
|
+
function spanRecordsToResourceSpans(readableSpans, encoder) {
|
|
2592
|
+
const resourceMap = createResourceMap(readableSpans);
|
|
2593
|
+
const out = [];
|
|
2594
|
+
const entryIterator = resourceMap.entries();
|
|
2595
|
+
let entry = entryIterator.next();
|
|
2596
|
+
while (!entry.done) {
|
|
2597
|
+
const [resource, ilmMap] = entry.value;
|
|
2598
|
+
const scopeResourceSpans = [];
|
|
2599
|
+
const ilmIterator = ilmMap.values();
|
|
2600
|
+
let ilmEntry = ilmIterator.next();
|
|
2601
|
+
while (!ilmEntry.done) {
|
|
2602
|
+
const scopeSpans = ilmEntry.value;
|
|
2603
|
+
if (scopeSpans.length > 0) {
|
|
2604
|
+
const spans = scopeSpans.map((readableSpan) => sdkSpanToOtlpSpan(readableSpan, encoder));
|
|
2605
|
+
scopeResourceSpans.push({
|
|
2606
|
+
scope: createInstrumentationScope(scopeSpans[0].instrumentationScope),
|
|
2607
|
+
spans,
|
|
2608
|
+
schemaUrl: scopeSpans[0].instrumentationScope.schemaUrl
|
|
2609
|
+
});
|
|
2610
|
+
}
|
|
2611
|
+
ilmEntry = ilmIterator.next();
|
|
2612
|
+
}
|
|
2613
|
+
const transformedSpans = {
|
|
2614
|
+
resource: createResource(resource),
|
|
2615
|
+
scopeSpans: scopeResourceSpans,
|
|
2616
|
+
schemaUrl: void 0
|
|
2617
|
+
};
|
|
2618
|
+
out.push(transformedSpans);
|
|
2619
|
+
entry = entryIterator.next();
|
|
2620
|
+
}
|
|
2621
|
+
return out;
|
|
2622
|
+
}
|
|
2623
|
+
var init_internal2 = __esm({
|
|
2624
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/internal.js"() {
|
|
2625
|
+
"use strict";
|
|
2626
|
+
init_internal();
|
|
2627
|
+
init_utils3();
|
|
2628
|
+
}
|
|
2629
|
+
});
|
|
2630
|
+
|
|
2631
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/trace.js
|
|
2632
|
+
var JsonTraceSerializer;
|
|
2633
|
+
var init_trace2 = __esm({
|
|
2634
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/trace.js"() {
|
|
2635
|
+
"use strict";
|
|
2636
|
+
init_internal2();
|
|
2637
|
+
JsonTraceSerializer = {
|
|
2638
|
+
serializeRequest: (arg) => {
|
|
2639
|
+
const request3 = createExportTraceServiceRequest(arg, {
|
|
2640
|
+
useHex: true,
|
|
2641
|
+
useLongBits: false
|
|
2642
|
+
});
|
|
2643
|
+
const encoder = new TextEncoder();
|
|
2644
|
+
return encoder.encode(JSON.stringify(request3));
|
|
2645
|
+
},
|
|
2646
|
+
deserializeResponse: (arg) => {
|
|
2647
|
+
const decoder = new TextDecoder();
|
|
2648
|
+
return JSON.parse(decoder.decode(arg));
|
|
2649
|
+
}
|
|
2650
|
+
};
|
|
2651
|
+
}
|
|
2652
|
+
});
|
|
2653
|
+
|
|
2654
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/index.js
|
|
2655
|
+
var init_json = __esm({
|
|
2656
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/index.js"() {
|
|
2657
|
+
"use strict";
|
|
2658
|
+
init_trace2();
|
|
2659
|
+
}
|
|
2660
|
+
});
|
|
2661
|
+
|
|
2662
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/index.js
|
|
2663
|
+
var init_esm8 = __esm({
|
|
2664
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-transformer@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-transformer/build/esm/index.js"() {
|
|
2665
|
+
"use strict";
|
|
2666
|
+
init_json();
|
|
2667
|
+
}
|
|
2668
|
+
});
|
|
2669
|
+
|
|
2670
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.js
|
|
2671
|
+
function isExportRetryable(statusCode) {
|
|
2672
|
+
const retryCodes = [429, 502, 503, 504];
|
|
2673
|
+
return retryCodes.includes(statusCode);
|
|
2674
|
+
}
|
|
2675
|
+
function parseRetryAfterToMills(retryAfter) {
|
|
2676
|
+
if (retryAfter == null) {
|
|
2677
|
+
return void 0;
|
|
2678
|
+
}
|
|
2679
|
+
const seconds = Number.parseInt(retryAfter, 10);
|
|
2680
|
+
if (Number.isInteger(seconds)) {
|
|
2681
|
+
return seconds > 0 ? seconds * 1e3 : -1;
|
|
2682
|
+
}
|
|
2683
|
+
const delay = new Date(retryAfter).getTime() - Date.now();
|
|
2684
|
+
if (delay >= 0) {
|
|
2685
|
+
return delay;
|
|
2686
|
+
}
|
|
2687
|
+
return 0;
|
|
2688
|
+
}
|
|
2689
|
+
var init_is_export_retryable = __esm({
|
|
2690
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/is-export-retryable.js"() {
|
|
2691
|
+
"use strict";
|
|
2692
|
+
}
|
|
2693
|
+
});
|
|
2694
|
+
|
|
2695
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js
|
|
2696
|
+
var http_transport_utils_exports = {};
|
|
2697
|
+
__export(http_transport_utils_exports, {
|
|
2698
|
+
compressAndSend: () => compressAndSend,
|
|
2699
|
+
createHttpAgent: () => createHttpAgent,
|
|
2700
|
+
sendWithHttp: () => sendWithHttp
|
|
2701
|
+
});
|
|
2702
|
+
import * as http from "http";
|
|
2703
|
+
import * as https from "https";
|
|
2704
|
+
import * as zlib2 from "zlib";
|
|
2705
|
+
import { Readable } from "stream";
|
|
2706
|
+
function sendWithHttp(params, agent, data, onDone, timeoutMillis) {
|
|
2707
|
+
const parsedUrl = new URL(params.url);
|
|
2708
|
+
const nodeVersion = Number(process.versions.node.split(".")[0]);
|
|
2709
|
+
const options = {
|
|
2710
|
+
hostname: parsedUrl.hostname,
|
|
2711
|
+
port: parsedUrl.port,
|
|
2712
|
+
path: parsedUrl.pathname,
|
|
2713
|
+
method: "POST",
|
|
2714
|
+
headers: {
|
|
2715
|
+
...params.headers()
|
|
2716
|
+
},
|
|
2717
|
+
agent
|
|
2718
|
+
};
|
|
2719
|
+
const request3 = parsedUrl.protocol === "http:" ? http.request : https.request;
|
|
2720
|
+
const req = request3(options, (res) => {
|
|
2721
|
+
const responseData = [];
|
|
2722
|
+
res.on("data", (chunk) => responseData.push(chunk));
|
|
2723
|
+
res.on("end", () => {
|
|
2724
|
+
if (res.statusCode && res.statusCode < 299) {
|
|
2725
|
+
onDone({
|
|
2726
|
+
status: "success",
|
|
2727
|
+
data: Buffer.concat(responseData)
|
|
2728
|
+
});
|
|
2729
|
+
} else if (res.statusCode && isExportRetryable(res.statusCode)) {
|
|
2730
|
+
onDone({
|
|
2731
|
+
status: "retryable",
|
|
2732
|
+
retryInMillis: parseRetryAfterToMills(res.headers["retry-after"])
|
|
2733
|
+
});
|
|
2734
|
+
} else {
|
|
2735
|
+
const error2 = new OTLPExporterError(res.statusMessage, res.statusCode, Buffer.concat(responseData).toString());
|
|
2736
|
+
onDone({
|
|
2737
|
+
status: "failure",
|
|
2738
|
+
error: error2
|
|
2739
|
+
});
|
|
2740
|
+
}
|
|
2741
|
+
});
|
|
2742
|
+
});
|
|
2743
|
+
req.setTimeout(timeoutMillis, () => {
|
|
2744
|
+
req.destroy();
|
|
2745
|
+
onDone({
|
|
2746
|
+
status: "failure",
|
|
2747
|
+
error: new Error("Request Timeout")
|
|
2748
|
+
});
|
|
2749
|
+
});
|
|
2750
|
+
req.on("error", (error2) => {
|
|
2751
|
+
onDone({
|
|
2752
|
+
status: "failure",
|
|
2753
|
+
error: error2
|
|
2754
|
+
});
|
|
2755
|
+
});
|
|
2756
|
+
const reportTimeoutErrorEvent = nodeVersion >= 14 ? "close" : "abort";
|
|
2757
|
+
req.on(reportTimeoutErrorEvent, () => {
|
|
2758
|
+
onDone({
|
|
2759
|
+
status: "failure",
|
|
2760
|
+
error: new Error("Request timed out")
|
|
2761
|
+
});
|
|
2762
|
+
});
|
|
2763
|
+
compressAndSend(req, params.compression, data, (error2) => {
|
|
2764
|
+
onDone({
|
|
2765
|
+
status: "failure",
|
|
2766
|
+
error: error2
|
|
2767
|
+
});
|
|
2768
|
+
});
|
|
2769
|
+
}
|
|
2770
|
+
function compressAndSend(req, compression, data, onError) {
|
|
2771
|
+
let dataStream = readableFromUint8Array(data);
|
|
2772
|
+
if (compression === "gzip") {
|
|
2773
|
+
req.setHeader("Content-Encoding", "gzip");
|
|
2774
|
+
dataStream = dataStream.on("error", onError).pipe(zlib2.createGzip()).on("error", onError);
|
|
2775
|
+
}
|
|
2776
|
+
dataStream.pipe(req).on("error", onError);
|
|
2777
|
+
}
|
|
2778
|
+
function readableFromUint8Array(buff) {
|
|
2779
|
+
const readable = new Readable();
|
|
2780
|
+
readable.push(buff);
|
|
2781
|
+
readable.push(null);
|
|
2782
|
+
return readable;
|
|
2783
|
+
}
|
|
2784
|
+
function createHttpAgent(rawUrl, agentOptions) {
|
|
2785
|
+
const parsedUrl = new URL(rawUrl);
|
|
2786
|
+
const Agent3 = parsedUrl.protocol === "http:" ? http.Agent : https.Agent;
|
|
2787
|
+
return new Agent3(agentOptions);
|
|
2788
|
+
}
|
|
2789
|
+
var init_http_transport_utils = __esm({
|
|
2790
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js"() {
|
|
2791
|
+
"use strict";
|
|
2792
|
+
init_is_export_retryable();
|
|
2793
|
+
init_types();
|
|
2794
|
+
}
|
|
2795
|
+
});
|
|
2796
|
+
|
|
2797
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-exporter-transport.js
|
|
2798
|
+
function createHttpExporterTransport(parameters) {
|
|
2799
|
+
return new HttpExporterTransport(parameters);
|
|
2800
|
+
}
|
|
2801
|
+
var HttpExporterTransport;
|
|
2802
|
+
var init_http_exporter_transport = __esm({
|
|
2803
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-exporter-transport.js"() {
|
|
2804
|
+
"use strict";
|
|
2805
|
+
HttpExporterTransport = class {
|
|
2806
|
+
_parameters;
|
|
2807
|
+
_utils = null;
|
|
2808
|
+
constructor(_parameters) {
|
|
2809
|
+
this._parameters = _parameters;
|
|
2810
|
+
}
|
|
2811
|
+
async send(data, timeoutMillis) {
|
|
2812
|
+
const { agent, send } = this._loadUtils();
|
|
2813
|
+
return new Promise((resolve) => {
|
|
2814
|
+
send(this._parameters, agent, data, (result) => {
|
|
2815
|
+
resolve(result);
|
|
2816
|
+
}, timeoutMillis);
|
|
2817
|
+
});
|
|
2818
|
+
}
|
|
2819
|
+
shutdown() {
|
|
2820
|
+
}
|
|
2821
|
+
_loadUtils() {
|
|
2822
|
+
let utils = this._utils;
|
|
2823
|
+
if (utils === null) {
|
|
2824
|
+
const {
|
|
2825
|
+
sendWithHttp: sendWithHttp2,
|
|
2826
|
+
createHttpAgent: createHttpAgent2
|
|
2827
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
2828
|
+
} = (init_http_transport_utils(), __toCommonJS(http_transport_utils_exports));
|
|
2829
|
+
utils = this._utils = {
|
|
2830
|
+
agent: createHttpAgent2(this._parameters.url, this._parameters.agentOptions),
|
|
2831
|
+
send: sendWithHttp2
|
|
2832
|
+
};
|
|
2833
|
+
}
|
|
2834
|
+
return utils;
|
|
2835
|
+
}
|
|
2836
|
+
};
|
|
2837
|
+
}
|
|
2838
|
+
});
|
|
2839
|
+
|
|
2840
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/retrying-transport.js
|
|
2841
|
+
function getJitter() {
|
|
2842
|
+
return Math.random() * (2 * JITTER) - JITTER;
|
|
2843
|
+
}
|
|
2844
|
+
function createRetryingTransport(options) {
|
|
2845
|
+
return new RetryingTransport(options.transport);
|
|
2846
|
+
}
|
|
2847
|
+
var MAX_ATTEMPTS, INITIAL_BACKOFF, MAX_BACKOFF, BACKOFF_MULTIPLIER, JITTER, RetryingTransport;
|
|
2848
|
+
var init_retrying_transport = __esm({
|
|
2849
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/retrying-transport.js"() {
|
|
2850
|
+
"use strict";
|
|
2851
|
+
MAX_ATTEMPTS = 5;
|
|
2852
|
+
INITIAL_BACKOFF = 1e3;
|
|
2853
|
+
MAX_BACKOFF = 5e3;
|
|
2854
|
+
BACKOFF_MULTIPLIER = 1.5;
|
|
2855
|
+
JITTER = 0.2;
|
|
2856
|
+
RetryingTransport = class {
|
|
2857
|
+
_transport;
|
|
2858
|
+
constructor(_transport) {
|
|
2859
|
+
this._transport = _transport;
|
|
2860
|
+
}
|
|
2861
|
+
retry(data, timeoutMillis, inMillis) {
|
|
2862
|
+
return new Promise((resolve, reject2) => {
|
|
2863
|
+
setTimeout(() => {
|
|
2864
|
+
this._transport.send(data, timeoutMillis).then(resolve, reject2);
|
|
2865
|
+
}, inMillis);
|
|
2866
|
+
});
|
|
2867
|
+
}
|
|
2868
|
+
async send(data, timeoutMillis) {
|
|
2869
|
+
const deadline = Date.now() + timeoutMillis;
|
|
2870
|
+
let result = await this._transport.send(data, timeoutMillis);
|
|
2871
|
+
let attempts = MAX_ATTEMPTS;
|
|
2872
|
+
let nextBackoff = INITIAL_BACKOFF;
|
|
2873
|
+
while (result.status === "retryable" && attempts > 0) {
|
|
2874
|
+
attempts--;
|
|
2875
|
+
const backoff = Math.max(Math.min(nextBackoff, MAX_BACKOFF) + getJitter(), 0);
|
|
2876
|
+
nextBackoff = nextBackoff * BACKOFF_MULTIPLIER;
|
|
2877
|
+
const retryInMillis = result.retryInMillis ?? backoff;
|
|
2878
|
+
const remainingTimeoutMillis = deadline - Date.now();
|
|
2879
|
+
if (retryInMillis > remainingTimeoutMillis) {
|
|
2880
|
+
return result;
|
|
2881
|
+
}
|
|
2882
|
+
result = await this.retry(data, remainingTimeoutMillis, retryInMillis);
|
|
2883
|
+
}
|
|
2884
|
+
return result;
|
|
2885
|
+
}
|
|
2886
|
+
shutdown() {
|
|
2887
|
+
return this._transport.shutdown();
|
|
2888
|
+
}
|
|
2889
|
+
};
|
|
2890
|
+
}
|
|
2891
|
+
});
|
|
2892
|
+
|
|
2893
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-http-export-delegate.js
|
|
2894
|
+
function createOtlpHttpExportDelegate(options, serializer) {
|
|
2895
|
+
return createOtlpExportDelegate({
|
|
2896
|
+
transport: createRetryingTransport({
|
|
2897
|
+
transport: createHttpExporterTransport(options)
|
|
2898
|
+
}),
|
|
2899
|
+
serializer,
|
|
2900
|
+
promiseHandler: createBoundedQueueExportPromiseHandler(options)
|
|
2901
|
+
}, { timeout: options.timeoutMillis });
|
|
2902
|
+
}
|
|
2903
|
+
var init_otlp_http_export_delegate = __esm({
|
|
2904
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/otlp-http-export-delegate.js"() {
|
|
2905
|
+
"use strict";
|
|
2906
|
+
init_otlp_export_delegate();
|
|
2907
|
+
init_http_exporter_transport();
|
|
2908
|
+
init_bounded_queue_export_promise_handler();
|
|
2909
|
+
init_retrying_transport();
|
|
2910
|
+
}
|
|
2911
|
+
});
|
|
2912
|
+
|
|
2913
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-env-configuration.js
|
|
2914
|
+
function parseAndValidateTimeoutFromEnv(timeoutEnvVar) {
|
|
2915
|
+
const envTimeout = process.env[timeoutEnvVar]?.trim();
|
|
2916
|
+
if (envTimeout != null && envTimeout !== "") {
|
|
2917
|
+
const definedTimeout = Number(envTimeout);
|
|
2918
|
+
if (Number.isFinite(definedTimeout) && definedTimeout > 0) {
|
|
2919
|
+
return definedTimeout;
|
|
2920
|
+
}
|
|
2921
|
+
diag.warn(`Configuration: ${timeoutEnvVar} is invalid, expected number greater than 0 (actual: ${envTimeout})`);
|
|
2922
|
+
}
|
|
2923
|
+
return void 0;
|
|
2924
|
+
}
|
|
2925
|
+
function getTimeoutFromEnv(signalIdentifier) {
|
|
2926
|
+
const specificTimeout = parseAndValidateTimeoutFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_TIMEOUT`);
|
|
2927
|
+
const nonSpecificTimeout = parseAndValidateTimeoutFromEnv("OTEL_EXPORTER_OTLP_TIMEOUT");
|
|
2928
|
+
return specificTimeout ?? nonSpecificTimeout;
|
|
2929
|
+
}
|
|
2930
|
+
function parseAndValidateCompressionFromEnv(compressionEnvVar) {
|
|
2931
|
+
const compression = process.env[compressionEnvVar]?.trim();
|
|
2932
|
+
if (compression === "") {
|
|
2933
|
+
return void 0;
|
|
2934
|
+
}
|
|
2935
|
+
if (compression == null || compression === "none" || compression === "gzip") {
|
|
2936
|
+
return compression;
|
|
2937
|
+
}
|
|
2938
|
+
diag.warn(`Configuration: ${compressionEnvVar} is invalid, expected 'none' or 'gzip' (actual: '${compression}')`);
|
|
2939
|
+
return void 0;
|
|
2940
|
+
}
|
|
2941
|
+
function getCompressionFromEnv(signalIdentifier) {
|
|
2942
|
+
const specificCompression = parseAndValidateCompressionFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_COMPRESSION`);
|
|
2943
|
+
const nonSpecificCompression = parseAndValidateCompressionFromEnv("OTEL_EXPORTER_OTLP_COMPRESSION");
|
|
2944
|
+
return specificCompression ?? nonSpecificCompression;
|
|
2945
|
+
}
|
|
2946
|
+
function getSharedConfigurationFromEnvironment(signalIdentifier) {
|
|
2947
|
+
return {
|
|
2948
|
+
timeoutMillis: getTimeoutFromEnv(signalIdentifier),
|
|
2949
|
+
compression: getCompressionFromEnv(signalIdentifier)
|
|
2950
|
+
};
|
|
2951
|
+
}
|
|
2952
|
+
var init_shared_env_configuration = __esm({
|
|
2953
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/shared-env-configuration.js"() {
|
|
2954
|
+
"use strict";
|
|
2955
|
+
init_esm();
|
|
2956
|
+
}
|
|
2957
|
+
});
|
|
2958
|
+
|
|
2959
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/util.js
|
|
2960
|
+
function validateAndNormalizeHeaders(partialHeaders) {
|
|
2961
|
+
return () => {
|
|
2962
|
+
const headers = {};
|
|
2963
|
+
Object.entries(partialHeaders?.() ?? {}).forEach(([key, value]) => {
|
|
2964
|
+
if (typeof value !== "undefined") {
|
|
2965
|
+
headers[key] = String(value);
|
|
2966
|
+
} else {
|
|
2967
|
+
diag.warn(`Header "${key}" has invalid value (${value}) and will be ignored`);
|
|
2968
|
+
}
|
|
2969
|
+
});
|
|
2970
|
+
return headers;
|
|
2971
|
+
};
|
|
2972
|
+
}
|
|
2973
|
+
var init_util = __esm({
|
|
2974
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/util.js"() {
|
|
2975
|
+
"use strict";
|
|
2976
|
+
init_esm();
|
|
2977
|
+
}
|
|
2978
|
+
});
|
|
2979
|
+
|
|
2980
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.js
|
|
2981
|
+
function mergeHeaders(userProvidedHeaders, fallbackHeaders, defaultHeaders) {
|
|
2982
|
+
const requiredHeaders = {
|
|
2983
|
+
...defaultHeaders()
|
|
2984
|
+
};
|
|
2985
|
+
const headers = {};
|
|
2986
|
+
return () => {
|
|
2987
|
+
if (fallbackHeaders != null) {
|
|
2988
|
+
Object.assign(headers, fallbackHeaders());
|
|
2989
|
+
}
|
|
2990
|
+
if (userProvidedHeaders != null) {
|
|
2991
|
+
Object.assign(headers, userProvidedHeaders());
|
|
2992
|
+
}
|
|
2993
|
+
return Object.assign(headers, requiredHeaders);
|
|
2994
|
+
};
|
|
2995
|
+
}
|
|
2996
|
+
function validateUserProvidedUrl(url) {
|
|
2997
|
+
if (url == null) {
|
|
2998
|
+
return void 0;
|
|
2999
|
+
}
|
|
3000
|
+
try {
|
|
3001
|
+
new URL(url);
|
|
3002
|
+
return url;
|
|
3003
|
+
} catch (e) {
|
|
3004
|
+
throw new Error(`Configuration: Could not parse user-provided export URL: '${url}'`);
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
function mergeOtlpHttpConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
|
|
3008
|
+
return {
|
|
3009
|
+
...mergeOtlpSharedConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration),
|
|
3010
|
+
headers: mergeHeaders(validateAndNormalizeHeaders(userProvidedConfiguration.headers), fallbackConfiguration.headers, defaultConfiguration.headers),
|
|
3011
|
+
url: validateUserProvidedUrl(userProvidedConfiguration.url) ?? fallbackConfiguration.url ?? defaultConfiguration.url,
|
|
3012
|
+
agentOptions: userProvidedConfiguration.agentOptions ?? fallbackConfiguration.agentOptions ?? defaultConfiguration.agentOptions
|
|
3013
|
+
};
|
|
3014
|
+
}
|
|
3015
|
+
function getHttpConfigurationDefaults(requiredHeaders, signalResourcePath) {
|
|
3016
|
+
return {
|
|
3017
|
+
...getSharedConfigurationDefaults(),
|
|
3018
|
+
headers: () => requiredHeaders,
|
|
3019
|
+
url: "http://localhost:4318/" + signalResourcePath,
|
|
3020
|
+
agentOptions: { keepAlive: true }
|
|
3021
|
+
};
|
|
3022
|
+
}
|
|
3023
|
+
var init_otlp_http_configuration = __esm({
|
|
3024
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-configuration.js"() {
|
|
3025
|
+
"use strict";
|
|
3026
|
+
init_shared_configuration();
|
|
3027
|
+
init_util();
|
|
3028
|
+
}
|
|
3029
|
+
});
|
|
3030
|
+
|
|
3031
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-env-configuration.js
|
|
3032
|
+
function getStaticHeadersFromEnv(signalIdentifier) {
|
|
3033
|
+
const signalSpecificRawHeaders = process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`]?.trim();
|
|
3034
|
+
const nonSignalSpecificRawHeaders = process.env["OTEL_EXPORTER_OTLP_HEADERS"]?.trim();
|
|
3035
|
+
const signalSpecificHeaders = parseKeyPairsIntoRecord(signalSpecificRawHeaders);
|
|
3036
|
+
const nonSignalSpecificHeaders = parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders);
|
|
3037
|
+
if (Object.keys(signalSpecificHeaders).length === 0 && Object.keys(nonSignalSpecificHeaders).length === 0) {
|
|
3038
|
+
return void 0;
|
|
3039
|
+
}
|
|
3040
|
+
return Object.assign({}, parseKeyPairsIntoRecord(nonSignalSpecificRawHeaders), parseKeyPairsIntoRecord(signalSpecificRawHeaders));
|
|
3041
|
+
}
|
|
3042
|
+
function appendRootPathToUrlIfNeeded(url) {
|
|
3043
|
+
try {
|
|
3044
|
+
const parsedUrl = new URL(url);
|
|
3045
|
+
return parsedUrl.toString();
|
|
3046
|
+
} catch {
|
|
3047
|
+
diag.warn(`Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`);
|
|
3048
|
+
return void 0;
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
function appendResourcePathToUrl(url, path3) {
|
|
3052
|
+
try {
|
|
3053
|
+
new URL(url);
|
|
3054
|
+
} catch {
|
|
3055
|
+
diag.warn(`Configuration: Could not parse environment-provided export URL: '${url}', falling back to undefined`);
|
|
3056
|
+
return void 0;
|
|
3057
|
+
}
|
|
3058
|
+
if (!url.endsWith("/")) {
|
|
3059
|
+
url = url + "/";
|
|
3060
|
+
}
|
|
3061
|
+
url += path3;
|
|
3062
|
+
try {
|
|
3063
|
+
new URL(url);
|
|
3064
|
+
} catch {
|
|
3065
|
+
diag.warn(`Configuration: Provided URL appended with '${path3}' is not a valid URL, using 'undefined' instead of '${url}'`);
|
|
3066
|
+
return void 0;
|
|
3067
|
+
}
|
|
3068
|
+
return url;
|
|
3069
|
+
}
|
|
3070
|
+
function getNonSpecificUrlFromEnv(signalResourcePath) {
|
|
3071
|
+
const envUrl = process.env.OTEL_EXPORTER_OTLP_ENDPOINT?.trim();
|
|
3072
|
+
if (envUrl == null || envUrl === "") {
|
|
3073
|
+
return void 0;
|
|
3074
|
+
}
|
|
3075
|
+
return appendResourcePathToUrl(envUrl, signalResourcePath);
|
|
3076
|
+
}
|
|
3077
|
+
function getSpecificUrlFromEnv(signalIdentifier) {
|
|
3078
|
+
const envUrl = process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`]?.trim();
|
|
3079
|
+
if (envUrl == null || envUrl === "") {
|
|
3080
|
+
return void 0;
|
|
3081
|
+
}
|
|
3082
|
+
return appendRootPathToUrlIfNeeded(envUrl);
|
|
3083
|
+
}
|
|
3084
|
+
function getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath) {
|
|
3085
|
+
return {
|
|
3086
|
+
...getSharedConfigurationFromEnvironment(signalIdentifier),
|
|
3087
|
+
url: getSpecificUrlFromEnv(signalIdentifier) ?? getNonSpecificUrlFromEnv(signalResourcePath),
|
|
3088
|
+
headers: wrapStaticHeadersInFunction(getStaticHeadersFromEnv(signalIdentifier))
|
|
3089
|
+
};
|
|
3090
|
+
}
|
|
3091
|
+
var init_otlp_http_env_configuration = __esm({
|
|
3092
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/otlp-http-env-configuration.js"() {
|
|
3093
|
+
"use strict";
|
|
3094
|
+
init_esm6();
|
|
3095
|
+
init_esm();
|
|
3096
|
+
init_shared_env_configuration();
|
|
3097
|
+
init_shared_configuration();
|
|
3098
|
+
}
|
|
3099
|
+
});
|
|
3100
|
+
|
|
3101
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-node-http-options.js
|
|
3102
|
+
function convertLegacyAgentOptions(config) {
|
|
3103
|
+
if (config?.keepAlive != null) {
|
|
3104
|
+
if (config.httpAgentOptions != null) {
|
|
3105
|
+
if (config.httpAgentOptions.keepAlive == null) {
|
|
3106
|
+
config.httpAgentOptions.keepAlive = config.keepAlive;
|
|
3107
|
+
}
|
|
3108
|
+
} else {
|
|
3109
|
+
config.httpAgentOptions = {
|
|
3110
|
+
keepAlive: config.keepAlive
|
|
3111
|
+
};
|
|
3112
|
+
}
|
|
3113
|
+
}
|
|
3114
|
+
return config.httpAgentOptions;
|
|
3115
|
+
}
|
|
3116
|
+
function convertLegacyHttpOptions(config, signalIdentifier, signalResourcePath, requiredHeaders) {
|
|
3117
|
+
if (config.metadata) {
|
|
3118
|
+
diag.warn("Metadata cannot be set when using http");
|
|
3119
|
+
}
|
|
3120
|
+
return mergeOtlpHttpConfigurationWithDefaults({
|
|
3121
|
+
url: config.url,
|
|
3122
|
+
headers: wrapStaticHeadersInFunction(config.headers),
|
|
3123
|
+
concurrencyLimit: config.concurrencyLimit,
|
|
3124
|
+
timeoutMillis: config.timeoutMillis,
|
|
3125
|
+
compression: config.compression,
|
|
3126
|
+
agentOptions: convertLegacyAgentOptions(config)
|
|
3127
|
+
}, getHttpConfigurationFromEnvironment(signalIdentifier, signalResourcePath), getHttpConfigurationDefaults(requiredHeaders, signalResourcePath));
|
|
3128
|
+
}
|
|
3129
|
+
var init_convert_legacy_node_http_options = __esm({
|
|
3130
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/configuration/convert-legacy-node-http-options.js"() {
|
|
3131
|
+
"use strict";
|
|
3132
|
+
init_otlp_http_configuration();
|
|
3133
|
+
init_otlp_http_env_configuration();
|
|
3134
|
+
init_esm();
|
|
3135
|
+
init_shared_configuration();
|
|
3136
|
+
}
|
|
3137
|
+
});
|
|
3138
|
+
|
|
3139
|
+
// ../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-node-http.js
|
|
3140
|
+
var init_index_node_http = __esm({
|
|
3141
|
+
"../../node_modules/.pnpm/@opentelemetry+otlp-exporter-base@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/otlp-exporter-base/build/esm/index-node-http.js"() {
|
|
3142
|
+
"use strict";
|
|
3143
|
+
init_otlp_http_export_delegate();
|
|
3144
|
+
init_convert_legacy_node_http_options();
|
|
3145
|
+
}
|
|
3146
|
+
});
|
|
3147
|
+
|
|
3148
|
+
// ../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/OTLPTraceExporter.js
|
|
3149
|
+
var OTLPTraceExporter;
|
|
3150
|
+
var init_OTLPTraceExporter = __esm({
|
|
3151
|
+
"../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/OTLPTraceExporter.js"() {
|
|
3152
|
+
"use strict";
|
|
3153
|
+
init_esm7();
|
|
3154
|
+
init_version2();
|
|
3155
|
+
init_esm8();
|
|
3156
|
+
init_index_node_http();
|
|
3157
|
+
OTLPTraceExporter = class extends OTLPExporterBase {
|
|
3158
|
+
constructor(config = {}) {
|
|
3159
|
+
super(createOtlpHttpExportDelegate(convertLegacyHttpOptions(config, "TRACES", "v1/traces", {
|
|
3160
|
+
"User-Agent": `OTel-OTLP-Exporter-JavaScript/${VERSION2}`,
|
|
3161
|
+
"Content-Type": "application/json"
|
|
3162
|
+
}), JsonTraceSerializer));
|
|
3163
|
+
}
|
|
3164
|
+
};
|
|
3165
|
+
}
|
|
3166
|
+
});
|
|
3167
|
+
|
|
3168
|
+
// ../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/index.js
|
|
3169
|
+
var init_node4 = __esm({
|
|
3170
|
+
"../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/node/index.js"() {
|
|
3171
|
+
"use strict";
|
|
3172
|
+
init_OTLPTraceExporter();
|
|
3173
|
+
}
|
|
3174
|
+
});
|
|
3175
|
+
|
|
3176
|
+
// ../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/index.js
|
|
3177
|
+
var init_platform4 = __esm({
|
|
3178
|
+
"../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/platform/index.js"() {
|
|
3179
|
+
"use strict";
|
|
3180
|
+
init_node4();
|
|
3181
|
+
}
|
|
3182
|
+
});
|
|
3183
|
+
|
|
3184
|
+
// ../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/index.js
|
|
3185
|
+
var esm_exports3 = {};
|
|
3186
|
+
__export(esm_exports3, {
|
|
3187
|
+
OTLPTraceExporter: () => OTLPTraceExporter
|
|
3188
|
+
});
|
|
3189
|
+
var init_esm9 = __esm({
|
|
3190
|
+
"../../node_modules/.pnpm/@opentelemetry+exporter-trace-otlp-http@0.200.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/exporter-trace-otlp-http/build/esm/index.js"() {
|
|
3191
|
+
"use strict";
|
|
3192
|
+
init_platform4();
|
|
3193
|
+
}
|
|
3194
|
+
});
|
|
6
3195
|
|
|
7
3196
|
// src/node.ts
|
|
8
3197
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -106,7 +3295,7 @@ async function getBaseBranchAncestor(remote = void 0) {
|
|
|
106
3295
|
return void 0;
|
|
107
3296
|
}
|
|
108
3297
|
}
|
|
109
|
-
async function getPastNAncestors(n =
|
|
3298
|
+
async function getPastNAncestors(n = 1e3, remote = void 0) {
|
|
110
3299
|
const git = await currentRepo();
|
|
111
3300
|
if (git === null) {
|
|
112
3301
|
return [];
|
|
@@ -123,7 +3312,7 @@ async function getPastNAncestors(n = 10, remote = void 0) {
|
|
|
123
3312
|
if (!ancestor) {
|
|
124
3313
|
return [];
|
|
125
3314
|
}
|
|
126
|
-
const commits = await git.log({ from: ancestor, to: "HEAD" });
|
|
3315
|
+
const commits = await git.log({ from: ancestor, to: "HEAD", maxCount: n });
|
|
127
3316
|
return commits.all.map((c) => c.hash);
|
|
128
3317
|
}
|
|
129
3318
|
async function attempt(fn) {
|
|
@@ -208,11 +3397,11 @@ async function repoInfo() {
|
|
|
208
3397
|
|
|
209
3398
|
// src/stackutil.ts
|
|
210
3399
|
function getStackTrace() {
|
|
211
|
-
const
|
|
212
|
-
if (typeof
|
|
3400
|
+
const trace2 = new Error().stack;
|
|
3401
|
+
if (typeof trace2 !== "string") {
|
|
213
3402
|
return [];
|
|
214
3403
|
}
|
|
215
|
-
const traceLines =
|
|
3404
|
+
const traceLines = trace2.split("\n");
|
|
216
3405
|
const out = [];
|
|
217
3406
|
const stackFrameRegex = /at(.*)\((.*):(\d+):(\d+)\)/;
|
|
218
3407
|
for (const traceLine of traceLines.slice(1)) {
|
|
@@ -986,11 +4175,11 @@ function objectIsEmpty(obj) {
|
|
|
986
4175
|
// src/mustache-utils.ts
|
|
987
4176
|
import { getObjValueByPath } from "@braintrust/core";
|
|
988
4177
|
import Mustache from "mustache";
|
|
989
|
-
function lintTemplate(template,
|
|
4178
|
+
function lintTemplate(template, context2) {
|
|
990
4179
|
const variables = getMustacheVars(template);
|
|
991
4180
|
for (const variable of variables) {
|
|
992
4181
|
const arrPathsReplaced = variable[1].replaceAll(/\.\d+/g, ".0");
|
|
993
|
-
const fieldExists = getObjValueByPath(
|
|
4182
|
+
const fieldExists = getObjValueByPath(context2, arrPathsReplaced.split(".")) !== void 0;
|
|
994
4183
|
if (!fieldExists) {
|
|
995
4184
|
throw new Error(`Variable '${variable[1]}' does not exist.`);
|
|
996
4185
|
}
|
|
@@ -4841,9 +8030,12 @@ function configureNode() {
|
|
|
4841
8030
|
// src/exports-node.ts
|
|
4842
8031
|
var exports_node_exports = {};
|
|
4843
8032
|
__export(exports_node_exports, {
|
|
8033
|
+
AISpanProcessor: () => AISpanProcessor,
|
|
4844
8034
|
Attachment: () => Attachment,
|
|
4845
8035
|
BaseAttachment: () => BaseAttachment,
|
|
4846
8036
|
BaseExperiment: () => BaseExperiment,
|
|
8037
|
+
BraintrustExporter: () => BraintrustExporter,
|
|
8038
|
+
BraintrustSpanProcessor: () => BraintrustSpanProcessor,
|
|
4847
8039
|
BraintrustState: () => BraintrustState,
|
|
4848
8040
|
BraintrustStream: () => BraintrustStream,
|
|
4849
8041
|
CodeFunction: () => CodeFunction,
|
|
@@ -4978,7 +8170,7 @@ async function invoke(args) {
|
|
|
4978
8170
|
`Invalid function ID arguments: ${functionId.error.message}`
|
|
4979
8171
|
);
|
|
4980
8172
|
}
|
|
4981
|
-
const
|
|
8173
|
+
const request3 = {
|
|
4982
8174
|
...functionId.data,
|
|
4983
8175
|
input,
|
|
4984
8176
|
messages,
|
|
@@ -4989,7 +8181,7 @@ async function invoke(args) {
|
|
|
4989
8181
|
mode,
|
|
4990
8182
|
strict
|
|
4991
8183
|
};
|
|
4992
|
-
const resp = await state.proxyConn().post(`function/invoke`,
|
|
8184
|
+
const resp = await state.proxyConn().post(`function/invoke`, request3, {
|
|
4993
8185
|
headers: {
|
|
4994
8186
|
Accept: stream ? "text/event-stream" : "application/json"
|
|
4995
8187
|
}
|
|
@@ -5891,12 +9083,12 @@ function groupByLimit(coll, limit, iteratee, callback) {
|
|
|
5891
9083
|
});
|
|
5892
9084
|
}, (err, mapResults) => {
|
|
5893
9085
|
var result = {};
|
|
5894
|
-
var { hasOwnProperty } = Object.prototype;
|
|
9086
|
+
var { hasOwnProperty: hasOwnProperty2 } = Object.prototype;
|
|
5895
9087
|
for (var i = 0; i < mapResults.length; i++) {
|
|
5896
9088
|
if (mapResults[i]) {
|
|
5897
9089
|
var { key } = mapResults[i];
|
|
5898
9090
|
var { val } = mapResults[i];
|
|
5899
|
-
if (
|
|
9091
|
+
if (hasOwnProperty2.call(result, key)) {
|
|
5900
9092
|
result[key].push(val);
|
|
5901
9093
|
} else {
|
|
5902
9094
|
result[key] = [val];
|
|
@@ -6758,14 +9950,20 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6758
9950
|
} else {
|
|
6759
9951
|
data = dataResult;
|
|
6760
9952
|
}
|
|
6761
|
-
|
|
6762
|
-
(datum) => [...Array(evaluator.trialCount ?? 1).keys()].map(() =>
|
|
9953
|
+
const dataWithTrials = data.filter((d) => filters.every((f) => evaluateFilter(d, f))).flatMap(
|
|
9954
|
+
(datum) => [...Array(evaluator.trialCount ?? 1).keys()].map((trialIndex) => ({
|
|
9955
|
+
datum,
|
|
9956
|
+
trialIndex
|
|
9957
|
+
}))
|
|
6763
9958
|
);
|
|
6764
|
-
progressReporter.start(evaluator.evalName,
|
|
9959
|
+
progressReporter.start(evaluator.evalName, dataWithTrials.length);
|
|
6765
9960
|
const results = [];
|
|
6766
9961
|
const q = queue(
|
|
6767
9962
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6768
|
-
async (
|
|
9963
|
+
async ({
|
|
9964
|
+
datum,
|
|
9965
|
+
trialIndex
|
|
9966
|
+
}) => {
|
|
6769
9967
|
const eventDataset = experiment ? experiment.dataset : Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
|
|
6770
9968
|
const baseEvent = {
|
|
6771
9969
|
name: "eval",
|
|
@@ -6814,7 +10012,8 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6814
10012
|
name: evaluator.evalName,
|
|
6815
10013
|
object_type: "task"
|
|
6816
10014
|
});
|
|
6817
|
-
}
|
|
10015
|
+
},
|
|
10016
|
+
trialIndex
|
|
6818
10017
|
});
|
|
6819
10018
|
if (outputResult instanceof Promise) {
|
|
6820
10019
|
output = await outputResult;
|
|
@@ -6964,9 +10163,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6964
10163
|
return await experiment.traced(callback, baseEvent);
|
|
6965
10164
|
}
|
|
6966
10165
|
},
|
|
6967
|
-
Math.max(evaluator.maxConcurrency ??
|
|
10166
|
+
Math.max(evaluator.maxConcurrency ?? dataWithTrials.length, 1)
|
|
6968
10167
|
);
|
|
6969
|
-
q.push(
|
|
10168
|
+
q.push(dataWithTrials);
|
|
6970
10169
|
const cancel = async () => {
|
|
6971
10170
|
await new Promise((_, reject2) => {
|
|
6972
10171
|
if (evaluator.timeout) {
|
|
@@ -7136,11 +10335,11 @@ var GraphBuilder = class {
|
|
|
7136
10335
|
this.OUT = this.createOutputNode();
|
|
7137
10336
|
}
|
|
7138
10337
|
// Create the final GraphData object
|
|
7139
|
-
async build(
|
|
10338
|
+
async build(context2) {
|
|
7140
10339
|
const nodes = await Promise.all(
|
|
7141
10340
|
Array.from(this.nodes.values()).map(async (node) => [
|
|
7142
10341
|
node.id,
|
|
7143
|
-
await node.build(
|
|
10342
|
+
await node.build(context2)
|
|
7144
10343
|
])
|
|
7145
10344
|
);
|
|
7146
10345
|
return {
|
|
@@ -7284,7 +10483,7 @@ var InputNode = class extends BaseNode {
|
|
|
7284
10483
|
constructor(graph, id) {
|
|
7285
10484
|
super(graph, id);
|
|
7286
10485
|
}
|
|
7287
|
-
async build(
|
|
10486
|
+
async build(context2) {
|
|
7288
10487
|
return {
|
|
7289
10488
|
type: "input",
|
|
7290
10489
|
description: "Input to the graph"
|
|
@@ -7295,7 +10494,7 @@ var OutputNode = class extends BaseNode {
|
|
|
7295
10494
|
constructor(graph, id) {
|
|
7296
10495
|
super(graph, id);
|
|
7297
10496
|
}
|
|
7298
|
-
async build(
|
|
10497
|
+
async build(context2) {
|
|
7299
10498
|
return {
|
|
7300
10499
|
type: "output",
|
|
7301
10500
|
description: "Output of the graph"
|
|
@@ -7307,10 +10506,10 @@ var PromptNode = class extends BaseNode {
|
|
|
7307
10506
|
super(graph, id);
|
|
7308
10507
|
this.prompt = prompt;
|
|
7309
10508
|
}
|
|
7310
|
-
async build(
|
|
10509
|
+
async build(context2) {
|
|
7311
10510
|
return {
|
|
7312
10511
|
type: "function",
|
|
7313
|
-
function: await
|
|
10512
|
+
function: await context2.getFunctionId(this.prompt)
|
|
7314
10513
|
};
|
|
7315
10514
|
}
|
|
7316
10515
|
};
|
|
@@ -7319,7 +10518,7 @@ var GateNode = class extends BaseNode {
|
|
|
7319
10518
|
super(graph, id);
|
|
7320
10519
|
this.condition = condition;
|
|
7321
10520
|
}
|
|
7322
|
-
async build(
|
|
10521
|
+
async build(context2) {
|
|
7323
10522
|
return {
|
|
7324
10523
|
type: "gate",
|
|
7325
10524
|
description: "Conditional gate",
|
|
@@ -7331,7 +10530,7 @@ var AggregatorNode = class extends BaseNode {
|
|
|
7331
10530
|
constructor(graph, id) {
|
|
7332
10531
|
super(graph, id);
|
|
7333
10532
|
}
|
|
7334
|
-
async build(
|
|
10533
|
+
async build(context2) {
|
|
7335
10534
|
return {
|
|
7336
10535
|
type: "aggregator",
|
|
7337
10536
|
description: "Aggregator"
|
|
@@ -7343,7 +10542,7 @@ var PromptTemplateNode = class extends BaseNode {
|
|
|
7343
10542
|
super(graph, id);
|
|
7344
10543
|
this.prompt = prompt;
|
|
7345
10544
|
}
|
|
7346
|
-
async build(
|
|
10545
|
+
async build(context2) {
|
|
7347
10546
|
return {
|
|
7348
10547
|
type: "prompt_template",
|
|
7349
10548
|
prompt: this.prompt
|
|
@@ -7355,7 +10554,7 @@ var LiteralNode = class extends BaseNode {
|
|
|
7355
10554
|
super(graph, id);
|
|
7356
10555
|
this.value = value;
|
|
7357
10556
|
}
|
|
7358
|
-
async build(
|
|
10557
|
+
async build(context2) {
|
|
7359
10558
|
return {
|
|
7360
10559
|
type: "literal",
|
|
7361
10560
|
value: this.value
|
|
@@ -8534,6 +11733,231 @@ function coalesceInput(messages, system) {
|
|
|
8534
11733
|
return input;
|
|
8535
11734
|
}
|
|
8536
11735
|
|
|
11736
|
+
// src/otel.ts
|
|
11737
|
+
var otelApi = null;
|
|
11738
|
+
var otelSdk = null;
|
|
11739
|
+
var OTEL_AVAILABLE = false;
|
|
11740
|
+
try {
|
|
11741
|
+
otelApi = (init_esm(), __toCommonJS(esm_exports));
|
|
11742
|
+
otelSdk = (init_esm5(), __toCommonJS(esm_exports2));
|
|
11743
|
+
OTEL_AVAILABLE = true;
|
|
11744
|
+
} catch (error2) {
|
|
11745
|
+
console.warn(
|
|
11746
|
+
"OpenTelemetry packages are not installed. Install them with: npm install @opentelemetry/api @opentelemetry/sdk-trace-base @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources @opentelemetry/semantic-conventions"
|
|
11747
|
+
);
|
|
11748
|
+
OTEL_AVAILABLE = false;
|
|
11749
|
+
}
|
|
11750
|
+
var FILTER_PREFIXES = ["gen_ai.", "braintrust.", "llm.", "ai."];
|
|
11751
|
+
var AISpanProcessor = class _AISpanProcessor {
|
|
11752
|
+
static checkOtelAvailable() {
|
|
11753
|
+
if (!OTEL_AVAILABLE) {
|
|
11754
|
+
throw new Error(
|
|
11755
|
+
"OpenTelemetry packages are not installed. Install them with: npm install @opentelemetry/api @opentelemetry/sdk-trace-base @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources @opentelemetry/semantic-conventions"
|
|
11756
|
+
);
|
|
11757
|
+
}
|
|
11758
|
+
}
|
|
11759
|
+
processor;
|
|
11760
|
+
customFilter;
|
|
11761
|
+
/**
|
|
11762
|
+
* Initialize the filter span processor.
|
|
11763
|
+
*
|
|
11764
|
+
* @param processor - The wrapped span processor that will receive filtered spans
|
|
11765
|
+
* @param customFilter - Optional function that takes a span and returns:
|
|
11766
|
+
* true to keep, false to drop,
|
|
11767
|
+
* null/undefined to not influence the decision
|
|
11768
|
+
*/
|
|
11769
|
+
constructor(processor, customFilter) {
|
|
11770
|
+
_AISpanProcessor.checkOtelAvailable();
|
|
11771
|
+
this.processor = processor;
|
|
11772
|
+
this.customFilter = customFilter;
|
|
11773
|
+
}
|
|
11774
|
+
/**
|
|
11775
|
+
* Forward span start events to the inner processor.
|
|
11776
|
+
*/
|
|
11777
|
+
onStart(span, parentContext) {
|
|
11778
|
+
this.processor.onStart(span, parentContext);
|
|
11779
|
+
}
|
|
11780
|
+
/**
|
|
11781
|
+
* Apply filtering logic and conditionally forward span end events.
|
|
11782
|
+
*/
|
|
11783
|
+
onEnd(span) {
|
|
11784
|
+
const shouldKeep = this.shouldKeepFilteredSpan(span);
|
|
11785
|
+
if (shouldKeep) {
|
|
11786
|
+
this.processor.onEnd(span);
|
|
11787
|
+
}
|
|
11788
|
+
}
|
|
11789
|
+
/**
|
|
11790
|
+
* Shutdown the inner processor.
|
|
11791
|
+
*/
|
|
11792
|
+
shutdown() {
|
|
11793
|
+
return this.processor.shutdown();
|
|
11794
|
+
}
|
|
11795
|
+
/**
|
|
11796
|
+
* Force flush the inner processor.
|
|
11797
|
+
*/
|
|
11798
|
+
forceFlush() {
|
|
11799
|
+
return this.processor.forceFlush();
|
|
11800
|
+
}
|
|
11801
|
+
/**
|
|
11802
|
+
* Determine if a span should be kept based on filtering criteria.
|
|
11803
|
+
*
|
|
11804
|
+
* Keep spans if:
|
|
11805
|
+
* 1. It's a root span (no parent)
|
|
11806
|
+
* 2. Custom filter returns true/false (if provided)
|
|
11807
|
+
* 3. Span name starts with 'gen_ai.', 'braintrust.', 'llm.', or 'ai.'
|
|
11808
|
+
* 4. Any attribute name starts with those prefixes
|
|
11809
|
+
*/
|
|
11810
|
+
shouldKeepFilteredSpan(span) {
|
|
11811
|
+
if (!span) {
|
|
11812
|
+
return false;
|
|
11813
|
+
}
|
|
11814
|
+
if (!span.parentSpanContext) {
|
|
11815
|
+
return true;
|
|
11816
|
+
}
|
|
11817
|
+
if (this.customFilter) {
|
|
11818
|
+
const customResult = this.customFilter(span);
|
|
11819
|
+
if (customResult === true) {
|
|
11820
|
+
return true;
|
|
11821
|
+
} else if (customResult === false) {
|
|
11822
|
+
return false;
|
|
11823
|
+
}
|
|
11824
|
+
}
|
|
11825
|
+
if (FILTER_PREFIXES.some((prefix) => span.name.startsWith(prefix))) {
|
|
11826
|
+
return true;
|
|
11827
|
+
}
|
|
11828
|
+
const attributes = span.attributes;
|
|
11829
|
+
if (attributes) {
|
|
11830
|
+
const attributeNames = Object.keys(attributes);
|
|
11831
|
+
if (attributeNames.some(
|
|
11832
|
+
(name) => FILTER_PREFIXES.some((prefix) => name.startsWith(prefix))
|
|
11833
|
+
)) {
|
|
11834
|
+
return true;
|
|
11835
|
+
}
|
|
11836
|
+
}
|
|
11837
|
+
return false;
|
|
11838
|
+
}
|
|
11839
|
+
};
|
|
11840
|
+
var BraintrustSpanProcessor = class _BraintrustSpanProcessor {
|
|
11841
|
+
static checkOtelAvailable() {
|
|
11842
|
+
if (!OTEL_AVAILABLE) {
|
|
11843
|
+
throw new Error(
|
|
11844
|
+
"OpenTelemetry packages are not installed. Install them with: npm install @opentelemetry/api @opentelemetry/sdk-trace-base @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources @opentelemetry/semantic-conventions"
|
|
11845
|
+
);
|
|
11846
|
+
}
|
|
11847
|
+
}
|
|
11848
|
+
processor;
|
|
11849
|
+
aiSpanProcessor;
|
|
11850
|
+
constructor(options = {}) {
|
|
11851
|
+
_BraintrustSpanProcessor.checkOtelAvailable();
|
|
11852
|
+
const apiKey = options.apiKey || process.env.BRAINTRUST_API_KEY;
|
|
11853
|
+
if (!apiKey) {
|
|
11854
|
+
throw new Error(
|
|
11855
|
+
"Braintrust API key is required. Set BRAINTRUST_API_KEY environment variable or pass apiKey option."
|
|
11856
|
+
);
|
|
11857
|
+
}
|
|
11858
|
+
let apiUrl = options.apiUrl || process.env.BRAINTRUST_API_URL || "https://api.braintrust.dev";
|
|
11859
|
+
if (!apiUrl.endsWith("/")) {
|
|
11860
|
+
apiUrl += "/";
|
|
11861
|
+
}
|
|
11862
|
+
let parent = options.parent || process.env.BRAINTRUST_PARENT;
|
|
11863
|
+
if (!parent) {
|
|
11864
|
+
parent = "project_name:default-otel-project";
|
|
11865
|
+
console.info(
|
|
11866
|
+
`No parent specified, using default: ${parent}. Configure with BRAINTRUST_PARENT environment variable or parent parameter.`
|
|
11867
|
+
);
|
|
11868
|
+
}
|
|
11869
|
+
let exporter;
|
|
11870
|
+
try {
|
|
11871
|
+
const {
|
|
11872
|
+
OTLPTraceExporter: OTLPTraceExporter2
|
|
11873
|
+
} = (init_esm9(), __toCommonJS(esm_exports3));
|
|
11874
|
+
const headers = {
|
|
11875
|
+
Authorization: `Bearer ${apiKey}`,
|
|
11876
|
+
"Content-Type": "application/json",
|
|
11877
|
+
"x-bt-parent": parent,
|
|
11878
|
+
...options.headers
|
|
11879
|
+
};
|
|
11880
|
+
exporter = new OTLPTraceExporter2({
|
|
11881
|
+
url: new URL("otel/v1/traces", apiUrl).href,
|
|
11882
|
+
headers
|
|
11883
|
+
});
|
|
11884
|
+
} catch (error2) {
|
|
11885
|
+
throw new Error(
|
|
11886
|
+
"Failed to create OTLP exporter. Make sure @opentelemetry/exporter-trace-otlp-http is installed."
|
|
11887
|
+
);
|
|
11888
|
+
}
|
|
11889
|
+
if (!otelSdk) {
|
|
11890
|
+
throw new Error("OpenTelemetry SDK not available");
|
|
11891
|
+
}
|
|
11892
|
+
this.processor = new otelSdk.BatchSpanProcessor(exporter);
|
|
11893
|
+
if (options.filterAISpans === true) {
|
|
11894
|
+
this.aiSpanProcessor = new AISpanProcessor(
|
|
11895
|
+
this.processor,
|
|
11896
|
+
options.customFilter
|
|
11897
|
+
);
|
|
11898
|
+
} else {
|
|
11899
|
+
this.aiSpanProcessor = this.processor;
|
|
11900
|
+
}
|
|
11901
|
+
}
|
|
11902
|
+
onStart(span, parentContext) {
|
|
11903
|
+
this.aiSpanProcessor.onStart(span, parentContext);
|
|
11904
|
+
}
|
|
11905
|
+
onEnd(span) {
|
|
11906
|
+
this.aiSpanProcessor.onEnd(span);
|
|
11907
|
+
}
|
|
11908
|
+
shutdown() {
|
|
11909
|
+
return this.aiSpanProcessor.shutdown();
|
|
11910
|
+
}
|
|
11911
|
+
forceFlush() {
|
|
11912
|
+
return this.aiSpanProcessor.forceFlush();
|
|
11913
|
+
}
|
|
11914
|
+
};
|
|
11915
|
+
var BraintrustExporter = class _BraintrustExporter {
|
|
11916
|
+
static checkOtelAvailable() {
|
|
11917
|
+
if (!OTEL_AVAILABLE) {
|
|
11918
|
+
throw new Error(
|
|
11919
|
+
"OpenTelemetry packages are not installed. Install them with: npm install @opentelemetry/api @opentelemetry/sdk-trace-base @opentelemetry/exporter-trace-otlp-http @opentelemetry/resources @opentelemetry/semantic-conventions"
|
|
11920
|
+
);
|
|
11921
|
+
}
|
|
11922
|
+
}
|
|
11923
|
+
processor;
|
|
11924
|
+
spans = [];
|
|
11925
|
+
callbacks = [];
|
|
11926
|
+
constructor(options = {}) {
|
|
11927
|
+
_BraintrustExporter.checkOtelAvailable();
|
|
11928
|
+
this.processor = new BraintrustSpanProcessor(options);
|
|
11929
|
+
}
|
|
11930
|
+
/**
|
|
11931
|
+
* Export spans to Braintrust by simulating span processor behavior.
|
|
11932
|
+
*/
|
|
11933
|
+
export(spans, resultCallback) {
|
|
11934
|
+
try {
|
|
11935
|
+
spans.forEach((span) => {
|
|
11936
|
+
this.processor.onEnd(span);
|
|
11937
|
+
});
|
|
11938
|
+
this.processor.forceFlush().then(() => {
|
|
11939
|
+
resultCallback({ code: 0 });
|
|
11940
|
+
}).catch((error2) => {
|
|
11941
|
+
resultCallback({ code: 1, error: error2 });
|
|
11942
|
+
});
|
|
11943
|
+
} catch (error2) {
|
|
11944
|
+
resultCallback({ code: 1, error: error2 });
|
|
11945
|
+
}
|
|
11946
|
+
}
|
|
11947
|
+
/**
|
|
11948
|
+
* Shutdown the exporter.
|
|
11949
|
+
*/
|
|
11950
|
+
shutdown() {
|
|
11951
|
+
return this.processor.shutdown();
|
|
11952
|
+
}
|
|
11953
|
+
/**
|
|
11954
|
+
* Force flush the exporter.
|
|
11955
|
+
*/
|
|
11956
|
+
forceFlush() {
|
|
11957
|
+
return this.processor.forceFlush();
|
|
11958
|
+
}
|
|
11959
|
+
};
|
|
11960
|
+
|
|
8537
11961
|
// dev/types.ts
|
|
8538
11962
|
import {
|
|
8539
11963
|
functionIdSchema as functionIdSchema2,
|
|
@@ -8584,9 +12008,12 @@ var evaluatorDefinitionsSchema = z5.record(
|
|
|
8584
12008
|
configureNode();
|
|
8585
12009
|
var index_default = exports_node_exports;
|
|
8586
12010
|
export {
|
|
12011
|
+
AISpanProcessor,
|
|
8587
12012
|
Attachment,
|
|
8588
12013
|
BaseAttachment,
|
|
8589
12014
|
BaseExperiment,
|
|
12015
|
+
BraintrustExporter,
|
|
12016
|
+
BraintrustSpanProcessor,
|
|
8590
12017
|
BraintrustState,
|
|
8591
12018
|
BraintrustStream,
|
|
8592
12019
|
CodeFunction,
|