@osfactory/otel-hook 0.13.1 → 0.14.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 +94 -3
- package/dist/{adapter-DyCb7y1N.d.ts → adapter-D5R8lhfl.d.ts} +1 -1
- package/dist/cli.js +1240 -200
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +32 -4
- package/dist/config.js +200 -14
- package/dist/config.js.map +1 -1
- package/dist/{destinations-DvqsPulb.d.ts → destinations-2KrcRslo.d.ts} +92 -2
- package/dist/{export-destinations-DUeQKr_C.d.ts → export-destinations-DvoH4QOe.d.ts} +135 -11
- package/dist/{hook-D5imE0Qc.d.ts → hook-DVK8Don-.d.ts} +4 -4
- package/dist/index.d.ts +11 -11
- package/dist/index.js +1262 -228
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +3 -3
- package/dist/install.js +1 -0
- package/dist/install.js.map +1 -1
- package/dist/integration.d.ts +16 -9
- package/dist/integration.js +1298 -205
- package/dist/integration.js.map +1 -1
- package/dist/lifecycle.js +1 -1
- package/dist/lifecycle.js.map +1 -1
- package/dist/{payload-CdDKeRpH.d.ts → payload-D4r71EL-.d.ts} +18 -2
- package/dist/privacy.d.ts +2 -2
- package/dist/privacy.js +42 -1
- package/dist/privacy.js.map +1 -1
- package/dist/providers.d.ts +94 -9
- package/dist/providers.js +300 -2
- package/dist/providers.js.map +1 -1
- package/dist/{registry-BKQhhIO3.d.ts → registry-DOJh9mzB.d.ts} +2 -2
- package/dist/runtime.d.ts +5 -5
- package/dist/runtime.js +151 -5
- package/dist/runtime.js.map +1 -1
- package/dist/{schema-SpFM6YQY.d.ts → schema-oRsbo7WO.d.ts} +77 -3
- package/dist/{service-CbI9CObT.d.ts → service-DySC7KQM.d.ts} +6 -1
- package/dist/telemetry.d.ts +5 -4
- package/dist/telemetry.js +1076 -476
- package/dist/telemetry.js.map +1 -1
- package/dist/testing.d.ts +5 -5
- package/dist/testing.js +178 -21
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
export { D as DEFAULT_CONFIG, a as DEFAULT_DETECTION_POLICY, b as DEFAULT_DIAGNOSTICS_POLICY, c as
|
|
2
|
+
import { k as OtelHookConfigPatch, O as OtelHookConfig } from './schema-oRsbo7WO.js';
|
|
3
|
+
export { D as DEFAULT_CONFIG, a as DEFAULT_DETECTION_POLICY, b as DEFAULT_DIAGNOSTICS_POLICY, c as DEFAULT_ENDPOINT_DOWN_MILLIS, d as DEFAULT_EXPORTER_POLICY, e as DEFAULT_EXPORT_BUDGET_MILLIS, f as DEFAULT_LOGS_POLICY, g as DEFAULT_METRICS_POLICY, h as DEFAULT_PROVIDERS_POLICY, i as DetectionPolicy, j as DiagnosticsPolicy, E as ExporterPolicy, L as LogsPolicy, M as MetricsPolicy, P as ProvidersPolicy, S as SessionContextPolicy, l as detectionPolicySchema, m as diagnosticsPolicySchema, n as effectiveExportTimeoutMillis, o as effectiveMetricsPolicy, p as exporterPolicySchema, q as logsPolicySchema, r as metricsPolicySchema, s as otelHookConfigPatchSchema, t as otelHookConfigSchema, u as providersPolicySchema, v as readsClaudeTranscriptUsage, w as readsCodexRolloutUsage, x as sessionContextDir, y as sessionContextPolicySchema } from './schema-oRsbo7WO.js';
|
|
4
4
|
import { OtelHookErrorInfo } from './errors.js';
|
|
5
5
|
import { b as Attributes } from './primitives-CJ8-rn-f.js';
|
|
6
|
-
export { D as DEFAULT_DESTINATION_NAME, a as DEFAULT_DESTINATION_SIGNALS, b as DEFAULT_SPOOL_POLICY, c as DESTINATION_NAME_PATTERN, d as DestinationDescription, E as ExportDestination,
|
|
6
|
+
export { A as ALL_REPOSITORIES, D as DEFAULT_DESTINATION_NAME, a as DEFAULT_DESTINATION_SIGNALS, b as DEFAULT_SPOOL_POLICY, c as DESTINATION_NAME_PATTERN, d as DestinationDescription, e as DestinationScope, f as DestinationScopeConfig, g as DestinationScopeDescription, E as ExportDestination, h as ExportDestinationConfig, i as ExportSignal, H as HEADER_ENV_REFERENCE_PREFIX, j as HeaderValueReference, M as MAX_DESTINATION_HEADERS, k as MAX_DESTINATION_SCOPES, l as MAX_EXPORT_DESTINATIONS, m as MAX_SCOPE_REPOSITORIES, R as ResolvedDestinationHeaders, S as SignalFlags, n as SpoolPolicy, o as describeExportDestinations, p as destinationScopeSchema, q as effectiveSpoolPolicy, r as endpointOrigin, s as exportDestinationSchema, t as exportDestinationsSchema, u as exportSignalSchema, v as hasConfiguredDestinations, w as matchDestinationScope, x as parseHeaderValueReference, y as resolveDestinationHeaders, z as resolveDestinationScopes, B as resolveExportDestinations, C as spoolPolicySchema } from './destinations-2KrcRslo.js';
|
|
7
7
|
export { g as contentModeSchema } from './policy-CimmCfRp.js';
|
|
8
8
|
import './taxonomy-DwhTtuWd.js';
|
|
9
9
|
import './content-M9xIKG7h.js';
|
|
@@ -246,6 +246,8 @@ declare const ENVIRONMENT_VARIABLES: Readonly<{
|
|
|
246
246
|
logLevel: "OTEL_HOOK_LOG_LEVEL";
|
|
247
247
|
/** `providers.claudeCode.readTranscriptUsage`; see `providersPolicySchema`. */
|
|
248
248
|
claudeTranscriptUsage: "OTEL_HOOK_CLAUDE_TRANSCRIPT_USAGE";
|
|
249
|
+
/** `providers.codex.readRolloutUsage`; see `providersPolicySchema`. */
|
|
250
|
+
codexRolloutUsage: "OTEL_HOOK_CODEX_ROLLOUT_USAGE";
|
|
249
251
|
}>;
|
|
250
252
|
/**
|
|
251
253
|
* Read configuration from an environment record.
|
|
@@ -371,4 +373,30 @@ type OtlpSignal = "traces" | "logs" | "metrics";
|
|
|
371
373
|
*/
|
|
372
374
|
declare const otlpSignalEndpointFromBase: (base: string, signal: OtlpSignal) => string;
|
|
373
375
|
|
|
374
|
-
|
|
376
|
+
/**
|
|
377
|
+
* Repository keys: how a destination scope names a repository, and how a record's
|
|
378
|
+
* `vcs.repository.url.full` is compared against it.
|
|
379
|
+
*
|
|
380
|
+
* A key is the repository URL's host and path, lowercased, without scheme,
|
|
381
|
+
* credentials, port, trailing slash, or `.git` suffix — `github.com/acme/widget`.
|
|
382
|
+
* The same remote spelled as HTTPS, `git@host:path` or `ssh://` gives the same
|
|
383
|
+
* key, so a scope written from `git remote get-url origin` matches a record
|
|
384
|
+
* stamped with the browse URL and the other way around.
|
|
385
|
+
*
|
|
386
|
+
* Pure: no I/O, never throws.
|
|
387
|
+
*/
|
|
388
|
+
/** OpenTelemetry VCS attribute a record's repository is read from. */
|
|
389
|
+
declare const ATTR_VCS_REPOSITORY_URL_FULL = "vcs.repository.url.full";
|
|
390
|
+
/** Longest repository reference accepted, in a scope or on a record. */
|
|
391
|
+
declare const MAX_REPOSITORY_REFERENCE_LENGTH = 2048;
|
|
392
|
+
/**
|
|
393
|
+
* The key of a repository URL or remote, or `undefined` when it does not name
|
|
394
|
+
* one (empty, unparsable, no path, or a local path).
|
|
395
|
+
*
|
|
396
|
+
* Accepted: `https://host/path(.git)`, `http://…`, `ssh://user@host[:port]/path`,
|
|
397
|
+
* `git://…`, `user@host:path` (scp-like), and an already-normalized
|
|
398
|
+
* `host/path`. Credentials and ports never reach the key.
|
|
399
|
+
*/
|
|
400
|
+
declare const normalizeRepositoryKey: (reference: string) => string | undefined;
|
|
401
|
+
|
|
402
|
+
export { ATTR_VCS_REPOSITORY_URL_FULL, CONFIG_SOURCE_PRECEDENCE, type ConfigLayer, type ConfigProvenance, type ConfigResolution, type ConfigSource, EMPTY_RESOURCE_ATTRIBUTES, ENVIRONMENT_VARIABLES, type EnvironmentConfigResult, type EnvironmentRecord, MAX_OTLP_HEADERS, MAX_REPOSITORY_REFERENCE_LENGTH, MAX_RESOURCE_ATTRIBUTES, MAX_RESOURCE_ATTRIBUTE_KEY_LENGTH, MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH, OTLP_ENDPOINT_VARIABLES, OTLP_HEADER_VARIABLES, OtelHookConfig, OtelHookConfigPatch, type OtlpSignal, type ParsedOtlpHeaders, type ParsedResourceAttributes, RESERVED_RESOURCE_ATTRIBUTE_KEYS, RESOURCE_ATTRIBUTE_KEY_PATTERN, RESOURCE_ATTRIBUTE_KEY_REJECTION_DETAIL, type ResolvedOtlpHeaders, type ResourceAttributeKeyRejection, type ResourceAttributeValue, type ResourceAttributes, checkResourceAttributeKey, configSourceSchema, describeOtlpHeaderNames, describeResolvedConfig, describeResourceAttributeNames, isReservedResourceAttributeKey, isSecretResourceAttributeKey, mergeOtlpHeaders, normalizeRepositoryKey, otlpSignalEndpointFromBase, parseEnvironmentConfig, parseOtlpHeadersValue, parseResourceAttributesValue, resolveConfig, resolveOtlpHeaders, resourceAttributeValueSchema, resourceAttributesSchema, sanitizeResourceAttributes, unionOtlpHeaderNames };
|
package/dist/config.js
CHANGED
|
@@ -413,6 +413,60 @@ var unionOtlpHeaderNames = (...lists) => {
|
|
|
413
413
|
};
|
|
414
414
|
var describeOtlpHeaderNames = (...sources) => unionOtlpHeaderNames(...sources.map((source) => Object.keys(source)));
|
|
415
415
|
|
|
416
|
+
// src/config/repository-key.ts
|
|
417
|
+
var ATTR_VCS_REPOSITORY_URL_FULL = "vcs.repository.url.full";
|
|
418
|
+
var MAX_REPOSITORY_REFERENCE_LENGTH = 2048;
|
|
419
|
+
var SCHEME_PATTERN = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
420
|
+
var SCP_LIKE_PATTERN = /^(?:[^@/\s]+@)?([^:/\s]+):(?!\/\/)(.+)$/;
|
|
421
|
+
var trimTrailingSlashes = (value) => {
|
|
422
|
+
let end = value.length;
|
|
423
|
+
while (end > 0 && value.charCodeAt(end - 1) === 47) end -= 1;
|
|
424
|
+
return value.slice(0, end);
|
|
425
|
+
};
|
|
426
|
+
var keyOf = (host, pathname) => {
|
|
427
|
+
const withoutSlashes = trimTrailingSlashes(pathname);
|
|
428
|
+
const cleanedPath = trimTrailingSlashes(
|
|
429
|
+
withoutSlashes.toLowerCase().endsWith(".git") ? withoutSlashes.slice(0, -4) : withoutSlashes
|
|
430
|
+
);
|
|
431
|
+
if (host.length === 0 || cleanedPath.length === 0 || cleanedPath === "/") {
|
|
432
|
+
return void 0;
|
|
433
|
+
}
|
|
434
|
+
const withSlash = cleanedPath.startsWith("/") ? cleanedPath : `/${cleanedPath}`;
|
|
435
|
+
return `${host}${withSlash}`.toLowerCase();
|
|
436
|
+
};
|
|
437
|
+
var normalizeRepositoryKey = (reference) => {
|
|
438
|
+
const trimmed = reference.trim();
|
|
439
|
+
if (trimmed.length === 0 || trimmed.length > MAX_REPOSITORY_REFERENCE_LENGTH) {
|
|
440
|
+
return void 0;
|
|
441
|
+
}
|
|
442
|
+
if (SCHEME_PATTERN.test(trimmed)) {
|
|
443
|
+
let url;
|
|
444
|
+
try {
|
|
445
|
+
url = new URL(trimmed);
|
|
446
|
+
} catch {
|
|
447
|
+
return void 0;
|
|
448
|
+
}
|
|
449
|
+
if (url.protocol === "file:") {
|
|
450
|
+
return void 0;
|
|
451
|
+
}
|
|
452
|
+
return keyOf(url.hostname, url.pathname);
|
|
453
|
+
}
|
|
454
|
+
if (trimmed.startsWith("/") || trimmed.startsWith(".") || trimmed.includes("\\")) {
|
|
455
|
+
return void 0;
|
|
456
|
+
}
|
|
457
|
+
const scp = SCP_LIKE_PATTERN.exec(trimmed);
|
|
458
|
+
if (scp !== null && !trimmed.split(":")[0]?.includes("/")) {
|
|
459
|
+
const [, host, pathPart] = scp;
|
|
460
|
+
return host === void 0 || pathPart === void 0 ? void 0 : keyOf(host, pathPart);
|
|
461
|
+
}
|
|
462
|
+
try {
|
|
463
|
+
const url = new URL(`https://${trimmed}`);
|
|
464
|
+
return keyOf(url.hostname, url.pathname);
|
|
465
|
+
} catch {
|
|
466
|
+
return void 0;
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
|
|
416
470
|
// src/config/destinations.ts
|
|
417
471
|
var DEFAULT_DESTINATION_NAME = "default";
|
|
418
472
|
var DESTINATION_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]{0,62}$/;
|
|
@@ -431,6 +485,30 @@ var headerValueSchema = z4.string().min(1).max(MAX_HEADER_VALUE_LENGTH).refine(
|
|
|
431
485
|
"an env: header reference must name an environment variable, e.g. env:COLLECTOR_TOKEN"
|
|
432
486
|
);
|
|
433
487
|
var endpointSchema = z4.string().url().max(2048);
|
|
488
|
+
var MAX_DESTINATION_SCOPES = 64;
|
|
489
|
+
var MAX_SCOPE_REPOSITORIES = 256;
|
|
490
|
+
var ALL_REPOSITORIES = "*";
|
|
491
|
+
var repositoryReferenceSchema = z4.string().min(1).max(MAX_REPOSITORY_REFERENCE_LENGTH).refine(
|
|
492
|
+
(value) => normalizeRepositoryKey(value) !== void 0,
|
|
493
|
+
"not a repository URL: use https://host/owner/repo, git@host:owner/repo.git, or host/owner/repo"
|
|
494
|
+
);
|
|
495
|
+
var destinationScopeSchema = z4.strictObject({
|
|
496
|
+
/**
|
|
497
|
+
* Repository URLs (any spelling of the remote; compared by host and path,
|
|
498
|
+
* case-insensitively, without `.git`), or `"*"` for every record that names
|
|
499
|
+
* a repository. A record that names none never matches a scope.
|
|
500
|
+
*/
|
|
501
|
+
repositories: z4.union([
|
|
502
|
+
z4.literal(ALL_REPOSITORIES),
|
|
503
|
+
z4.array(repositoryReferenceSchema).min(1).max(MAX_SCOPE_REPOSITORIES).readonly()
|
|
504
|
+
]),
|
|
505
|
+
/** Signals sent for these repositories. Default: every signal the destination takes. */
|
|
506
|
+
signals: z4.array(exportSignalSchema).min(1).max(3).readonly().optional(),
|
|
507
|
+
/** Content disclosure for these repositories, never above `privacy.contentMode`. Default: unchanged. */
|
|
508
|
+
contentMode: contentModeSchema.optional(),
|
|
509
|
+
/** False leaves `session.id` off metric data points for these repositories. Default true. */
|
|
510
|
+
includeSessionId: z4.boolean().optional()
|
|
511
|
+
});
|
|
434
512
|
var exportDestinationSchema = z4.strictObject({
|
|
435
513
|
/** Unique, lowercase, filesystem-safe. `default` is reserved for the single-endpoint settings. */
|
|
436
514
|
name: z4.string().regex(DESTINATION_NAME_PATTERN, "destination names are lowercase letters, digits, _ and -"),
|
|
@@ -464,7 +542,15 @@ var exportDestinationSchema = z4.strictObject({
|
|
|
464
542
|
* opt-in for content-bearing records leaving the host. `metrics` is never on by
|
|
465
543
|
* default: a destination receives hook-derived metrics only when it lists them.
|
|
466
544
|
*/
|
|
467
|
-
signals: z4.array(exportSignalSchema).min(1).max(3).readonly().optional()
|
|
545
|
+
signals: z4.array(exportSignalSchema).min(1).max(3).readonly().optional(),
|
|
546
|
+
/**
|
|
547
|
+
* Per-repository filter. Absent: every record goes to this destination, as
|
|
548
|
+
* before scopes existed. Present: a record goes only when its repository
|
|
549
|
+
* (`vcs.repository.url.full`) matches a scope — the first matching scope
|
|
550
|
+
* decides its signals, content mode, and session id — and a record that
|
|
551
|
+
* names no repository is not sent here at all.
|
|
552
|
+
*/
|
|
553
|
+
scopes: z4.array(destinationScopeSchema).min(1).max(MAX_DESTINATION_SCOPES).readonly().optional()
|
|
468
554
|
}).refine(
|
|
469
555
|
(destination) => destination.endpoint !== void 0 || destination.tracesEndpoint !== void 0 || destination.logsEndpoint !== void 0 || destination.metricsEndpoint !== void 0,
|
|
470
556
|
"a destination needs an endpoint, or a tracesEndpoint / logsEndpoint / metricsEndpoint"
|
|
@@ -508,6 +594,32 @@ var effectiveSpoolPolicy = (exporter) => ({
|
|
|
508
594
|
maxAgeMillis: exporter.spool?.maxAgeMillis ?? DEFAULT_SPOOL_POLICY.maxAgeMillis,
|
|
509
595
|
maxBatches: exporter.spool?.maxBatches ?? DEFAULT_SPOOL_POLICY.maxBatches
|
|
510
596
|
});
|
|
597
|
+
var resolveDestinationScopes = (scopes, destinationSignals) => scopes.map((scope) => {
|
|
598
|
+
const listed = scope.signals ?? exportSignalSchema.options;
|
|
599
|
+
return {
|
|
600
|
+
repositories: scope.repositories === ALL_REPOSITORIES ? ALL_REPOSITORIES : new Set(
|
|
601
|
+
scope.repositories.flatMap((reference) => {
|
|
602
|
+
const key = normalizeRepositoryKey(reference);
|
|
603
|
+
return key === void 0 ? [] : [key];
|
|
604
|
+
})
|
|
605
|
+
),
|
|
606
|
+
signals: {
|
|
607
|
+
traces: destinationSignals.traces && listed.includes("traces"),
|
|
608
|
+
logs: destinationSignals.logs && listed.includes("logs"),
|
|
609
|
+
metrics: destinationSignals.metrics && listed.includes("metrics")
|
|
610
|
+
},
|
|
611
|
+
...scope.contentMode === void 0 ? {} : { contentMode: scope.contentMode },
|
|
612
|
+
includeSessionId: scope.includeSessionId ?? true
|
|
613
|
+
};
|
|
614
|
+
});
|
|
615
|
+
var matchDestinationScope = (scopes, repositoryKey) => {
|
|
616
|
+
if (repositoryKey === void 0) {
|
|
617
|
+
return void 0;
|
|
618
|
+
}
|
|
619
|
+
return scopes.find(
|
|
620
|
+
(scope) => scope.repositories === ALL_REPOSITORIES || scope.repositories.has(repositoryKey)
|
|
621
|
+
);
|
|
622
|
+
};
|
|
511
623
|
var legacyDestination = (exporter) => ({
|
|
512
624
|
name: DEFAULT_DESTINATION_NAME,
|
|
513
625
|
source: "exporter",
|
|
@@ -532,6 +644,11 @@ var resolveExportDestinations = (exporter) => {
|
|
|
532
644
|
continue;
|
|
533
645
|
}
|
|
534
646
|
const signals = destination.signals ?? DEFAULT_DESTINATION_SIGNALS;
|
|
647
|
+
const flags = {
|
|
648
|
+
traces: signals.includes("traces"),
|
|
649
|
+
logs: exporter.logs.enabled && signals.includes("logs"),
|
|
650
|
+
metrics: signals.includes("metrics")
|
|
651
|
+
};
|
|
535
652
|
resolved.push({
|
|
536
653
|
name: destination.name,
|
|
537
654
|
source: "destinations",
|
|
@@ -540,12 +657,9 @@ var resolveExportDestinations = (exporter) => {
|
|
|
540
657
|
...destination.tracesEndpoint === void 0 ? {} : { tracesEndpoint: destination.tracesEndpoint },
|
|
541
658
|
...destination.logsEndpoint === void 0 ? {} : { logsEndpoint: destination.logsEndpoint },
|
|
542
659
|
...destination.metricsEndpoint === void 0 ? {} : { metricsEndpoint: destination.metricsEndpoint },
|
|
543
|
-
signals:
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
metrics: signals.includes("metrics")
|
|
547
|
-
},
|
|
548
|
-
headers: { ...destination.headers ?? {} }
|
|
660
|
+
signals: flags,
|
|
661
|
+
headers: { ...destination.headers ?? {} },
|
|
662
|
+
...destination.scopes === void 0 ? {} : { scopes: resolveDestinationScopes(destination.scopes, flags) }
|
|
549
663
|
});
|
|
550
664
|
}
|
|
551
665
|
return resolved;
|
|
@@ -569,6 +683,12 @@ var resolveDestinationHeaders = (headers, environment) => {
|
|
|
569
683
|
}
|
|
570
684
|
return { values, missingVariables: [...new Set(missing)].sort() };
|
|
571
685
|
};
|
|
686
|
+
var describeScope = (scope) => ({
|
|
687
|
+
repositories: scope.repositories === ALL_REPOSITORIES ? ALL_REPOSITORIES : [...scope.repositories].sort(),
|
|
688
|
+
signals: exportSignalSchema.options.filter((signal) => scope.signals[signal]),
|
|
689
|
+
...scope.contentMode === void 0 ? {} : { contentMode: scope.contentMode },
|
|
690
|
+
includeSessionId: scope.includeSessionId
|
|
691
|
+
});
|
|
572
692
|
var endpointOrigin = (endpoint) => {
|
|
573
693
|
if (endpoint === void 0) {
|
|
574
694
|
return void 0;
|
|
@@ -598,7 +718,8 @@ var describeExportDestinations = (exporter) => {
|
|
|
598
718
|
...logsOrigin === void 0 || !destination.signals.logs ? {} : { logsEndpointOrigin: logsOrigin },
|
|
599
719
|
...metricsOrigin === void 0 || !destination.signals.metrics ? {} : { metricsEndpointOrigin: metricsOrigin },
|
|
600
720
|
headerNames: destination.source === "exporter" ? [...exporter.headerNames].sort() : Object.keys(destination.headers).sort(),
|
|
601
|
-
headerVariables: [...new Set(variables)].sort()
|
|
721
|
+
headerVariables: [...new Set(variables)].sort(),
|
|
722
|
+
...destination.scopes === void 0 ? {} : { scopes: destination.scopes.map(describeScope) }
|
|
602
723
|
};
|
|
603
724
|
};
|
|
604
725
|
const enabled = resolveExportDestinations(exporter).map(
|
|
@@ -612,7 +733,14 @@ var describeExportDestinations = (exporter) => {
|
|
|
612
733
|
protocol: destination.protocol ?? exporter.protocol,
|
|
613
734
|
...destination.endpoint === void 0 ? {} : { endpoint: destination.endpoint },
|
|
614
735
|
signals: { traces: false, logs: false, metrics: false },
|
|
615
|
-
headers: { ...destination.headers ?? {} }
|
|
736
|
+
headers: { ...destination.headers ?? {} },
|
|
737
|
+
...destination.scopes === void 0 ? {} : {
|
|
738
|
+
scopes: resolveDestinationScopes(destination.scopes, {
|
|
739
|
+
traces: true,
|
|
740
|
+
logs: true,
|
|
741
|
+
metrics: true
|
|
742
|
+
})
|
|
743
|
+
}
|
|
616
744
|
},
|
|
617
745
|
false
|
|
618
746
|
)
|
|
@@ -701,8 +829,26 @@ var exporterPolicySchema = z5.strictObject({
|
|
|
701
829
|
* Per-destination retry spool bounds, each optional and merged per leaf; any
|
|
702
830
|
* bound left unset takes its value from `DEFAULT_SPOOL_POLICY`.
|
|
703
831
|
*/
|
|
704
|
-
spool: spoolPolicySchema.partial().optional()
|
|
832
|
+
spool: spoolPolicySchema.partial().optional(),
|
|
833
|
+
/**
|
|
834
|
+
* The most time one hook invocation spends trying to reach one endpoint, in
|
|
835
|
+
* milliseconds: caps `timeoutMillis` for every OTLP request (connection setup
|
|
836
|
+
* included) and the exporter's own retries inside it. A batch that does not
|
|
837
|
+
* get through in time is spooled. Default {@link DEFAULT_EXPORT_BUDGET_MILLIS}:
|
|
838
|
+
* the host agent waits for its hooks, so a down collector must not stall it.
|
|
839
|
+
*/
|
|
840
|
+
exportBudgetMillis: z5.number().int().min(50).max(6e5).optional(),
|
|
841
|
+
/**
|
|
842
|
+
* After an endpoint was unreachable (refused, timed out, or answered a
|
|
843
|
+
* retryable status), every hook spools for it without trying for this long,
|
|
844
|
+
* in milliseconds; then one hook probes it again. 0 disables the window.
|
|
845
|
+
* Default {@link DEFAULT_ENDPOINT_DOWN_MILLIS}.
|
|
846
|
+
*/
|
|
847
|
+
endpointDownMillis: z5.number().int().min(0).max(36e5).optional()
|
|
705
848
|
});
|
|
849
|
+
var DEFAULT_EXPORT_BUDGET_MILLIS = 1500;
|
|
850
|
+
var DEFAULT_ENDPOINT_DOWN_MILLIS = 3e4;
|
|
851
|
+
var effectiveExportTimeoutMillis = (exporter) => Math.min(exporter.timeoutMillis, exporter.exportBudgetMillis ?? DEFAULT_EXPORT_BUDGET_MILLIS);
|
|
706
852
|
var detectionPolicySchema = z5.strictObject({
|
|
707
853
|
/** Detections below this confidence resolve to the unknown provider. */
|
|
708
854
|
minimumConfidence: detectionConfidenceSchema,
|
|
@@ -719,6 +865,9 @@ var diagnosticsPolicySchema = z5.strictObject({
|
|
|
719
865
|
var providersPolicySchema = z5.strictObject({
|
|
720
866
|
claudeCode: z5.strictObject({
|
|
721
867
|
readTranscriptUsage: z5.boolean()
|
|
868
|
+
}).optional(),
|
|
869
|
+
codex: z5.strictObject({
|
|
870
|
+
readRolloutUsage: z5.boolean()
|
|
722
871
|
}).optional()
|
|
723
872
|
});
|
|
724
873
|
var sessionContextPolicySchema = z5.strictObject({
|
|
@@ -748,7 +897,8 @@ var otelHookConfigPatchSchema = z5.strictObject({
|
|
|
748
897
|
detection: detectionPolicySchema.partial().optional(),
|
|
749
898
|
diagnostics: diagnosticsPolicySchema.partial().optional(),
|
|
750
899
|
providers: z5.strictObject({
|
|
751
|
-
claudeCode: z5.strictObject({ readTranscriptUsage: z5.boolean() }).partial().optional()
|
|
900
|
+
claudeCode: z5.strictObject({ readTranscriptUsage: z5.boolean() }).partial().optional(),
|
|
901
|
+
codex: z5.strictObject({ readRolloutUsage: z5.boolean() }).partial().optional()
|
|
752
902
|
}).partial().optional(),
|
|
753
903
|
sessionContext: sessionContextPolicySchema.partial().optional()
|
|
754
904
|
});
|
|
@@ -775,7 +925,8 @@ var DEFAULT_DIAGNOSTICS_POLICY = Object.freeze({
|
|
|
775
925
|
emitErrorEvents: true
|
|
776
926
|
});
|
|
777
927
|
var DEFAULT_PROVIDERS_POLICY = Object.freeze({
|
|
778
|
-
claudeCode: Object.freeze({ readTranscriptUsage: false })
|
|
928
|
+
claudeCode: Object.freeze({ readTranscriptUsage: false }),
|
|
929
|
+
codex: Object.freeze({ readRolloutUsage: false })
|
|
779
930
|
});
|
|
780
931
|
var DEFAULT_CONFIG = Object.freeze({
|
|
781
932
|
exporter: DEFAULT_EXPORTER_POLICY,
|
|
@@ -785,6 +936,7 @@ var DEFAULT_CONFIG = Object.freeze({
|
|
|
785
936
|
providers: DEFAULT_PROVIDERS_POLICY
|
|
786
937
|
});
|
|
787
938
|
var readsClaudeTranscriptUsage = (config) => config.providers?.claudeCode?.readTranscriptUsage === true;
|
|
939
|
+
var readsCodexRolloutUsage = (config) => config.providers?.codex?.readRolloutUsage === true;
|
|
788
940
|
var sessionContextDir = (config) => config.sessionContext?.dir;
|
|
789
941
|
var effectiveMetricsPolicy = (exporter) => ({
|
|
790
942
|
...DEFAULT_METRICS_POLICY,
|
|
@@ -1122,6 +1274,18 @@ var resolveConfig = (layers = []) => {
|
|
|
1122
1274
|
);
|
|
1123
1275
|
}
|
|
1124
1276
|
}
|
|
1277
|
+
const rank = { omit: 0, mask: 1, redact: 2, raw: 3 };
|
|
1278
|
+
const effectiveMode = parsed.data.privacy.contentMode === "raw" && !parsed.data.privacy.allowRawContent ? "omit" : parsed.data.privacy.contentMode;
|
|
1279
|
+
const widening = enabled.filter(
|
|
1280
|
+
(destination) => (destination.scopes ?? []).some(
|
|
1281
|
+
(scope) => scope.contentMode !== void 0 && rank[scope.contentMode] > rank[effectiveMode]
|
|
1282
|
+
)
|
|
1283
|
+
).map((destination) => destination.name);
|
|
1284
|
+
if (widening.length > 0) {
|
|
1285
|
+
notes.push(
|
|
1286
|
+
`destination(s) ${widening.join(", ")} have a scope contentMode above privacy.contentMode=${effectiveMode}; a scope can only lower disclosure, so ${effectiveMode} applies`
|
|
1287
|
+
);
|
|
1288
|
+
}
|
|
1125
1289
|
}
|
|
1126
1290
|
if (!withDestinations && parsed.data.exporter.logs.enabled && parsed.data.exporter.logs.endpoint === void 0 && parsed.data.exporter.endpoint === void 0) {
|
|
1127
1291
|
notes.push(
|
|
@@ -1169,6 +1333,9 @@ var describeDestinationAttributes = (config) => {
|
|
|
1169
1333
|
}
|
|
1170
1334
|
attributes[`${prefix}.header_names`] = [...destination.headerNames];
|
|
1171
1335
|
attributes[`${prefix}.header_variables`] = [...destination.headerVariables];
|
|
1336
|
+
if (destination.scopes !== void 0) {
|
|
1337
|
+
attributes[`${prefix}.scope_count`] = destination.scopes.length;
|
|
1338
|
+
}
|
|
1172
1339
|
}
|
|
1173
1340
|
return attributes;
|
|
1174
1341
|
};
|
|
@@ -1295,7 +1462,9 @@ var ENVIRONMENT_VARIABLES = Object.freeze({
|
|
|
1295
1462
|
minimumConfidence: "OTEL_HOOK_MIN_DETECTION_CONFIDENCE",
|
|
1296
1463
|
logLevel: "OTEL_HOOK_LOG_LEVEL",
|
|
1297
1464
|
/** `providers.claudeCode.readTranscriptUsage`; see `providersPolicySchema`. */
|
|
1298
|
-
claudeTranscriptUsage: "OTEL_HOOK_CLAUDE_TRANSCRIPT_USAGE"
|
|
1465
|
+
claudeTranscriptUsage: "OTEL_HOOK_CLAUDE_TRANSCRIPT_USAGE",
|
|
1466
|
+
/** `providers.codex.readRolloutUsage`; see `providersPolicySchema`. */
|
|
1467
|
+
codexRolloutUsage: "OTEL_HOOK_CODEX_ROLLOUT_USAGE"
|
|
1299
1468
|
});
|
|
1300
1469
|
var BOOLEAN_TRUE = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
|
|
1301
1470
|
var BOOLEAN_FALSE = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
|
|
@@ -1490,7 +1659,11 @@ var parseEnvironmentConfig = (env) => {
|
|
|
1490
1659
|
const detection = confidenceParsed?.success === true ? { minimumConfidence: confidenceParsed.data } : {};
|
|
1491
1660
|
const diagnostics = logLevel === void 0 ? {} : { logLevel };
|
|
1492
1661
|
const claudeTranscriptUsage = readBoolean(ENVIRONMENT_VARIABLES.claudeTranscriptUsage);
|
|
1493
|
-
const
|
|
1662
|
+
const codexRolloutUsage = readBoolean(ENVIRONMENT_VARIABLES.codexRolloutUsage);
|
|
1663
|
+
const providers = {
|
|
1664
|
+
...claudeTranscriptUsage === void 0 ? {} : { claudeCode: { readTranscriptUsage: claudeTranscriptUsage } },
|
|
1665
|
+
...codexRolloutUsage === void 0 ? {} : { codex: { readRolloutUsage: codexRolloutUsage } }
|
|
1666
|
+
};
|
|
1494
1667
|
const patch = {
|
|
1495
1668
|
...Object.keys(exporter).length === 0 ? {} : { exporter },
|
|
1496
1669
|
...Object.keys(privacy).length === 0 ? {} : { privacy },
|
|
@@ -1501,13 +1674,17 @@ var parseEnvironmentConfig = (env) => {
|
|
|
1501
1674
|
return { patch, warnings };
|
|
1502
1675
|
};
|
|
1503
1676
|
export {
|
|
1677
|
+
ALL_REPOSITORIES,
|
|
1678
|
+
ATTR_VCS_REPOSITORY_URL_FULL,
|
|
1504
1679
|
CONFIG_SOURCE_PRECEDENCE,
|
|
1505
1680
|
DEFAULT_CONFIG,
|
|
1506
1681
|
DEFAULT_DESTINATION_NAME,
|
|
1507
1682
|
DEFAULT_DESTINATION_SIGNALS,
|
|
1508
1683
|
DEFAULT_DETECTION_POLICY,
|
|
1509
1684
|
DEFAULT_DIAGNOSTICS_POLICY,
|
|
1685
|
+
DEFAULT_ENDPOINT_DOWN_MILLIS,
|
|
1510
1686
|
DEFAULT_EXPORTER_POLICY,
|
|
1687
|
+
DEFAULT_EXPORT_BUDGET_MILLIS,
|
|
1511
1688
|
DEFAULT_LOGS_POLICY,
|
|
1512
1689
|
DEFAULT_METRICS_POLICY,
|
|
1513
1690
|
DEFAULT_PROVIDERS_POLICY,
|
|
@@ -1517,11 +1694,14 @@ export {
|
|
|
1517
1694
|
ENVIRONMENT_VARIABLES,
|
|
1518
1695
|
HEADER_ENV_REFERENCE_PREFIX,
|
|
1519
1696
|
MAX_DESTINATION_HEADERS,
|
|
1697
|
+
MAX_DESTINATION_SCOPES,
|
|
1520
1698
|
MAX_EXPORT_DESTINATIONS,
|
|
1521
1699
|
MAX_OTLP_HEADERS,
|
|
1700
|
+
MAX_REPOSITORY_REFERENCE_LENGTH,
|
|
1522
1701
|
MAX_RESOURCE_ATTRIBUTES,
|
|
1523
1702
|
MAX_RESOURCE_ATTRIBUTE_KEY_LENGTH,
|
|
1524
1703
|
MAX_RESOURCE_ATTRIBUTE_VALUE_LENGTH,
|
|
1704
|
+
MAX_SCOPE_REPOSITORIES,
|
|
1525
1705
|
OTLP_ENDPOINT_VARIABLES,
|
|
1526
1706
|
OTLP_HEADER_VARIABLES,
|
|
1527
1707
|
RESERVED_RESOURCE_ATTRIBUTE_KEYS,
|
|
@@ -1534,8 +1714,10 @@ export {
|
|
|
1534
1714
|
describeOtlpHeaderNames,
|
|
1535
1715
|
describeResolvedConfig,
|
|
1536
1716
|
describeResourceAttributeNames,
|
|
1717
|
+
destinationScopeSchema,
|
|
1537
1718
|
detectionPolicySchema,
|
|
1538
1719
|
diagnosticsPolicySchema,
|
|
1720
|
+
effectiveExportTimeoutMillis,
|
|
1539
1721
|
effectiveMetricsPolicy,
|
|
1540
1722
|
effectiveSpoolPolicy,
|
|
1541
1723
|
endpointOrigin,
|
|
@@ -1547,8 +1729,10 @@ export {
|
|
|
1547
1729
|
isReservedResourceAttributeKey,
|
|
1548
1730
|
isSecretResourceAttributeKey,
|
|
1549
1731
|
logsPolicySchema,
|
|
1732
|
+
matchDestinationScope,
|
|
1550
1733
|
mergeOtlpHeaders,
|
|
1551
1734
|
metricsPolicySchema,
|
|
1735
|
+
normalizeRepositoryKey,
|
|
1552
1736
|
otelHookConfigPatchSchema,
|
|
1553
1737
|
otelHookConfigSchema,
|
|
1554
1738
|
otlpSignalEndpointFromBase,
|
|
@@ -1558,8 +1742,10 @@ export {
|
|
|
1558
1742
|
parseResourceAttributesValue,
|
|
1559
1743
|
providersPolicySchema,
|
|
1560
1744
|
readsClaudeTranscriptUsage,
|
|
1745
|
+
readsCodexRolloutUsage,
|
|
1561
1746
|
resolveConfig,
|
|
1562
1747
|
resolveDestinationHeaders,
|
|
1748
|
+
resolveDestinationScopes,
|
|
1563
1749
|
resolveExportDestinations,
|
|
1564
1750
|
resolveOtlpHeaders,
|
|
1565
1751
|
resourceAttributeValueSchema,
|