@osfactory/otel-hook 0.7.0 → 0.9.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/README.md +202 -3
- package/dist/cli.js +1527 -730
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +51 -3
- package/dist/config.js +481 -160
- package/dist/config.js.map +1 -1
- package/dist/destinations-C6Bm89W6.d.ts +169 -0
- package/dist/diagnostics.d.ts +8 -0
- package/dist/diagnostics.js +2 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/{otlp-log-sink-eUEjaLhk.d.ts → export-destinations-d8tZV0G4.d.ts} +255 -7
- package/dist/{hook-Dh8OO4Wa.d.ts → hook-zA1b4cWd.d.ts} +2 -2
- package/dist/index.d.ts +8 -7
- package/dist/index.js +1379 -695
- package/dist/index.js.map +1 -1
- package/dist/integration.d.ts +25 -7
- package/dist/integration.js +742 -181
- package/dist/integration.js.map +1 -1
- package/dist/lifecycle.js +3 -1
- package/dist/lifecycle.js.map +1 -1
- package/dist/providers.d.ts +3 -3
- package/dist/{registry-CIVvRlVK.d.ts → registry-B8ZHc2bc.d.ts} +1 -1
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.js +245 -121
- package/dist/runtime.js.map +1 -1
- package/dist/{schema-Cn0-xz8L.d.ts → schema-BxiVsU-d.d.ts} +68 -2
- package/dist/telemetry.d.ts +22 -65
- package/dist/telemetry.js +657 -69
- package/dist/telemetry.js.map +1 -1
- package/dist/testing.d.ts +3 -3
- package/dist/testing.js +659 -535
- package/dist/testing.js.map +1 -1
- package/package.json +9 -9
package/dist/config.js
CHANGED
|
@@ -284,37 +284,361 @@ var sanitizeResourceAttributes = (attributes) => {
|
|
|
284
284
|
var describeResourceAttributeNames = (attributes) => Object.keys(attributes).sort();
|
|
285
285
|
|
|
286
286
|
// src/config/schema.ts
|
|
287
|
+
import { z as z5 } from "zod";
|
|
288
|
+
|
|
289
|
+
// src/config/destinations.ts
|
|
287
290
|
import { z as z4 } from "zod";
|
|
288
|
-
|
|
289
|
-
|
|
291
|
+
|
|
292
|
+
// src/config/header-value.ts
|
|
293
|
+
var isUnsafeHeaderValue = (value) => [...value].some((char) => {
|
|
294
|
+
const code = char.codePointAt(0) ?? 0;
|
|
295
|
+
return code < 32 && code !== 9 || code === 127 || code > 255;
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
// src/config/otlp-headers.ts
|
|
299
|
+
var MAX_OTLP_HEADERS = 32;
|
|
300
|
+
var OTLP_HEADER_VARIABLES = Object.freeze({
|
|
301
|
+
generic: "OTEL_EXPORTER_OTLP_HEADERS",
|
|
302
|
+
traces: "OTEL_EXPORTER_OTLP_TRACES_HEADERS",
|
|
303
|
+
logs: "OTEL_EXPORTER_OTLP_LOGS_HEADERS"
|
|
304
|
+
});
|
|
305
|
+
var HEADER_NAME_PATTERN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
306
|
+
var decode = (raw) => {
|
|
307
|
+
try {
|
|
308
|
+
return decodeURIComponent(raw);
|
|
309
|
+
} catch {
|
|
310
|
+
return void 0;
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
var parseOtlpHeadersValue = (raw) => {
|
|
314
|
+
const headers = {};
|
|
315
|
+
const warnings = [];
|
|
316
|
+
let overflowed = false;
|
|
317
|
+
for (const [index, rawEntry] of raw.split(",").entries()) {
|
|
318
|
+
const position = String(index + 1);
|
|
319
|
+
const entry = rawEntry.trim();
|
|
320
|
+
if (entry === "") {
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
const equals = entry.indexOf("=");
|
|
324
|
+
if (equals <= 0) {
|
|
325
|
+
warnings.push(`entry ${position} is not a key=value pair; ignored`);
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
const key = decode(entry.slice(0, equals).trim());
|
|
329
|
+
const value = decode(entry.slice(equals + 1).trim());
|
|
330
|
+
if (key === void 0 || value === void 0) {
|
|
331
|
+
warnings.push(`entry ${position} has malformed percent-encoding; ignored`);
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
const name = key.trim();
|
|
335
|
+
const trimmedValue = value.trim();
|
|
336
|
+
if (!HEADER_NAME_PATTERN.test(name)) {
|
|
337
|
+
warnings.push(`entry ${position} does not name a valid HTTP header; ignored`);
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
if (trimmedValue === "") {
|
|
341
|
+
warnings.push(`entry ${position} has an empty value; ignored`);
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
if (isUnsafeHeaderValue(trimmedValue)) {
|
|
345
|
+
warnings.push(`entry ${position} has a character not allowed in an HTTP header value; ignored`);
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
const existing = findHeaderName(headers, name);
|
|
349
|
+
if (existing === void 0 && Object.keys(headers).length >= MAX_OTLP_HEADERS) {
|
|
350
|
+
overflowed = true;
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
if (existing !== void 0) {
|
|
354
|
+
delete headers[existing];
|
|
355
|
+
}
|
|
356
|
+
headers[name] = trimmedValue;
|
|
357
|
+
}
|
|
358
|
+
if (overflowed) {
|
|
359
|
+
warnings.push(`more than ${String(MAX_OTLP_HEADERS)} headers were supplied; the excess was ignored`);
|
|
360
|
+
}
|
|
361
|
+
return { headers, warnings };
|
|
362
|
+
};
|
|
363
|
+
var findHeaderName = (headers, name) => {
|
|
364
|
+
const lower = name.toLowerCase();
|
|
365
|
+
return Object.keys(headers).find((candidate) => candidate.toLowerCase() === lower);
|
|
366
|
+
};
|
|
367
|
+
var mergeOtlpHeaders = (...sources) => {
|
|
368
|
+
const merged = {};
|
|
369
|
+
for (const source of sources) {
|
|
370
|
+
for (const [name, value] of Object.entries(source)) {
|
|
371
|
+
const existing = findHeaderName(merged, name);
|
|
372
|
+
if (existing !== void 0) {
|
|
373
|
+
delete merged[existing];
|
|
374
|
+
}
|
|
375
|
+
merged[name] = value;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return merged;
|
|
379
|
+
};
|
|
380
|
+
var resolveOtlpHeaders = (env, explicit = {}) => {
|
|
381
|
+
const warnings = [];
|
|
382
|
+
const read = (variable) => {
|
|
383
|
+
const raw = env[variable];
|
|
384
|
+
if (raw === void 0 || raw.trim() === "") {
|
|
385
|
+
return {};
|
|
386
|
+
}
|
|
387
|
+
const parsed = parseOtlpHeadersValue(raw);
|
|
388
|
+
for (const detail of parsed.warnings) {
|
|
389
|
+
warnings.push({ variable, detail });
|
|
390
|
+
}
|
|
391
|
+
return parsed.headers;
|
|
392
|
+
};
|
|
393
|
+
const generic = read(OTLP_HEADER_VARIABLES.generic);
|
|
394
|
+
const traces = read(OTLP_HEADER_VARIABLES.traces);
|
|
395
|
+
const logs = read(OTLP_HEADER_VARIABLES.logs);
|
|
396
|
+
return {
|
|
397
|
+
traces: mergeOtlpHeaders(generic, traces, explicit),
|
|
398
|
+
logs: mergeOtlpHeaders(generic, logs, explicit),
|
|
399
|
+
warnings
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
var unionOtlpHeaderNames = (...lists) => {
|
|
403
|
+
const names = [];
|
|
404
|
+
const seen = /* @__PURE__ */ new Set();
|
|
405
|
+
for (const name of lists.flat()) {
|
|
406
|
+
if (!seen.has(name.toLowerCase())) {
|
|
407
|
+
seen.add(name.toLowerCase());
|
|
408
|
+
names.push(name);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return names.sort().slice(0, MAX_OTLP_HEADERS);
|
|
412
|
+
};
|
|
413
|
+
var describeOtlpHeaderNames = (...sources) => unionOtlpHeaderNames(...sources.map((source) => Object.keys(source)));
|
|
414
|
+
|
|
415
|
+
// src/config/destinations.ts
|
|
416
|
+
var DEFAULT_DESTINATION_NAME = "default";
|
|
417
|
+
var DESTINATION_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]{0,62}$/;
|
|
418
|
+
var MAX_EXPORT_DESTINATIONS = 16;
|
|
419
|
+
var MAX_DESTINATION_HEADERS = MAX_OTLP_HEADERS;
|
|
420
|
+
var HEADER_ENV_REFERENCE_PREFIX = "env:";
|
|
421
|
+
var HEADER_NAME_PATTERN2 = /^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/;
|
|
422
|
+
var ENV_VARIABLE_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
423
|
+
var MAX_HEADER_VALUE_LENGTH = 8192;
|
|
424
|
+
var exportSignalSchema = z4.enum(["traces", "logs"]);
|
|
425
|
+
var headerValueSchema = z4.string().min(1).max(MAX_HEADER_VALUE_LENGTH).refine(
|
|
426
|
+
(value) => !isUnsafeHeaderValue(value),
|
|
427
|
+
"header values may not contain line breaks, control characters, or characters beyond Latin-1"
|
|
428
|
+
).refine(
|
|
429
|
+
(value) => !value.startsWith(HEADER_ENV_REFERENCE_PREFIX) || ENV_VARIABLE_NAME_PATTERN.test(value.slice(HEADER_ENV_REFERENCE_PREFIX.length)),
|
|
430
|
+
"an env: header reference must name an environment variable, e.g. env:COLLECTOR_TOKEN"
|
|
431
|
+
);
|
|
432
|
+
var endpointSchema = z4.string().url().max(2048);
|
|
433
|
+
var exportDestinationSchema = z4.strictObject({
|
|
434
|
+
/** Unique, lowercase, filesystem-safe. `default` is reserved for the single-endpoint settings. */
|
|
435
|
+
name: z4.string().regex(DESTINATION_NAME_PATTERN, "destination names are lowercase letters, digits, _ and -"),
|
|
436
|
+
/** Default true. A disabled destination is neither sent to nor drained. */
|
|
437
|
+
enabled: z4.boolean().optional(),
|
|
438
|
+
/**
|
|
439
|
+
* Traces URL, with the same meaning as `exporter.endpoint`: the logs URL is
|
|
440
|
+
* derived from it (`/v1/traces` becomes `/v1/logs`) unless `logsEndpoint` is set.
|
|
441
|
+
*/
|
|
442
|
+
endpoint: endpointSchema.optional(),
|
|
443
|
+
/** Per-signal override of `endpoint` for traces. */
|
|
444
|
+
tracesEndpoint: endpointSchema.optional(),
|
|
445
|
+
/** Per-signal override of the derived logs URL. */
|
|
446
|
+
logsEndpoint: endpointSchema.optional(),
|
|
447
|
+
/** Defaults to `exporter.protocol`. */
|
|
448
|
+
protocol: z4.enum(["http/protobuf", "http/json", "none"]).optional(),
|
|
449
|
+
/**
|
|
450
|
+
* Header name to value. A value of the form `env:NAME` is read from that
|
|
451
|
+
* environment variable at send time, so a credential never has to be written
|
|
452
|
+
* into the file. Values never appear in a snapshot, a diagnostic, or `doctor`.
|
|
453
|
+
*/
|
|
454
|
+
headers: z4.record(z4.string().regex(HEADER_NAME_PATTERN2, "not a valid header name"), headerValueSchema).refine(
|
|
455
|
+
(headers) => Object.keys(headers).length <= MAX_DESTINATION_HEADERS,
|
|
456
|
+
`at most ${String(MAX_DESTINATION_HEADERS)} headers per destination`
|
|
457
|
+
).optional(),
|
|
458
|
+
/**
|
|
459
|
+
* Which signals this destination receives. Default: both. The logs signal is
|
|
460
|
+
* still governed by `exporter.logs.enabled`, which stays the one opt-in for a
|
|
461
|
+
* second stream leaving the host.
|
|
462
|
+
*/
|
|
463
|
+
signals: z4.array(exportSignalSchema).min(1).max(2).readonly().optional()
|
|
464
|
+
}).refine(
|
|
465
|
+
(destination) => destination.endpoint !== void 0 || destination.tracesEndpoint !== void 0 || destination.logsEndpoint !== void 0,
|
|
466
|
+
"a destination needs an endpoint, or a tracesEndpoint / logsEndpoint"
|
|
467
|
+
);
|
|
468
|
+
var exportDestinationsSchema = z4.array(exportDestinationSchema).max(MAX_EXPORT_DESTINATIONS).readonly().superRefine((destinations, context) => {
|
|
469
|
+
const seen = /* @__PURE__ */ new Set();
|
|
470
|
+
destinations.forEach((destination, index) => {
|
|
471
|
+
if (destination.name === DEFAULT_DESTINATION_NAME) {
|
|
472
|
+
context.addIssue({
|
|
473
|
+
code: "custom",
|
|
474
|
+
path: [index, "name"],
|
|
475
|
+
message: 'the name "default" is reserved for exporter.endpoint and the OTEL_EXPORTER_OTLP_* variables'
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
if (seen.has(destination.name)) {
|
|
479
|
+
context.addIssue({
|
|
480
|
+
code: "custom",
|
|
481
|
+
path: [index, "name"],
|
|
482
|
+
message: `duplicate destination name "${destination.name}"`
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
seen.add(destination.name);
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
var spoolPolicySchema = z4.strictObject({
|
|
489
|
+
/** Total bytes of queued batches. Default 16 MiB. */
|
|
490
|
+
maxBytes: z4.number().int().min(1024).max(1073741824),
|
|
491
|
+
/** A batch older than this is dropped instead of sent. Default 72 hours. */
|
|
492
|
+
maxAgeMillis: z4.number().int().min(1e3).max(30 * 24 * 60 * 60 * 1e3),
|
|
493
|
+
/** Number of queued batches. Default 500. */
|
|
494
|
+
maxBatches: z4.number().int().min(1).max(65536)
|
|
495
|
+
});
|
|
496
|
+
var DEFAULT_SPOOL_POLICY = Object.freeze({
|
|
497
|
+
maxBytes: 16 * 1024 * 1024,
|
|
498
|
+
maxAgeMillis: 72 * 60 * 60 * 1e3,
|
|
499
|
+
maxBatches: 500
|
|
500
|
+
});
|
|
501
|
+
var effectiveSpoolPolicy = (exporter) => ({
|
|
502
|
+
maxBytes: exporter.spool?.maxBytes ?? DEFAULT_SPOOL_POLICY.maxBytes,
|
|
503
|
+
maxAgeMillis: exporter.spool?.maxAgeMillis ?? DEFAULT_SPOOL_POLICY.maxAgeMillis,
|
|
504
|
+
maxBatches: exporter.spool?.maxBatches ?? DEFAULT_SPOOL_POLICY.maxBatches
|
|
505
|
+
});
|
|
506
|
+
var legacyDestination = (exporter) => ({
|
|
507
|
+
name: DEFAULT_DESTINATION_NAME,
|
|
508
|
+
source: "exporter",
|
|
509
|
+
protocol: exporter.protocol,
|
|
510
|
+
...exporter.endpoint === void 0 ? {} : { endpoint: exporter.endpoint },
|
|
511
|
+
...exporter.logs.endpoint === void 0 ? {} : { logsEndpoint: exporter.logs.endpoint },
|
|
512
|
+
signals: { traces: true, logs: exporter.logs.enabled },
|
|
513
|
+
headers: {}
|
|
514
|
+
});
|
|
515
|
+
var hasConfiguredDestinations = (exporter) => exporter.destinations !== void 0 && exporter.destinations.length > 0;
|
|
516
|
+
var resolveExportDestinations = (exporter) => {
|
|
517
|
+
if (!hasConfiguredDestinations(exporter)) {
|
|
518
|
+
return [legacyDestination(exporter)];
|
|
519
|
+
}
|
|
520
|
+
const resolved = [];
|
|
521
|
+
if (exporter.endpoint !== void 0 || exporter.logs.endpoint !== void 0) {
|
|
522
|
+
resolved.push(legacyDestination(exporter));
|
|
523
|
+
}
|
|
524
|
+
for (const destination of exporter.destinations ?? []) {
|
|
525
|
+
if (destination.enabled === false) {
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
const signals = destination.signals ?? exportSignalSchema.options;
|
|
529
|
+
resolved.push({
|
|
530
|
+
name: destination.name,
|
|
531
|
+
source: "destinations",
|
|
532
|
+
protocol: destination.protocol ?? exporter.protocol,
|
|
533
|
+
...destination.endpoint === void 0 ? {} : { endpoint: destination.endpoint },
|
|
534
|
+
...destination.tracesEndpoint === void 0 ? {} : { tracesEndpoint: destination.tracesEndpoint },
|
|
535
|
+
...destination.logsEndpoint === void 0 ? {} : { logsEndpoint: destination.logsEndpoint },
|
|
536
|
+
signals: {
|
|
537
|
+
traces: signals.includes("traces"),
|
|
538
|
+
logs: exporter.logs.enabled && signals.includes("logs")
|
|
539
|
+
},
|
|
540
|
+
headers: { ...destination.headers ?? {} }
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
return resolved;
|
|
544
|
+
};
|
|
545
|
+
var parseHeaderValueReference = (value) => value.startsWith(HEADER_ENV_REFERENCE_PREFIX) ? { kind: "env", variable: value.slice(HEADER_ENV_REFERENCE_PREFIX.length) } : { kind: "literal" };
|
|
546
|
+
var resolveDestinationHeaders = (headers, environment) => {
|
|
547
|
+
const values = {};
|
|
548
|
+
const missing = [];
|
|
549
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
550
|
+
const reference = parseHeaderValueReference(value);
|
|
551
|
+
if (reference.kind === "literal") {
|
|
552
|
+
values[name] = value;
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
const resolved = environment?.[reference.variable];
|
|
556
|
+
if (resolved === void 0 || resolved === "") {
|
|
557
|
+
missing.push(reference.variable);
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
|
+
values[name] = resolved;
|
|
561
|
+
}
|
|
562
|
+
return { values, missingVariables: [...new Set(missing)].sort() };
|
|
563
|
+
};
|
|
564
|
+
var endpointOrigin = (endpoint) => {
|
|
565
|
+
if (endpoint === void 0) {
|
|
566
|
+
return void 0;
|
|
567
|
+
}
|
|
568
|
+
try {
|
|
569
|
+
return new URL(endpoint).origin;
|
|
570
|
+
} catch {
|
|
571
|
+
return "<unparsable>";
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
var describeExportDestinations = (exporter) => {
|
|
575
|
+
const describe = (destination, enabled2) => {
|
|
576
|
+
const tracesOrigin = endpointOrigin(destination.tracesEndpoint ?? destination.endpoint);
|
|
577
|
+
const logsOrigin = endpointOrigin(
|
|
578
|
+
destination.logsEndpoint ?? destination.endpoint ?? destination.tracesEndpoint
|
|
579
|
+
);
|
|
580
|
+
const variables = Object.values(destination.headers).map(parseHeaderValueReference).flatMap((reference) => reference.kind === "env" ? [reference.variable] : []);
|
|
581
|
+
return {
|
|
582
|
+
name: destination.name,
|
|
583
|
+
enabled: enabled2,
|
|
584
|
+
protocol: destination.protocol,
|
|
585
|
+
signals: exportSignalSchema.options.filter((signal) => destination.signals[signal]),
|
|
586
|
+
...tracesOrigin === void 0 || !destination.signals.traces ? {} : { tracesEndpointOrigin: tracesOrigin },
|
|
587
|
+
...logsOrigin === void 0 || !destination.signals.logs ? {} : { logsEndpointOrigin: logsOrigin },
|
|
588
|
+
headerNames: destination.source === "exporter" ? [...exporter.headerNames].sort() : Object.keys(destination.headers).sort(),
|
|
589
|
+
headerVariables: [...new Set(variables)].sort()
|
|
590
|
+
};
|
|
591
|
+
};
|
|
592
|
+
const enabled = resolveExportDestinations(exporter).map(
|
|
593
|
+
(destination) => describe(destination, true)
|
|
594
|
+
);
|
|
595
|
+
const disabled = (exporter.destinations ?? []).filter((destination) => destination.enabled === false).map(
|
|
596
|
+
(destination) => describe(
|
|
597
|
+
{
|
|
598
|
+
name: destination.name,
|
|
599
|
+
source: "destinations",
|
|
600
|
+
protocol: destination.protocol ?? exporter.protocol,
|
|
601
|
+
...destination.endpoint === void 0 ? {} : { endpoint: destination.endpoint },
|
|
602
|
+
signals: { traces: false, logs: false },
|
|
603
|
+
headers: { ...destination.headers ?? {} }
|
|
604
|
+
},
|
|
605
|
+
false
|
|
606
|
+
)
|
|
607
|
+
);
|
|
608
|
+
return [...enabled, ...disabled];
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
// src/config/schema.ts
|
|
612
|
+
var logsPolicySchema = z5.strictObject({
|
|
613
|
+
enabled: z5.boolean(),
|
|
290
614
|
/**
|
|
291
615
|
* Full URL for the logs signal.
|
|
292
616
|
*
|
|
293
617
|
* Absent, it is derived from `endpoint`: a trailing `/v1/traces` becomes
|
|
294
618
|
* `/v1/logs`, and an endpoint with no signal path has `/v1/logs` appended.
|
|
295
619
|
*/
|
|
296
|
-
endpoint:
|
|
297
|
-
includeContent:
|
|
298
|
-
maxBatchSize:
|
|
620
|
+
endpoint: z5.string().url().max(2048).optional(),
|
|
621
|
+
includeContent: z5.boolean(),
|
|
622
|
+
maxBatchSize: z5.number().int().min(1).max(4096)
|
|
299
623
|
});
|
|
300
624
|
var DEFAULT_LOGS_POLICY = Object.freeze({
|
|
301
625
|
enabled: false,
|
|
302
626
|
includeContent: false,
|
|
303
627
|
maxBatchSize: 128
|
|
304
628
|
});
|
|
305
|
-
var exporterPolicySchema =
|
|
306
|
-
enabled:
|
|
307
|
-
protocol:
|
|
308
|
-
endpoint:
|
|
629
|
+
var exporterPolicySchema = z5.strictObject({
|
|
630
|
+
enabled: z5.boolean(),
|
|
631
|
+
protocol: z5.enum(["http/protobuf", "http/json", "none"]),
|
|
632
|
+
endpoint: z5.string().url().max(2048).optional(),
|
|
309
633
|
/**
|
|
310
634
|
* Header names only. Values are supplied separately at construction time and
|
|
311
635
|
* are never part of a resolved-config snapshot, which is logged and exported.
|
|
312
636
|
*/
|
|
313
|
-
headerNames:
|
|
314
|
-
timeoutMillis:
|
|
315
|
-
maxBatchSize:
|
|
316
|
-
maxQueueSize:
|
|
317
|
-
maxRetryAttempts:
|
|
637
|
+
headerNames: z5.array(nonEmptyStringSchema).max(32).readonly(),
|
|
638
|
+
timeoutMillis: z5.number().int().min(1).max(6e5),
|
|
639
|
+
maxBatchSize: z5.number().int().min(1).max(4096),
|
|
640
|
+
maxQueueSize: z5.number().int().min(1).max(65536),
|
|
641
|
+
maxRetryAttempts: z5.number().int().min(0).max(10),
|
|
318
642
|
serviceName: nonEmptyStringSchema,
|
|
319
643
|
serviceNamespace: nonEmptyStringSchema.optional(),
|
|
320
644
|
/**
|
|
@@ -331,32 +655,52 @@ var exporterPolicySchema = z4.strictObject({
|
|
|
331
655
|
* headers, timeout, protocol, service identity, and resource attributes above —
|
|
332
656
|
* a second top-level section would invite two of each to drift apart.
|
|
333
657
|
*/
|
|
334
|
-
logs: logsPolicySchema
|
|
658
|
+
logs: logsPolicySchema,
|
|
659
|
+
/**
|
|
660
|
+
* Additional OTLP destinations, each sent every batch in parallel.
|
|
661
|
+
*
|
|
662
|
+
* Absent (the default), the exporter has exactly one destination — the
|
|
663
|
+
* single-endpoint settings above, named `default` — and behaves exactly as it
|
|
664
|
+
* did before this list existed. See `destinations.ts`.
|
|
665
|
+
*
|
|
666
|
+
* Merged as one leaf: a higher layer that sets the list replaces it whole,
|
|
667
|
+
* because "the union of two partial lists" has no answer an operator could
|
|
668
|
+
* predict.
|
|
669
|
+
*/
|
|
670
|
+
destinations: exportDestinationsSchema.optional(),
|
|
671
|
+
/**
|
|
672
|
+
* Per-destination retry spool bounds, each optional and merged per leaf; any
|
|
673
|
+
* bound left unset takes its value from `DEFAULT_SPOOL_POLICY`.
|
|
674
|
+
*/
|
|
675
|
+
spool: spoolPolicySchema.partial().optional()
|
|
335
676
|
});
|
|
336
|
-
var detectionPolicySchema =
|
|
677
|
+
var detectionPolicySchema = z5.strictObject({
|
|
337
678
|
/** Detections below this confidence resolve to the unknown provider. */
|
|
338
679
|
minimumConfidence: detectionConfidenceSchema,
|
|
339
680
|
/** When false, an ambiguous detection is an error rather than unknown. */
|
|
340
|
-
allowAmbiguousFallback:
|
|
681
|
+
allowAmbiguousFallback: z5.boolean(),
|
|
341
682
|
/** Optional allow-list of provider ids; empty means "any registered". */
|
|
342
|
-
allowedProviderIds:
|
|
683
|
+
allowedProviderIds: z5.array(nonEmptyStringSchema).max(32).readonly()
|
|
343
684
|
});
|
|
344
|
-
var diagnosticsPolicySchema =
|
|
345
|
-
logLevel:
|
|
685
|
+
var diagnosticsPolicySchema = z5.strictObject({
|
|
686
|
+
logLevel: z5.enum(["silent", "error", "warn", "info", "debug"]),
|
|
346
687
|
/** Emit `error.raised` events for contained failures. */
|
|
347
|
-
emitErrorEvents:
|
|
688
|
+
emitErrorEvents: z5.boolean()
|
|
348
689
|
});
|
|
349
|
-
var otelHookConfigSchema =
|
|
690
|
+
var otelHookConfigSchema = z5.strictObject({
|
|
350
691
|
exporter: exporterPolicySchema,
|
|
351
692
|
privacy: privacyPolicySchema,
|
|
352
693
|
detection: detectionPolicySchema,
|
|
353
694
|
diagnostics: diagnosticsPolicySchema
|
|
354
695
|
});
|
|
355
|
-
var otelHookConfigPatchSchema =
|
|
696
|
+
var otelHookConfigPatchSchema = z5.strictObject({
|
|
356
697
|
// `logs` is unwrapped and re-partialled for the same reason `privacy.limits` is:
|
|
357
698
|
// merging happens per leaf, so a layer must be able to set `logs.enabled` alone
|
|
358
699
|
// without also restating the endpoint and the batch size.
|
|
359
|
-
exporter: exporterPolicySchema.omit({ logs: true }).partial().extend({
|
|
700
|
+
exporter: exporterPolicySchema.omit({ logs: true, spool: true }).partial().extend({
|
|
701
|
+
logs: logsPolicySchema.partial().optional(),
|
|
702
|
+
spool: spoolPolicySchema.partial().optional()
|
|
703
|
+
}).optional(),
|
|
360
704
|
privacy: privacyPolicySchema.omit({ limits: true }).partial().extend({ limits: privacyPolicySchema.shape.limits.partial().optional() }).optional(),
|
|
361
705
|
detection: detectionPolicySchema.partial().optional(),
|
|
362
706
|
diagnostics: diagnosticsPolicySchema.partial().optional()
|
|
@@ -390,14 +734,14 @@ var DEFAULT_CONFIG = Object.freeze({
|
|
|
390
734
|
});
|
|
391
735
|
|
|
392
736
|
// src/config/resolve.ts
|
|
393
|
-
import { z as
|
|
737
|
+
import { z as z8 } from "zod";
|
|
394
738
|
|
|
395
739
|
// src/errors/index.ts
|
|
396
|
-
import { z as
|
|
740
|
+
import { z as z7 } from "zod";
|
|
397
741
|
|
|
398
742
|
// src/errors/taxonomy.ts
|
|
399
|
-
import { z as
|
|
400
|
-
var otelHookErrorCodeSchema =
|
|
743
|
+
import { z as z6 } from "zod";
|
|
744
|
+
var otelHookErrorCodeSchema = z6.enum([
|
|
401
745
|
/** Input was not usable at all (empty stdin, unparsable JSON). */
|
|
402
746
|
"invalid-input",
|
|
403
747
|
/** Input parsed but failed canonical schema validation. */
|
|
@@ -433,8 +777,8 @@ var otelHookErrorCodeSchema = z5.enum([
|
|
|
433
777
|
/** Anything unanticipated. Always reported, never fatal to the host. */
|
|
434
778
|
"internal-error"
|
|
435
779
|
]);
|
|
436
|
-
var errorSeveritySchema =
|
|
437
|
-
var errorPhaseSchema =
|
|
780
|
+
var errorSeveritySchema = z6.enum(["warning", "error"]);
|
|
781
|
+
var errorPhaseSchema = z6.enum([
|
|
438
782
|
"configuration",
|
|
439
783
|
"detection",
|
|
440
784
|
"identity",
|
|
@@ -445,7 +789,7 @@ var errorPhaseSchema = z5.enum([
|
|
|
445
789
|
"export",
|
|
446
790
|
"shutdown"
|
|
447
791
|
]);
|
|
448
|
-
var failurePostureSchema =
|
|
792
|
+
var failurePostureSchema = z6.enum(["fail-open", "fail-closed-attribution"]);
|
|
449
793
|
var ERROR_TAXONOMY = Object.freeze({
|
|
450
794
|
"invalid-input": {
|
|
451
795
|
code: "invalid-input",
|
|
@@ -570,7 +914,7 @@ var ERROR_TAXONOMY = Object.freeze({
|
|
|
570
914
|
}
|
|
571
915
|
});
|
|
572
916
|
var describeErrorCode = (code) => ERROR_TAXONOMY[code];
|
|
573
|
-
var attributionOutcomeSchema =
|
|
917
|
+
var attributionOutcomeSchema = z6.enum([
|
|
574
918
|
/** Identity resolved; events carry provider and session identity. */
|
|
575
919
|
"attributed",
|
|
576
920
|
/** Identity could not be established safely; nothing was attributed. */
|
|
@@ -580,7 +924,7 @@ var attributionOutcomeSchema = z5.enum([
|
|
|
580
924
|
/** Input was recognized but intentionally carried no telemetry. */
|
|
581
925
|
"not-applicable"
|
|
582
926
|
]);
|
|
583
|
-
var attributionReasonSchema =
|
|
927
|
+
var attributionReasonSchema = z6.enum([
|
|
584
928
|
"provider-unknown",
|
|
585
929
|
"provider-detection-ambiguous",
|
|
586
930
|
"identity-conflict",
|
|
@@ -592,13 +936,13 @@ var attributionReasonSchema = z5.enum([
|
|
|
592
936
|
]);
|
|
593
937
|
|
|
594
938
|
// src/errors/index.ts
|
|
595
|
-
var otelHookErrorInfoSchema =
|
|
939
|
+
var otelHookErrorInfoSchema = z7.strictObject({
|
|
596
940
|
code: otelHookErrorCodeSchema,
|
|
597
941
|
severity: errorSeveritySchema,
|
|
598
942
|
phase: errorPhaseSchema,
|
|
599
943
|
posture: failurePostureSchema,
|
|
600
|
-
retryable:
|
|
601
|
-
message:
|
|
944
|
+
retryable: z7.boolean(),
|
|
945
|
+
message: z7.string().min(1).max(512),
|
|
602
946
|
details: attributesSchema.optional(),
|
|
603
947
|
occurredAt: epochMillisSchema.optional()
|
|
604
948
|
});
|
|
@@ -619,7 +963,7 @@ var createErrorInfo = (input) => {
|
|
|
619
963
|
|
|
620
964
|
// src/config/resolve.ts
|
|
621
965
|
var CONFIG_SOURCE_PRECEDENCE = ["defaults", "file", "environment", "inline-override"];
|
|
622
|
-
var configSourceSchema =
|
|
966
|
+
var configSourceSchema = z8.enum(CONFIG_SOURCE_PRECEDENCE);
|
|
623
967
|
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
624
968
|
var mergeLeaf = (target, patch, source, provenance, path) => {
|
|
625
969
|
for (const [key, value] of Object.entries(patch)) {
|
|
@@ -628,8 +972,8 @@ var mergeLeaf = (target, patch, source, provenance, path) => {
|
|
|
628
972
|
}
|
|
629
973
|
const childPath = path === "" ? key : `${path}.${key}`;
|
|
630
974
|
const existing = target[key];
|
|
631
|
-
if (isPlainObject(value) && isPlainObject(existing)) {
|
|
632
|
-
const child = { ...existing };
|
|
975
|
+
if (isPlainObject(value) && (isPlainObject(existing) || existing === void 0)) {
|
|
976
|
+
const child = { ...existing ?? {} };
|
|
633
977
|
mergeLeaf(child, value, source, provenance, childPath);
|
|
634
978
|
target[key] = child;
|
|
635
979
|
continue;
|
|
@@ -701,10 +1045,27 @@ var resolveConfig = (layers = []) => {
|
|
|
701
1045
|
if (parsed.data.privacy.contentMode === "raw" && !parsed.data.privacy.allowRawContent) {
|
|
702
1046
|
notes.push("privacy.contentMode=raw will be downgraded to omit: allowRawContent is false");
|
|
703
1047
|
}
|
|
704
|
-
|
|
1048
|
+
const withDestinations = hasConfiguredDestinations(parsed.data.exporter);
|
|
1049
|
+
if (parsed.data.exporter.enabled && parsed.data.exporter.protocol !== "none" && parsed.data.exporter.endpoint === void 0 && !withDestinations) {
|
|
705
1050
|
notes.push("exporter.enabled is true but no endpoint is configured");
|
|
706
1051
|
}
|
|
707
|
-
if (
|
|
1052
|
+
if (withDestinations) {
|
|
1053
|
+
const enabled = (parsed.data.exporter.destinations ?? []).filter(
|
|
1054
|
+
(destination) => destination.enabled !== false
|
|
1055
|
+
);
|
|
1056
|
+
if (enabled.length === 0 && parsed.data.exporter.endpoint === void 0) {
|
|
1057
|
+
notes.push("exporter.destinations is set but every destination is disabled");
|
|
1058
|
+
}
|
|
1059
|
+
if (!parsed.data.exporter.logs.enabled) {
|
|
1060
|
+
const askingForLogs = enabled.filter((destination) => destination.signals?.includes("logs") === true).map((destination) => destination.name);
|
|
1061
|
+
if (askingForLogs.length > 0) {
|
|
1062
|
+
notes.push(
|
|
1063
|
+
`destination(s) ${askingForLogs.join(", ")} list the logs signal but exporter.logs.enabled is false, so only traces are sent`
|
|
1064
|
+
);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
if (!withDestinations && parsed.data.exporter.logs.enabled && parsed.data.exporter.logs.endpoint === void 0 && parsed.data.exporter.endpoint === void 0) {
|
|
708
1069
|
notes.push(
|
|
709
1070
|
"exporter.logs.enabled is true but neither a logs endpoint nor a trace endpoint to derive one from is configured"
|
|
710
1071
|
);
|
|
@@ -716,6 +1077,35 @@ var resolveConfig = (layers = []) => {
|
|
|
716
1077
|
}
|
|
717
1078
|
return { status: "ok", config: parsed.data, provenance, notes };
|
|
718
1079
|
};
|
|
1080
|
+
var describeDestinationAttributes = (config) => {
|
|
1081
|
+
const attributes = {};
|
|
1082
|
+
if (config.exporter.spool !== void 0 || hasConfiguredDestinations(config.exporter)) {
|
|
1083
|
+
const spool = effectiveSpoolPolicy(config.exporter);
|
|
1084
|
+
attributes["exporter.spool_max_bytes"] = spool.maxBytes;
|
|
1085
|
+
attributes["exporter.spool_max_age_millis"] = spool.maxAgeMillis;
|
|
1086
|
+
attributes["exporter.spool_max_batches"] = spool.maxBatches;
|
|
1087
|
+
}
|
|
1088
|
+
if (!hasConfiguredDestinations(config.exporter)) {
|
|
1089
|
+
return attributes;
|
|
1090
|
+
}
|
|
1091
|
+
const destinations = describeExportDestinations(config.exporter);
|
|
1092
|
+
attributes["exporter.destination_names"] = destinations.map((destination) => destination.name);
|
|
1093
|
+
for (const destination of destinations) {
|
|
1094
|
+
const prefix = `exporter.destination.${destination.name}`;
|
|
1095
|
+
attributes[`${prefix}.enabled`] = destination.enabled;
|
|
1096
|
+
attributes[`${prefix}.protocol`] = destination.protocol;
|
|
1097
|
+
attributes[`${prefix}.signals`] = [...destination.signals];
|
|
1098
|
+
if (destination.tracesEndpointOrigin !== void 0) {
|
|
1099
|
+
attributes[`${prefix}.traces_endpoint_origin`] = destination.tracesEndpointOrigin;
|
|
1100
|
+
}
|
|
1101
|
+
if (destination.logsEndpointOrigin !== void 0) {
|
|
1102
|
+
attributes[`${prefix}.logs_endpoint_origin`] = destination.logsEndpointOrigin;
|
|
1103
|
+
}
|
|
1104
|
+
attributes[`${prefix}.header_names`] = [...destination.headerNames];
|
|
1105
|
+
attributes[`${prefix}.header_variables`] = [...destination.headerVariables];
|
|
1106
|
+
}
|
|
1107
|
+
return attributes;
|
|
1108
|
+
};
|
|
719
1109
|
var describeResolvedConfig = (config) => {
|
|
720
1110
|
const originOf = (endpoint) => {
|
|
721
1111
|
if (endpoint === void 0) {
|
|
@@ -727,12 +1117,12 @@ var describeResolvedConfig = (config) => {
|
|
|
727
1117
|
return "<unparsable>";
|
|
728
1118
|
}
|
|
729
1119
|
};
|
|
730
|
-
const
|
|
1120
|
+
const endpointOrigin2 = originOf(config.exporter.endpoint);
|
|
731
1121
|
const logsEndpointOrigin = originOf(config.exporter.logs.endpoint);
|
|
732
1122
|
return {
|
|
733
1123
|
"exporter.enabled": config.exporter.enabled,
|
|
734
1124
|
"exporter.protocol": config.exporter.protocol,
|
|
735
|
-
...
|
|
1125
|
+
...endpointOrigin2 === void 0 ? {} : { "exporter.endpoint_origin": endpointOrigin2 },
|
|
736
1126
|
"exporter.logs_enabled": config.exporter.logs.enabled,
|
|
737
1127
|
"exporter.logs_include_content": config.exporter.logs.includeContent,
|
|
738
1128
|
"exporter.logs_max_batch_size": config.exporter.logs.maxBatchSize,
|
|
@@ -744,6 +1134,7 @@ var describeResolvedConfig = (config) => {
|
|
|
744
1134
|
"exporter.resource_attribute_names": [
|
|
745
1135
|
...describeResourceAttributeNames(config.exporter.resourceAttributes)
|
|
746
1136
|
],
|
|
1137
|
+
...describeDestinationAttributes(config),
|
|
747
1138
|
"exporter.timeout_millis": config.exporter.timeoutMillis,
|
|
748
1139
|
"exporter.max_batch_size": config.exporter.maxBatchSize,
|
|
749
1140
|
"exporter.service_name": config.exporter.serviceName,
|
|
@@ -761,131 +1152,39 @@ var describeResolvedConfig = (config) => {
|
|
|
761
1152
|
};
|
|
762
1153
|
};
|
|
763
1154
|
|
|
764
|
-
// src/config/otlp-
|
|
765
|
-
var
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
logs: "OTEL_EXPORTER_OTLP_LOGS_HEADERS"
|
|
770
|
-
});
|
|
771
|
-
var HEADER_NAME_PATTERN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
772
|
-
var isUnsafeHeaderValue = (value) => [...value].some((char) => {
|
|
773
|
-
const code = char.codePointAt(0) ?? 0;
|
|
774
|
-
return code < 32 && code !== 9 || code === 127 || code > 255;
|
|
1155
|
+
// src/config/otlp-endpoint.ts
|
|
1156
|
+
var OTLP_ENDPOINT_VARIABLES = Object.freeze({
|
|
1157
|
+
generic: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
1158
|
+
traces: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT",
|
|
1159
|
+
logs: "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT"
|
|
775
1160
|
});
|
|
776
|
-
var
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
1161
|
+
var OTLP_TRACES_PATH = "/v1/traces";
|
|
1162
|
+
var OTLP_LOGS_PATH = "/v1/logs";
|
|
1163
|
+
var withoutTrailingSlashes = (value) => {
|
|
1164
|
+
let end = value.length;
|
|
1165
|
+
while (end > 0 && value.charCodeAt(end - 1) === 47) {
|
|
1166
|
+
end -= 1;
|
|
781
1167
|
}
|
|
1168
|
+
return value.slice(0, end);
|
|
782
1169
|
};
|
|
783
|
-
var
|
|
784
|
-
const
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
for (const [index, rawEntry] of raw.split(",").entries()) {
|
|
788
|
-
const position = String(index + 1);
|
|
789
|
-
const entry = rawEntry.trim();
|
|
790
|
-
if (entry === "") {
|
|
791
|
-
continue;
|
|
792
|
-
}
|
|
793
|
-
const equals = entry.indexOf("=");
|
|
794
|
-
if (equals <= 0) {
|
|
795
|
-
warnings.push(`entry ${position} is not a key=value pair; ignored`);
|
|
796
|
-
continue;
|
|
797
|
-
}
|
|
798
|
-
const key = decode(entry.slice(0, equals).trim());
|
|
799
|
-
const value = decode(entry.slice(equals + 1).trim());
|
|
800
|
-
if (key === void 0 || value === void 0) {
|
|
801
|
-
warnings.push(`entry ${position} has malformed percent-encoding; ignored`);
|
|
802
|
-
continue;
|
|
803
|
-
}
|
|
804
|
-
const name = key.trim();
|
|
805
|
-
const trimmedValue = value.trim();
|
|
806
|
-
if (!HEADER_NAME_PATTERN.test(name)) {
|
|
807
|
-
warnings.push(`entry ${position} does not name a valid HTTP header; ignored`);
|
|
808
|
-
continue;
|
|
809
|
-
}
|
|
810
|
-
if (trimmedValue === "") {
|
|
811
|
-
warnings.push(`entry ${position} has an empty value; ignored`);
|
|
812
|
-
continue;
|
|
813
|
-
}
|
|
814
|
-
if (isUnsafeHeaderValue(trimmedValue)) {
|
|
815
|
-
warnings.push(`entry ${position} has a character not allowed in an HTTP header value; ignored`);
|
|
816
|
-
continue;
|
|
817
|
-
}
|
|
818
|
-
const existing = findHeaderName(headers, name);
|
|
819
|
-
if (existing === void 0 && Object.keys(headers).length >= MAX_OTLP_HEADERS) {
|
|
820
|
-
overflowed = true;
|
|
821
|
-
continue;
|
|
822
|
-
}
|
|
823
|
-
if (existing !== void 0) {
|
|
824
|
-
delete headers[existing];
|
|
825
|
-
}
|
|
826
|
-
headers[name] = trimmedValue;
|
|
827
|
-
}
|
|
828
|
-
if (overflowed) {
|
|
829
|
-
warnings.push(`more than ${String(MAX_OTLP_HEADERS)} headers were supplied; the excess was ignored`);
|
|
830
|
-
}
|
|
831
|
-
return { headers, warnings };
|
|
832
|
-
};
|
|
833
|
-
var findHeaderName = (headers, name) => {
|
|
834
|
-
const lower = name.toLowerCase();
|
|
835
|
-
return Object.keys(headers).find((candidate) => candidate.toLowerCase() === lower);
|
|
836
|
-
};
|
|
837
|
-
var mergeOtlpHeaders = (...sources) => {
|
|
838
|
-
const merged = {};
|
|
839
|
-
for (const source of sources) {
|
|
840
|
-
for (const [name, value] of Object.entries(source)) {
|
|
841
|
-
const existing = findHeaderName(merged, name);
|
|
842
|
-
if (existing !== void 0) {
|
|
843
|
-
delete merged[existing];
|
|
844
|
-
}
|
|
845
|
-
merged[name] = value;
|
|
846
|
-
}
|
|
1170
|
+
var otlpSignalEndpointFromBase = (base, signal) => {
|
|
1171
|
+
const trimmed = withoutTrailingSlashes(base);
|
|
1172
|
+
if (trimmed.endsWith(OTLP_TRACES_PATH)) {
|
|
1173
|
+
return signal === "traces" ? trimmed : `${trimmed.slice(0, trimmed.length - OTLP_TRACES_PATH.length)}${OTLP_LOGS_PATH}`;
|
|
847
1174
|
}
|
|
848
|
-
return
|
|
1175
|
+
return `${trimmed}${signal === "traces" ? OTLP_TRACES_PATH : OTLP_LOGS_PATH}`;
|
|
849
1176
|
};
|
|
850
|
-
var resolveOtlpHeaders = (env, explicit = {}) => {
|
|
851
|
-
const warnings = [];
|
|
852
|
-
const read = (variable) => {
|
|
853
|
-
const raw = env[variable];
|
|
854
|
-
if (raw === void 0 || raw.trim() === "") {
|
|
855
|
-
return {};
|
|
856
|
-
}
|
|
857
|
-
const parsed = parseOtlpHeadersValue(raw);
|
|
858
|
-
for (const detail of parsed.warnings) {
|
|
859
|
-
warnings.push({ variable, detail });
|
|
860
|
-
}
|
|
861
|
-
return parsed.headers;
|
|
862
|
-
};
|
|
863
|
-
const generic = read(OTLP_HEADER_VARIABLES.generic);
|
|
864
|
-
const traces = read(OTLP_HEADER_VARIABLES.traces);
|
|
865
|
-
const logs = read(OTLP_HEADER_VARIABLES.logs);
|
|
866
|
-
return {
|
|
867
|
-
traces: mergeOtlpHeaders(generic, traces, explicit),
|
|
868
|
-
logs: mergeOtlpHeaders(generic, logs, explicit),
|
|
869
|
-
warnings
|
|
870
|
-
};
|
|
871
|
-
};
|
|
872
|
-
var unionOtlpHeaderNames = (...lists) => {
|
|
873
|
-
const names = [];
|
|
874
|
-
const seen = /* @__PURE__ */ new Set();
|
|
875
|
-
for (const name of lists.flat()) {
|
|
876
|
-
if (!seen.has(name.toLowerCase())) {
|
|
877
|
-
seen.add(name.toLowerCase());
|
|
878
|
-
names.push(name);
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
return names.sort().slice(0, MAX_OTLP_HEADERS);
|
|
882
|
-
};
|
|
883
|
-
var describeOtlpHeaderNames = (...sources) => unionOtlpHeaderNames(...sources.map((source) => Object.keys(source)));
|
|
884
1177
|
|
|
885
1178
|
// src/config/environment.ts
|
|
886
1179
|
var ENVIRONMENT_VARIABLES = Object.freeze({
|
|
887
1180
|
exporterEnabled: "OTEL_HOOK_ENABLED",
|
|
1181
|
+
/** Full traces URL; otel-hook's own variable, above the standard ones. */
|
|
888
1182
|
exporterEndpoint: "OTEL_HOOK_EXPORTER_ENDPOINT",
|
|
1183
|
+
/**
|
|
1184
|
+
* Standard base URL: `/v1/traces` and `/v1/logs` are appended per signal. A
|
|
1185
|
+
* value already ending in `/v1/traces` is the legacy full traces URL and is
|
|
1186
|
+
* used as-is (see `otlpSignalEndpointFromBase`).
|
|
1187
|
+
*/
|
|
889
1188
|
otlpEndpoint: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
890
1189
|
exporterProtocol: "OTEL_HOOK_EXPORTER_PROTOCOL",
|
|
891
1190
|
exporterTimeoutMillis: "OTEL_HOOK_EXPORTER_TIMEOUT_MS",
|
|
@@ -959,7 +1258,10 @@ var parseEnvironmentConfig = (env) => {
|
|
|
959
1258
|
return trimmed === "" ? void 0 : trimmed;
|
|
960
1259
|
};
|
|
961
1260
|
const exporterEnabled = readBoolean(ENVIRONMENT_VARIABLES.exporterEnabled);
|
|
962
|
-
const
|
|
1261
|
+
const hookEndpoint = readString(ENVIRONMENT_VARIABLES.exporterEndpoint);
|
|
1262
|
+
const otlpTracesEndpoint = readString(OTLP_ENDPOINT_VARIABLES.traces);
|
|
1263
|
+
const otlpBaseEndpoint = readString(ENVIRONMENT_VARIABLES.otlpEndpoint);
|
|
1264
|
+
const endpoint = hookEndpoint ?? otlpTracesEndpoint ?? (otlpBaseEndpoint === void 0 ? void 0 : otlpSignalEndpointFromBase(otlpBaseEndpoint, "traces"));
|
|
963
1265
|
const timeoutMillis = readInteger(ENVIRONMENT_VARIABLES.exporterTimeoutMillis);
|
|
964
1266
|
const resourceRaw = readString(ENVIRONMENT_VARIABLES.resourceAttributes);
|
|
965
1267
|
const resource = resourceRaw === void 0 ? void 0 : parseResourceAttributesValue(resourceRaw);
|
|
@@ -1045,7 +1347,7 @@ var parseEnvironmentConfig = (env) => {
|
|
|
1045
1347
|
const maxEventsPerInvocation = readInteger(ENVIRONMENT_VARIABLES.maxEventsPerInvocation);
|
|
1046
1348
|
const logsEnabled = readBoolean(ENVIRONMENT_VARIABLES.logsEnabled);
|
|
1047
1349
|
const logsIncludeContent = readBoolean(ENVIRONMENT_VARIABLES.logsIncludeContent);
|
|
1048
|
-
const logsEndpoint = readString(ENVIRONMENT_VARIABLES.logsEndpoint) ?? readString(ENVIRONMENT_VARIABLES.otlpLogsEndpoint);
|
|
1350
|
+
const logsEndpoint = readString(ENVIRONMENT_VARIABLES.logsEndpoint) ?? readString(ENVIRONMENT_VARIABLES.otlpLogsEndpoint) ?? (hookEndpoint === void 0 && otlpTracesEndpoint !== void 0 && otlpBaseEndpoint !== void 0 ? otlpSignalEndpointFromBase(otlpBaseEndpoint, "logs") : void 0);
|
|
1049
1351
|
const logs = {
|
|
1050
1352
|
...logsEnabled === void 0 ? {} : { enabled: logsEnabled },
|
|
1051
1353
|
...logsEndpoint === void 0 ? {} : { endpoint: logsEndpoint },
|
|
@@ -1092,16 +1394,23 @@ var parseEnvironmentConfig = (env) => {
|
|
|
1092
1394
|
export {
|
|
1093
1395
|
CONFIG_SOURCE_PRECEDENCE,
|
|
1094
1396
|
DEFAULT_CONFIG,
|
|
1397
|
+
DEFAULT_DESTINATION_NAME,
|
|
1095
1398
|
DEFAULT_DETECTION_POLICY,
|
|
1096
1399
|
DEFAULT_DIAGNOSTICS_POLICY,
|
|
1097
1400
|
DEFAULT_EXPORTER_POLICY,
|
|
1098
1401
|
DEFAULT_LOGS_POLICY,
|
|
1402
|
+
DEFAULT_SPOOL_POLICY,
|
|
1403
|
+
DESTINATION_NAME_PATTERN,
|
|
1099
1404
|
EMPTY_RESOURCE_ATTRIBUTES,
|
|
1100
1405
|
ENVIRONMENT_VARIABLES,
|
|
1406
|
+
HEADER_ENV_REFERENCE_PREFIX,
|
|
1407
|
+
MAX_DESTINATION_HEADERS,
|
|
1408
|
+
MAX_EXPORT_DESTINATIONS,
|
|
1101
1409
|
MAX_OTLP_HEADERS,
|
|
1102
1410
|
MAX_RESOURCE_ATTRIBUTES,
|
|
1103
1411
|
MAX_RESOURCE_ATTRIBUTE_KEY_LENGTH,
|
|
1104
1412
|
MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH,
|
|
1413
|
+
OTLP_ENDPOINT_VARIABLES,
|
|
1105
1414
|
OTLP_HEADER_VARIABLES,
|
|
1106
1415
|
RESERVED_RESOURCE_ATTRIBUTE_KEYS,
|
|
1107
1416
|
RESOURCE_ATTRIBUTE_KEY_PATTERN,
|
|
@@ -1109,26 +1418,38 @@ export {
|
|
|
1109
1418
|
checkResourceAttributeKey,
|
|
1110
1419
|
configSourceSchema,
|
|
1111
1420
|
contentModeSchema,
|
|
1421
|
+
describeExportDestinations,
|
|
1112
1422
|
describeOtlpHeaderNames,
|
|
1113
1423
|
describeResolvedConfig,
|
|
1114
1424
|
describeResourceAttributeNames,
|
|
1115
1425
|
detectionPolicySchema,
|
|
1116
1426
|
diagnosticsPolicySchema,
|
|
1427
|
+
effectiveSpoolPolicy,
|
|
1428
|
+
endpointOrigin,
|
|
1429
|
+
exportDestinationSchema,
|
|
1430
|
+
exportDestinationsSchema,
|
|
1431
|
+
exportSignalSchema,
|
|
1117
1432
|
exporterPolicySchema,
|
|
1433
|
+
hasConfiguredDestinations,
|
|
1118
1434
|
isReservedResourceAttributeKey,
|
|
1119
1435
|
isSecretResourceAttributeKey,
|
|
1120
1436
|
logsPolicySchema,
|
|
1121
1437
|
mergeOtlpHeaders,
|
|
1122
1438
|
otelHookConfigPatchSchema,
|
|
1123
1439
|
otelHookConfigSchema,
|
|
1440
|
+
otlpSignalEndpointFromBase,
|
|
1124
1441
|
parseEnvironmentConfig,
|
|
1442
|
+
parseHeaderValueReference,
|
|
1125
1443
|
parseOtlpHeadersValue,
|
|
1126
1444
|
parseResourceAttributesValue,
|
|
1127
1445
|
resolveConfig,
|
|
1446
|
+
resolveDestinationHeaders,
|
|
1447
|
+
resolveExportDestinations,
|
|
1128
1448
|
resolveOtlpHeaders,
|
|
1129
1449
|
resourceAttributeValueSchema,
|
|
1130
1450
|
resourceAttributesSchema,
|
|
1131
1451
|
sanitizeResourceAttributes,
|
|
1452
|
+
spoolPolicySchema,
|
|
1132
1453
|
unionOtlpHeaderNames
|
|
1133
1454
|
};
|
|
1134
1455
|
//# sourceMappingURL=config.js.map
|