@osfactory/otel-hook 0.10.0 → 0.12.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 +108 -4
- package/dist/{adapter-B9RwW6TO.d.ts → adapter-DQiPu8xF.d.ts} +2 -2
- package/dist/cli.js +1495 -135
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +11 -4
- package/dist/config.js +116 -21
- package/dist/config.js.map +1 -1
- package/dist/{destinations-DWOkVxV1.d.ts → destinations-DvqsPulb.d.ts} +12 -2
- package/dist/diagnostics.d.ts +1 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/{events-CSD_YiJ2.d.ts → events-fcomX6d5.d.ts} +22 -0
- package/dist/{export-destinations-lORbe25J.d.ts → export-destinations-CI7z4n3i.d.ts} +136 -6
- package/dist/{filesystem-store-DX3dGIgu.d.ts → filesystem-store-CmnUlj1O.d.ts} +1 -1
- package/dist/{hook-BAxXoKsp.d.ts → hook-vM_cgqS2.d.ts} +11 -5
- package/dist/index.d.ts +16 -16
- package/dist/index.js +1496 -183
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +4 -4
- package/dist/install.js +9 -1
- package/dist/install.js.map +1 -1
- package/dist/integration.d.ts +36 -12
- package/dist/integration.js +1464 -231
- package/dist/integration.js.map +1 -1
- package/dist/lifecycle.d.ts +55 -4
- package/dist/lifecycle.js +279 -5
- package/dist/lifecycle.js.map +1 -1
- package/dist/{memory-aJilVG4R.d.ts → memory-DdU1U91y.d.ts} +2 -2
- package/dist/{semconv-Dw7gcQcg.d.ts → metric-model-C9lLqqpI.d.ts} +157 -2
- package/dist/model.d.ts +1 -1
- package/dist/model.js +9 -1
- package/dist/model.js.map +1 -1
- package/dist/{payload-D7gc0-WQ.d.ts → payload-BT19hiVZ.d.ts} +1 -1
- package/dist/{ports-plO5MKrY.d.ts → ports-C3k_5eOQ.d.ts} +57 -2
- package/dist/providers.d.ts +10 -10
- package/dist/providers.js +10 -1
- package/dist/providers.js.map +1 -1
- package/dist/{registry-C7XO4DzD.d.ts → registry-gyJqaWmp.d.ts} +2 -2
- package/dist/runtime.d.ts +97 -9
- package/dist/runtime.js +312 -33
- package/dist/runtime.js.map +1 -1
- package/dist/{schema-CHb3GU1r.d.ts → schema-SpFM6YQY.d.ts} +87 -1
- package/dist/state.d.ts +4 -4
- package/dist/state.js +32 -1
- package/dist/state.js.map +1 -1
- package/dist/telemetry.d.ts +6 -6
- package/dist/telemetry.js +929 -31
- package/dist/telemetry.js.map +1 -1
- package/dist/testing.d.ts +11 -9
- package/dist/testing.js +164 -33
- package/dist/testing.js.map +1 -1
- package/package.json +3 -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 DEFAULT_EXPORTER_POLICY, d as DEFAULT_LOGS_POLICY, e as
|
|
2
|
+
import { i as OtelHookConfigPatch, O as OtelHookConfig } from './schema-SpFM6YQY.js';
|
|
3
|
+
export { D as DEFAULT_CONFIG, a as DEFAULT_DETECTION_POLICY, b as DEFAULT_DIAGNOSTICS_POLICY, c as DEFAULT_EXPORTER_POLICY, d as DEFAULT_LOGS_POLICY, e as DEFAULT_METRICS_POLICY, f as DEFAULT_PROVIDERS_POLICY, g as DetectionPolicy, h as DiagnosticsPolicy, E as ExporterPolicy, L as LogsPolicy, M as MetricsPolicy, P as ProvidersPolicy, S as SessionContextPolicy, j as detectionPolicySchema, k as diagnosticsPolicySchema, l as effectiveMetricsPolicy, m as exporterPolicySchema, n as logsPolicySchema, o as metricsPolicySchema, p as otelHookConfigPatchSchema, q as otelHookConfigSchema, r as providersPolicySchema, s as readsClaudeTranscriptUsage, t as sessionContextDir, u as sessionContextPolicySchema } from './schema-SpFM6YQY.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
|
|
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, e as ExportDestinationConfig, f as ExportSignal, H as HEADER_ENV_REFERENCE_PREFIX, g as HeaderValueReference, M as MAX_DESTINATION_HEADERS, h as MAX_EXPORT_DESTINATIONS, R as ResolvedDestinationHeaders, S as SpoolPolicy, i as describeExportDestinations, j as effectiveSpoolPolicy, k as endpointOrigin, l as exportDestinationSchema, m as exportDestinationsSchema, n as exportSignalSchema, o as hasConfiguredDestinations, p as parseHeaderValueReference, r as resolveDestinationHeaders, q as resolveExportDestinations, s as spoolPolicySchema } from './destinations-DvqsPulb.js';
|
|
7
7
|
export { g as contentModeSchema } from './policy-CimmCfRp.js';
|
|
8
8
|
import './taxonomy-DwhTtuWd.js';
|
|
9
9
|
import './content-M9xIKG7h.js';
|
|
@@ -224,6 +224,12 @@ declare const ENVIRONMENT_VARIABLES: Readonly<{
|
|
|
224
224
|
/** Standard per-signal endpoint; the weaker source of the two. */
|
|
225
225
|
otlpLogsEndpoint: "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT";
|
|
226
226
|
logsIncludeContent: "OTEL_HOOK_LOGS_INCLUDE_CONTENT";
|
|
227
|
+
metricsEnabled: "OTEL_HOOK_METRICS_ENABLED";
|
|
228
|
+
metricsEndpoint: "OTEL_HOOK_METRICS_ENDPOINT";
|
|
229
|
+
/** Standard per-signal endpoint; the weaker source of the two. */
|
|
230
|
+
otlpMetricsEndpoint: "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT";
|
|
231
|
+
/** Standard: `cumulative`, `delta`, or `lowmemory` (read as `delta` here). */
|
|
232
|
+
otlpMetricsTemporality: "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE";
|
|
227
233
|
serviceName: "OTEL_HOOK_SERVICE_NAME";
|
|
228
234
|
otlpServiceName: "OTEL_SERVICE_NAME";
|
|
229
235
|
serviceNamespace: "OTEL_HOOK_SERVICE_NAMESPACE";
|
|
@@ -351,8 +357,9 @@ declare const OTLP_ENDPOINT_VARIABLES: Readonly<{
|
|
|
351
357
|
generic: "OTEL_EXPORTER_OTLP_ENDPOINT";
|
|
352
358
|
traces: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT";
|
|
353
359
|
logs: "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT";
|
|
360
|
+
metrics: "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT";
|
|
354
361
|
}>;
|
|
355
|
-
type OtlpSignal = "traces" | "logs";
|
|
362
|
+
type OtlpSignal = "traces" | "logs" | "metrics";
|
|
356
363
|
/**
|
|
357
364
|
* The URL a signal posts to, given an `OTEL_EXPORTER_OTLP_ENDPOINT` base.
|
|
358
365
|
*
|
package/dist/config.js
CHANGED
|
@@ -284,6 +284,7 @@ var sanitizeResourceAttributes = (attributes) => {
|
|
|
284
284
|
var describeResourceAttributeNames = (attributes) => Object.keys(attributes).sort();
|
|
285
285
|
|
|
286
286
|
// src/config/schema.ts
|
|
287
|
+
import { isAbsolute } from "path";
|
|
287
288
|
import { z as z5 } from "zod";
|
|
288
289
|
|
|
289
290
|
// src/config/destinations.ts
|
|
@@ -421,7 +422,7 @@ var HEADER_ENV_REFERENCE_PREFIX = "env:";
|
|
|
421
422
|
var HEADER_NAME_PATTERN2 = /^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/;
|
|
422
423
|
var ENV_VARIABLE_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
423
424
|
var MAX_HEADER_VALUE_LENGTH = 8192;
|
|
424
|
-
var exportSignalSchema = z4.enum(["traces", "logs"]);
|
|
425
|
+
var exportSignalSchema = z4.enum(["traces", "logs", "metrics"]);
|
|
425
426
|
var headerValueSchema = z4.string().min(1).max(MAX_HEADER_VALUE_LENGTH).refine(
|
|
426
427
|
(value) => !isUnsafeHeaderValue(value),
|
|
427
428
|
"header values may not contain line breaks, control characters, or characters beyond Latin-1"
|
|
@@ -444,6 +445,8 @@ var exportDestinationSchema = z4.strictObject({
|
|
|
444
445
|
tracesEndpoint: endpointSchema.optional(),
|
|
445
446
|
/** Per-signal override of the derived logs URL. */
|
|
446
447
|
logsEndpoint: endpointSchema.optional(),
|
|
448
|
+
/** Per-signal override of the derived metrics URL (`/v1/traces` becomes `/v1/metrics`). */
|
|
449
|
+
metricsEndpoint: endpointSchema.optional(),
|
|
447
450
|
/** Defaults to `exporter.protocol`. */
|
|
448
451
|
protocol: z4.enum(["http/protobuf", "http/json", "none"]).optional(),
|
|
449
452
|
/**
|
|
@@ -456,15 +459,17 @@ var exportDestinationSchema = z4.strictObject({
|
|
|
456
459
|
`at most ${String(MAX_DESTINATION_HEADERS)} headers per destination`
|
|
457
460
|
).optional(),
|
|
458
461
|
/**
|
|
459
|
-
* Which signals this destination receives. Default:
|
|
460
|
-
* still governed by `exporter.logs.enabled`, which stays the one
|
|
461
|
-
*
|
|
462
|
+
* Which signals this destination receives. Default: traces and logs. The logs
|
|
463
|
+
* signal is still governed by `exporter.logs.enabled`, which stays the one
|
|
464
|
+
* opt-in for content-bearing records leaving the host. `metrics` is never on by
|
|
465
|
+
* default: a destination receives hook-derived metrics only when it lists them.
|
|
462
466
|
*/
|
|
463
|
-
signals: z4.array(exportSignalSchema).min(1).max(
|
|
467
|
+
signals: z4.array(exportSignalSchema).min(1).max(3).readonly().optional()
|
|
464
468
|
}).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"
|
|
469
|
+
(destination) => destination.endpoint !== void 0 || destination.tracesEndpoint !== void 0 || destination.logsEndpoint !== void 0 || destination.metricsEndpoint !== void 0,
|
|
470
|
+
"a destination needs an endpoint, or a tracesEndpoint / logsEndpoint / metricsEndpoint"
|
|
467
471
|
);
|
|
472
|
+
var DEFAULT_DESTINATION_SIGNALS = Object.freeze(["traces", "logs"]);
|
|
468
473
|
var exportDestinationsSchema = z4.array(exportDestinationSchema).max(MAX_EXPORT_DESTINATIONS).readonly().superRefine((destinations, context) => {
|
|
469
474
|
const seen = /* @__PURE__ */ new Set();
|
|
470
475
|
destinations.forEach((destination, index) => {
|
|
@@ -509,7 +514,8 @@ var legacyDestination = (exporter) => ({
|
|
|
509
514
|
protocol: exporter.protocol,
|
|
510
515
|
...exporter.endpoint === void 0 ? {} : { endpoint: exporter.endpoint },
|
|
511
516
|
...exporter.logs.endpoint === void 0 ? {} : { logsEndpoint: exporter.logs.endpoint },
|
|
512
|
-
|
|
517
|
+
...exporter.metrics?.endpoint === void 0 ? {} : { metricsEndpoint: exporter.metrics.endpoint },
|
|
518
|
+
signals: { traces: true, logs: exporter.logs.enabled, metrics: exporter.metrics?.enabled === true },
|
|
513
519
|
headers: {}
|
|
514
520
|
});
|
|
515
521
|
var hasConfiguredDestinations = (exporter) => exporter.destinations !== void 0 && exporter.destinations.length > 0;
|
|
@@ -518,14 +524,14 @@ var resolveExportDestinations = (exporter) => {
|
|
|
518
524
|
return [legacyDestination(exporter)];
|
|
519
525
|
}
|
|
520
526
|
const resolved = [];
|
|
521
|
-
if (exporter.endpoint !== void 0 || exporter.logs.endpoint !== void 0) {
|
|
527
|
+
if (exporter.endpoint !== void 0 || exporter.logs.endpoint !== void 0 || exporter.metrics?.endpoint !== void 0) {
|
|
522
528
|
resolved.push(legacyDestination(exporter));
|
|
523
529
|
}
|
|
524
530
|
for (const destination of exporter.destinations ?? []) {
|
|
525
531
|
if (destination.enabled === false) {
|
|
526
532
|
continue;
|
|
527
533
|
}
|
|
528
|
-
const signals = destination.signals ??
|
|
534
|
+
const signals = destination.signals ?? DEFAULT_DESTINATION_SIGNALS;
|
|
529
535
|
resolved.push({
|
|
530
536
|
name: destination.name,
|
|
531
537
|
source: "destinations",
|
|
@@ -533,9 +539,11 @@ var resolveExportDestinations = (exporter) => {
|
|
|
533
539
|
...destination.endpoint === void 0 ? {} : { endpoint: destination.endpoint },
|
|
534
540
|
...destination.tracesEndpoint === void 0 ? {} : { tracesEndpoint: destination.tracesEndpoint },
|
|
535
541
|
...destination.logsEndpoint === void 0 ? {} : { logsEndpoint: destination.logsEndpoint },
|
|
542
|
+
...destination.metricsEndpoint === void 0 ? {} : { metricsEndpoint: destination.metricsEndpoint },
|
|
536
543
|
signals: {
|
|
537
544
|
traces: signals.includes("traces"),
|
|
538
|
-
logs: exporter.logs.enabled && signals.includes("logs")
|
|
545
|
+
logs: exporter.logs.enabled && signals.includes("logs"),
|
|
546
|
+
metrics: signals.includes("metrics")
|
|
539
547
|
},
|
|
540
548
|
headers: { ...destination.headers ?? {} }
|
|
541
549
|
});
|
|
@@ -577,6 +585,9 @@ var describeExportDestinations = (exporter) => {
|
|
|
577
585
|
const logsOrigin = endpointOrigin(
|
|
578
586
|
destination.logsEndpoint ?? destination.endpoint ?? destination.tracesEndpoint
|
|
579
587
|
);
|
|
588
|
+
const metricsOrigin = endpointOrigin(
|
|
589
|
+
destination.metricsEndpoint ?? destination.endpoint ?? destination.tracesEndpoint
|
|
590
|
+
);
|
|
580
591
|
const variables = Object.values(destination.headers).map(parseHeaderValueReference).flatMap((reference) => reference.kind === "env" ? [reference.variable] : []);
|
|
581
592
|
return {
|
|
582
593
|
name: destination.name,
|
|
@@ -585,6 +596,7 @@ var describeExportDestinations = (exporter) => {
|
|
|
585
596
|
signals: exportSignalSchema.options.filter((signal) => destination.signals[signal]),
|
|
586
597
|
...tracesOrigin === void 0 || !destination.signals.traces ? {} : { tracesEndpointOrigin: tracesOrigin },
|
|
587
598
|
...logsOrigin === void 0 || !destination.signals.logs ? {} : { logsEndpointOrigin: logsOrigin },
|
|
599
|
+
...metricsOrigin === void 0 || !destination.signals.metrics ? {} : { metricsEndpointOrigin: metricsOrigin },
|
|
588
600
|
headerNames: destination.source === "exporter" ? [...exporter.headerNames].sort() : Object.keys(destination.headers).sort(),
|
|
589
601
|
headerVariables: [...new Set(variables)].sort()
|
|
590
602
|
};
|
|
@@ -599,7 +611,7 @@ var describeExportDestinations = (exporter) => {
|
|
|
599
611
|
source: "destinations",
|
|
600
612
|
protocol: destination.protocol ?? exporter.protocol,
|
|
601
613
|
...destination.endpoint === void 0 ? {} : { endpoint: destination.endpoint },
|
|
602
|
-
signals: { traces: false, logs: false },
|
|
614
|
+
signals: { traces: false, logs: false, metrics: false },
|
|
603
615
|
headers: { ...destination.headers ?? {} }
|
|
604
616
|
},
|
|
605
617
|
false
|
|
@@ -626,6 +638,18 @@ var DEFAULT_LOGS_POLICY = Object.freeze({
|
|
|
626
638
|
includeContent: false,
|
|
627
639
|
maxBatchSize: 128
|
|
628
640
|
});
|
|
641
|
+
var metricsPolicySchema = z5.strictObject({
|
|
642
|
+
enabled: z5.boolean(),
|
|
643
|
+
/** Full URL. Absent, derived from `endpoint` (`/v1/traces` becomes `/v1/metrics`). */
|
|
644
|
+
endpoint: z5.string().url().max(2048).optional(),
|
|
645
|
+
temporality: z5.enum(["cumulative", "delta"]),
|
|
646
|
+
includeSessionId: z5.boolean()
|
|
647
|
+
});
|
|
648
|
+
var DEFAULT_METRICS_POLICY = Object.freeze({
|
|
649
|
+
enabled: false,
|
|
650
|
+
temporality: "cumulative",
|
|
651
|
+
includeSessionId: true
|
|
652
|
+
});
|
|
629
653
|
var exporterPolicySchema = z5.strictObject({
|
|
630
654
|
enabled: z5.boolean(),
|
|
631
655
|
protocol: z5.enum(["http/protobuf", "http/json", "none"]),
|
|
@@ -656,6 +680,11 @@ var exporterPolicySchema = z5.strictObject({
|
|
|
656
680
|
* a second top-level section would invite two of each to drift apart.
|
|
657
681
|
*/
|
|
658
682
|
logs: logsPolicySchema,
|
|
683
|
+
/**
|
|
684
|
+
* Hook-derived metrics. Optional so an `ExporterPolicy` built by hand before
|
|
685
|
+
* metrics existed stays valid; absent reads as {@link DEFAULT_METRICS_POLICY}.
|
|
686
|
+
*/
|
|
687
|
+
metrics: metricsPolicySchema.optional(),
|
|
659
688
|
/**
|
|
660
689
|
* Additional OTLP destinations, each sent every batch in parallel.
|
|
661
690
|
*
|
|
@@ -692,20 +721,27 @@ var providersPolicySchema = z5.strictObject({
|
|
|
692
721
|
readTranscriptUsage: z5.boolean()
|
|
693
722
|
}).optional()
|
|
694
723
|
});
|
|
724
|
+
var sessionContextPolicySchema = z5.strictObject({
|
|
725
|
+
/** Absolute path of the context directory. */
|
|
726
|
+
dir: z5.string().min(1).max(4096).refine((value) => isAbsolute(value), { message: "must be an absolute path" })
|
|
727
|
+
});
|
|
695
728
|
var otelHookConfigSchema = z5.strictObject({
|
|
696
729
|
exporter: exporterPolicySchema,
|
|
697
730
|
privacy: privacyPolicySchema,
|
|
698
731
|
detection: detectionPolicySchema,
|
|
699
732
|
diagnostics: diagnosticsPolicySchema,
|
|
700
733
|
/** Optional so a hand-built configuration from before it existed stays valid. */
|
|
701
|
-
providers: providersPolicySchema.optional()
|
|
734
|
+
providers: providersPolicySchema.optional(),
|
|
735
|
+
/** Optional: absent means no session context is read. */
|
|
736
|
+
sessionContext: sessionContextPolicySchema.optional()
|
|
702
737
|
});
|
|
703
738
|
var otelHookConfigPatchSchema = z5.strictObject({
|
|
704
739
|
// `logs` is unwrapped and re-partialled for the same reason `privacy.limits` is:
|
|
705
740
|
// merging happens per leaf, so a layer must be able to set `logs.enabled` alone
|
|
706
741
|
// without also restating the endpoint and the batch size.
|
|
707
|
-
exporter: exporterPolicySchema.omit({ logs: true, spool: true }).partial().extend({
|
|
742
|
+
exporter: exporterPolicySchema.omit({ logs: true, metrics: true, spool: true }).partial().extend({
|
|
708
743
|
logs: logsPolicySchema.partial().optional(),
|
|
744
|
+
metrics: metricsPolicySchema.partial().optional(),
|
|
709
745
|
spool: spoolPolicySchema.partial().optional()
|
|
710
746
|
}).optional(),
|
|
711
747
|
privacy: privacyPolicySchema.omit({ limits: true }).partial().extend({ limits: privacyPolicySchema.shape.limits.partial().optional() }).optional(),
|
|
@@ -713,7 +749,8 @@ var otelHookConfigPatchSchema = z5.strictObject({
|
|
|
713
749
|
diagnostics: diagnosticsPolicySchema.partial().optional(),
|
|
714
750
|
providers: z5.strictObject({
|
|
715
751
|
claudeCode: z5.strictObject({ readTranscriptUsage: z5.boolean() }).partial().optional()
|
|
716
|
-
}).partial().optional()
|
|
752
|
+
}).partial().optional(),
|
|
753
|
+
sessionContext: sessionContextPolicySchema.partial().optional()
|
|
717
754
|
});
|
|
718
755
|
var DEFAULT_EXPORTER_POLICY = Object.freeze({
|
|
719
756
|
enabled: true,
|
|
@@ -725,7 +762,8 @@ var DEFAULT_EXPORTER_POLICY = Object.freeze({
|
|
|
725
762
|
maxRetryAttempts: 2,
|
|
726
763
|
serviceName: "coding-agent",
|
|
727
764
|
resourceAttributes: EMPTY_RESOURCE_ATTRIBUTES,
|
|
728
|
-
logs: DEFAULT_LOGS_POLICY
|
|
765
|
+
logs: DEFAULT_LOGS_POLICY,
|
|
766
|
+
metrics: DEFAULT_METRICS_POLICY
|
|
729
767
|
});
|
|
730
768
|
var DEFAULT_DETECTION_POLICY = Object.freeze({
|
|
731
769
|
minimumConfidence: "strong",
|
|
@@ -747,6 +785,11 @@ var DEFAULT_CONFIG = Object.freeze({
|
|
|
747
785
|
providers: DEFAULT_PROVIDERS_POLICY
|
|
748
786
|
});
|
|
749
787
|
var readsClaudeTranscriptUsage = (config) => config.providers?.claudeCode?.readTranscriptUsage === true;
|
|
788
|
+
var sessionContextDir = (config) => config.sessionContext?.dir;
|
|
789
|
+
var effectiveMetricsPolicy = (exporter) => ({
|
|
790
|
+
...DEFAULT_METRICS_POLICY,
|
|
791
|
+
...exporter.metrics ?? {}
|
|
792
|
+
});
|
|
750
793
|
|
|
751
794
|
// src/config/resolve.ts
|
|
752
795
|
import { z as z8 } from "zod";
|
|
@@ -1085,6 +1128,11 @@ var resolveConfig = (layers = []) => {
|
|
|
1085
1128
|
"exporter.logs.enabled is true but neither a logs endpoint nor a trace endpoint to derive one from is configured"
|
|
1086
1129
|
);
|
|
1087
1130
|
}
|
|
1131
|
+
if (!withDestinations && parsed.data.exporter.metrics?.enabled === true && parsed.data.exporter.metrics.endpoint === void 0 && parsed.data.exporter.endpoint === void 0) {
|
|
1132
|
+
notes.push(
|
|
1133
|
+
"exporter.metrics.enabled is true but neither a metrics endpoint nor a trace endpoint to derive one from is configured"
|
|
1134
|
+
);
|
|
1135
|
+
}
|
|
1088
1136
|
if (parsed.data.exporter.logs.includeContent && parsed.data.privacy.contentMode === "omit") {
|
|
1089
1137
|
notes.push(
|
|
1090
1138
|
"exporter.logs.includeContent is true but privacy.contentMode is omit, so no content is disclosed to describe"
|
|
@@ -1116,6 +1164,9 @@ var describeDestinationAttributes = (config) => {
|
|
|
1116
1164
|
if (destination.logsEndpointOrigin !== void 0) {
|
|
1117
1165
|
attributes[`${prefix}.logs_endpoint_origin`] = destination.logsEndpointOrigin;
|
|
1118
1166
|
}
|
|
1167
|
+
if (destination.metricsEndpointOrigin !== void 0) {
|
|
1168
|
+
attributes[`${prefix}.metrics_endpoint_origin`] = destination.metricsEndpointOrigin;
|
|
1169
|
+
}
|
|
1119
1170
|
attributes[`${prefix}.header_names`] = [...destination.headerNames];
|
|
1120
1171
|
attributes[`${prefix}.header_variables`] = [...destination.headerVariables];
|
|
1121
1172
|
}
|
|
@@ -1134,6 +1185,8 @@ var describeResolvedConfig = (config) => {
|
|
|
1134
1185
|
};
|
|
1135
1186
|
const endpointOrigin2 = originOf(config.exporter.endpoint);
|
|
1136
1187
|
const logsEndpointOrigin = originOf(config.exporter.logs.endpoint);
|
|
1188
|
+
const metrics = effectiveMetricsPolicy(config.exporter);
|
|
1189
|
+
const metricsEndpointOrigin = originOf(metrics.endpoint);
|
|
1137
1190
|
return {
|
|
1138
1191
|
"exporter.enabled": config.exporter.enabled,
|
|
1139
1192
|
"exporter.protocol": config.exporter.protocol,
|
|
@@ -1142,6 +1195,10 @@ var describeResolvedConfig = (config) => {
|
|
|
1142
1195
|
"exporter.logs_include_content": config.exporter.logs.includeContent,
|
|
1143
1196
|
"exporter.logs_max_batch_size": config.exporter.logs.maxBatchSize,
|
|
1144
1197
|
...logsEndpointOrigin === void 0 ? {} : { "exporter.logs_endpoint_origin": logsEndpointOrigin },
|
|
1198
|
+
"exporter.metrics_enabled": metrics.enabled,
|
|
1199
|
+
"exporter.metrics_temporality": metrics.temporality,
|
|
1200
|
+
"exporter.metrics_include_session_id": metrics.includeSessionId,
|
|
1201
|
+
...metricsEndpointOrigin === void 0 ? {} : { "exporter.metrics_endpoint_origin": metricsEndpointOrigin },
|
|
1145
1202
|
"exporter.header_names": [...config.exporter.headerNames],
|
|
1146
1203
|
// Names only. A resource attribute *name* is already on the wire in every
|
|
1147
1204
|
// exported resource, so disclosing it here adds nothing; a *value* may hold
|
|
@@ -1163,7 +1220,9 @@ var describeResolvedConfig = (config) => {
|
|
|
1163
1220
|
"detection.minimum_confidence": config.detection.minimumConfidence,
|
|
1164
1221
|
"detection.allow_ambiguous_fallback": config.detection.allowAmbiguousFallback,
|
|
1165
1222
|
"diagnostics.log_level": config.diagnostics.logLevel,
|
|
1166
|
-
"diagnostics.emit_error_events": config.diagnostics.emitErrorEvents
|
|
1223
|
+
"diagnostics.emit_error_events": config.diagnostics.emitErrorEvents,
|
|
1224
|
+
// Whether, never where: the directory is a local path.
|
|
1225
|
+
"session_context.enabled": config.sessionContext?.dir !== void 0
|
|
1167
1226
|
};
|
|
1168
1227
|
};
|
|
1169
1228
|
|
|
@@ -1171,10 +1230,17 @@ var describeResolvedConfig = (config) => {
|
|
|
1171
1230
|
var OTLP_ENDPOINT_VARIABLES = Object.freeze({
|
|
1172
1231
|
generic: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
1173
1232
|
traces: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT",
|
|
1174
|
-
logs: "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT"
|
|
1233
|
+
logs: "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT",
|
|
1234
|
+
metrics: "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT"
|
|
1175
1235
|
});
|
|
1176
1236
|
var OTLP_TRACES_PATH = "/v1/traces";
|
|
1177
1237
|
var OTLP_LOGS_PATH = "/v1/logs";
|
|
1238
|
+
var OTLP_METRICS_PATH = "/v1/metrics";
|
|
1239
|
+
var SIGNAL_PATHS = Object.freeze({
|
|
1240
|
+
traces: OTLP_TRACES_PATH,
|
|
1241
|
+
logs: OTLP_LOGS_PATH,
|
|
1242
|
+
metrics: OTLP_METRICS_PATH
|
|
1243
|
+
});
|
|
1178
1244
|
var withoutTrailingSlashes = (value) => {
|
|
1179
1245
|
let end = value.length;
|
|
1180
1246
|
while (end > 0 && value.charCodeAt(end - 1) === 47) {
|
|
@@ -1185,9 +1251,9 @@ var withoutTrailingSlashes = (value) => {
|
|
|
1185
1251
|
var otlpSignalEndpointFromBase = (base, signal) => {
|
|
1186
1252
|
const trimmed = withoutTrailingSlashes(base);
|
|
1187
1253
|
if (trimmed.endsWith(OTLP_TRACES_PATH)) {
|
|
1188
|
-
return signal === "traces" ? trimmed : `${trimmed.slice(0, trimmed.length - OTLP_TRACES_PATH.length)}${
|
|
1254
|
+
return signal === "traces" ? trimmed : `${trimmed.slice(0, trimmed.length - OTLP_TRACES_PATH.length)}${SIGNAL_PATHS[signal]}`;
|
|
1189
1255
|
}
|
|
1190
|
-
return `${trimmed}${signal
|
|
1256
|
+
return `${trimmed}${SIGNAL_PATHS[signal]}`;
|
|
1191
1257
|
};
|
|
1192
1258
|
|
|
1193
1259
|
// src/config/environment.ts
|
|
@@ -1208,6 +1274,12 @@ var ENVIRONMENT_VARIABLES = Object.freeze({
|
|
|
1208
1274
|
/** Standard per-signal endpoint; the weaker source of the two. */
|
|
1209
1275
|
otlpLogsEndpoint: "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT",
|
|
1210
1276
|
logsIncludeContent: "OTEL_HOOK_LOGS_INCLUDE_CONTENT",
|
|
1277
|
+
metricsEnabled: "OTEL_HOOK_METRICS_ENABLED",
|
|
1278
|
+
metricsEndpoint: "OTEL_HOOK_METRICS_ENDPOINT",
|
|
1279
|
+
/** Standard per-signal endpoint; the weaker source of the two. */
|
|
1280
|
+
otlpMetricsEndpoint: "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT",
|
|
1281
|
+
/** Standard: `cumulative`, `delta`, or `lowmemory` (read as `delta` here). */
|
|
1282
|
+
otlpMetricsTemporality: "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE",
|
|
1211
1283
|
serviceName: "OTEL_HOOK_SERVICE_NAME",
|
|
1212
1284
|
otlpServiceName: "OTEL_SERVICE_NAME",
|
|
1213
1285
|
serviceNamespace: "OTEL_HOOK_SERVICE_NAMESPACE",
|
|
@@ -1370,6 +1442,22 @@ var parseEnvironmentConfig = (env) => {
|
|
|
1370
1442
|
...logsEndpoint === void 0 ? {} : { endpoint: logsEndpoint },
|
|
1371
1443
|
...logsIncludeContent === void 0 ? {} : { includeContent: logsIncludeContent }
|
|
1372
1444
|
};
|
|
1445
|
+
const metricsEnabled = readBoolean(ENVIRONMENT_VARIABLES.metricsEnabled);
|
|
1446
|
+
const metricsEndpoint = readString(ENVIRONMENT_VARIABLES.metricsEndpoint) ?? readString(ENVIRONMENT_VARIABLES.otlpMetricsEndpoint) ?? (hookEndpoint === void 0 && otlpTracesEndpoint !== void 0 && otlpBaseEndpoint !== void 0 ? otlpSignalEndpointFromBase(otlpBaseEndpoint, "metrics") : void 0);
|
|
1447
|
+
const temporalityRaw = readString(ENVIRONMENT_VARIABLES.otlpMetricsTemporality)?.toLowerCase();
|
|
1448
|
+
let metricsTemporality;
|
|
1449
|
+
if (temporalityRaw === "cumulative") {
|
|
1450
|
+
metricsTemporality = "cumulative";
|
|
1451
|
+
} else if (temporalityRaw === "delta" || temporalityRaw === "lowmemory") {
|
|
1452
|
+
metricsTemporality = "delta";
|
|
1453
|
+
} else if (temporalityRaw !== void 0) {
|
|
1454
|
+
warn(ENVIRONMENT_VARIABLES.otlpMetricsTemporality, "expected cumulative, delta, or lowmemory");
|
|
1455
|
+
}
|
|
1456
|
+
const metrics = {
|
|
1457
|
+
...metricsEnabled === void 0 ? {} : { enabled: metricsEnabled },
|
|
1458
|
+
...metricsEndpoint === void 0 ? {} : { endpoint: metricsEndpoint },
|
|
1459
|
+
...metricsTemporality === void 0 ? {} : { temporality: metricsTemporality }
|
|
1460
|
+
};
|
|
1373
1461
|
const otlpHeaders = resolveOtlpHeaders(env);
|
|
1374
1462
|
for (const { variable, detail } of otlpHeaders.warnings) {
|
|
1375
1463
|
warn(variable, detail);
|
|
@@ -1384,7 +1472,8 @@ var parseEnvironmentConfig = (env) => {
|
|
|
1384
1472
|
...serviceName === void 0 ? {} : { serviceName },
|
|
1385
1473
|
...serviceNamespace === void 0 ? {} : { serviceNamespace },
|
|
1386
1474
|
...Object.keys(resourceAttributes).length === 0 ? {} : { resourceAttributes },
|
|
1387
|
-
...Object.keys(logs).length === 0 ? {} : { logs }
|
|
1475
|
+
...Object.keys(logs).length === 0 ? {} : { logs },
|
|
1476
|
+
...Object.keys(metrics).length === 0 ? {} : { metrics }
|
|
1388
1477
|
};
|
|
1389
1478
|
const limits = {
|
|
1390
1479
|
...maxStringLength === void 0 ? {} : { maxStringLength },
|
|
@@ -1415,10 +1504,12 @@ export {
|
|
|
1415
1504
|
CONFIG_SOURCE_PRECEDENCE,
|
|
1416
1505
|
DEFAULT_CONFIG,
|
|
1417
1506
|
DEFAULT_DESTINATION_NAME,
|
|
1507
|
+
DEFAULT_DESTINATION_SIGNALS,
|
|
1418
1508
|
DEFAULT_DETECTION_POLICY,
|
|
1419
1509
|
DEFAULT_DIAGNOSTICS_POLICY,
|
|
1420
1510
|
DEFAULT_EXPORTER_POLICY,
|
|
1421
1511
|
DEFAULT_LOGS_POLICY,
|
|
1512
|
+
DEFAULT_METRICS_POLICY,
|
|
1422
1513
|
DEFAULT_PROVIDERS_POLICY,
|
|
1423
1514
|
DEFAULT_SPOOL_POLICY,
|
|
1424
1515
|
DESTINATION_NAME_PATTERN,
|
|
@@ -1445,6 +1536,7 @@ export {
|
|
|
1445
1536
|
describeResourceAttributeNames,
|
|
1446
1537
|
detectionPolicySchema,
|
|
1447
1538
|
diagnosticsPolicySchema,
|
|
1539
|
+
effectiveMetricsPolicy,
|
|
1448
1540
|
effectiveSpoolPolicy,
|
|
1449
1541
|
endpointOrigin,
|
|
1450
1542
|
exportDestinationSchema,
|
|
@@ -1456,6 +1548,7 @@ export {
|
|
|
1456
1548
|
isSecretResourceAttributeKey,
|
|
1457
1549
|
logsPolicySchema,
|
|
1458
1550
|
mergeOtlpHeaders,
|
|
1551
|
+
metricsPolicySchema,
|
|
1459
1552
|
otelHookConfigPatchSchema,
|
|
1460
1553
|
otelHookConfigSchema,
|
|
1461
1554
|
otlpSignalEndpointFromBase,
|
|
@@ -1472,6 +1565,8 @@ export {
|
|
|
1472
1565
|
resourceAttributeValueSchema,
|
|
1473
1566
|
resourceAttributesSchema,
|
|
1474
1567
|
sanitizeResourceAttributes,
|
|
1568
|
+
sessionContextDir,
|
|
1569
|
+
sessionContextPolicySchema,
|
|
1475
1570
|
spoolPolicySchema,
|
|
1476
1571
|
unionOtlpHeaderNames
|
|
1477
1572
|
};
|