@osfactory/otel-hook 0.10.0 → 0.11.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.
Files changed (43) hide show
  1. package/README.md +82 -3
  2. package/dist/{adapter-B9RwW6TO.d.ts → adapter-DiLknaTF.d.ts} +1 -1
  3. package/dist/cli.js +1131 -77
  4. package/dist/cli.js.map +1 -1
  5. package/dist/config.d.ts +11 -4
  6. package/dist/config.js +100 -18
  7. package/dist/config.js.map +1 -1
  8. package/dist/{destinations-DWOkVxV1.d.ts → destinations-BIl3gGzx.d.ts} +12 -2
  9. package/dist/diagnostics.d.ts +1 -1
  10. package/dist/diagnostics.js.map +1 -1
  11. package/dist/{export-destinations-lORbe25J.d.ts → export-destinations-QWKGGEjk.d.ts} +130 -5
  12. package/dist/{filesystem-store-DX3dGIgu.d.ts → filesystem-store-D3SCNmbX.d.ts} +1 -1
  13. package/dist/{hook-BAxXoKsp.d.ts → hook-BOecWGSz.d.ts} +4 -4
  14. package/dist/index.d.ts +14 -14
  15. package/dist/index.js +1114 -90
  16. package/dist/index.js.map +1 -1
  17. package/dist/install.d.ts +3 -3
  18. package/dist/integration.d.ts +29 -11
  19. package/dist/integration.js +1117 -154
  20. package/dist/integration.js.map +1 -1
  21. package/dist/lifecycle.d.ts +54 -3
  22. package/dist/lifecycle.js +270 -4
  23. package/dist/lifecycle.js.map +1 -1
  24. package/dist/{memory-aJilVG4R.d.ts → memory-Cs51jyRk.d.ts} +1 -1
  25. package/dist/{semconv-Dw7gcQcg.d.ts → metric-model-DDnWxL9d.d.ts} +154 -2
  26. package/dist/{payload-D7gc0-WQ.d.ts → payload-ChtrEX6A.d.ts} +1 -1
  27. package/dist/{ports-plO5MKrY.d.ts → ports-CeqLq31i.d.ts} +24 -0
  28. package/dist/providers.d.ts +8 -8
  29. package/dist/{registry-C7XO4DzD.d.ts → registry-CcJNF3WY.d.ts} +2 -2
  30. package/dist/runtime.d.ts +7 -7
  31. package/dist/runtime.js +55 -9
  32. package/dist/runtime.js.map +1 -1
  33. package/dist/{schema-CHb3GU1r.d.ts → schema-DMnoU1V_.d.ts} +64 -1
  34. package/dist/state.d.ts +3 -3
  35. package/dist/state.js +23 -0
  36. package/dist/state.js.map +1 -1
  37. package/dist/telemetry.d.ts +5 -5
  38. package/dist/telemetry.js +860 -17
  39. package/dist/telemetry.js.map +1 -1
  40. package/dist/testing.d.ts +8 -8
  41. package/dist/testing.js +55 -9
  42. package/dist/testing.js.map +1 -1
  43. package/package.json +3 -1
package/dist/config.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
- import { h as OtelHookConfigPatch, O as OtelHookConfig } from './schema-CHb3GU1r.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_PROVIDERS_POLICY, f as DetectionPolicy, g as DiagnosticsPolicy, E as ExporterPolicy, L as LogsPolicy, P as ProvidersPolicy, i as detectionPolicySchema, j as diagnosticsPolicySchema, k as exporterPolicySchema, l as logsPolicySchema, o as otelHookConfigPatchSchema, m as otelHookConfigSchema, p as providersPolicySchema, r as readsClaudeTranscriptUsage } from './schema-CHb3GU1r.js';
2
+ import { i as OtelHookConfigPatch, O as OtelHookConfig } from './schema-DMnoU1V_.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, 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 } from './schema-DMnoU1V_.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_SPOOL_POLICY, b as DESTINATION_NAME_PATTERN, c as DestinationDescription, E as ExportDestination, d as ExportDestinationConfig, e as ExportSignal, H as HEADER_ENV_REFERENCE_PREFIX, f as HeaderValueReference, M as MAX_DESTINATION_HEADERS, g as MAX_EXPORT_DESTINATIONS, R as ResolvedDestinationHeaders, S as SpoolPolicy, h as describeExportDestinations, i as effectiveSpoolPolicy, j as endpointOrigin, k as exportDestinationSchema, l as exportDestinationsSchema, m as exportSignalSchema, n as hasConfiguredDestinations, p as parseHeaderValueReference, r as resolveDestinationHeaders, o as resolveExportDestinations, s as spoolPolicySchema } from './destinations-DWOkVxV1.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, 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-BIl3gGzx.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
@@ -421,7 +421,7 @@ var HEADER_ENV_REFERENCE_PREFIX = "env:";
421
421
  var HEADER_NAME_PATTERN2 = /^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,128}$/;
422
422
  var ENV_VARIABLE_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
423
423
  var MAX_HEADER_VALUE_LENGTH = 8192;
424
- var exportSignalSchema = z4.enum(["traces", "logs"]);
424
+ var exportSignalSchema = z4.enum(["traces", "logs", "metrics"]);
425
425
  var headerValueSchema = z4.string().min(1).max(MAX_HEADER_VALUE_LENGTH).refine(
426
426
  (value) => !isUnsafeHeaderValue(value),
427
427
  "header values may not contain line breaks, control characters, or characters beyond Latin-1"
@@ -444,6 +444,8 @@ var exportDestinationSchema = z4.strictObject({
444
444
  tracesEndpoint: endpointSchema.optional(),
445
445
  /** Per-signal override of the derived logs URL. */
446
446
  logsEndpoint: endpointSchema.optional(),
447
+ /** Per-signal override of the derived metrics URL (`/v1/traces` becomes `/v1/metrics`). */
448
+ metricsEndpoint: endpointSchema.optional(),
447
449
  /** Defaults to `exporter.protocol`. */
448
450
  protocol: z4.enum(["http/protobuf", "http/json", "none"]).optional(),
449
451
  /**
@@ -456,15 +458,17 @@ var exportDestinationSchema = z4.strictObject({
456
458
  `at most ${String(MAX_DESTINATION_HEADERS)} headers per destination`
457
459
  ).optional(),
458
460
  /**
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.
461
+ * Which signals this destination receives. Default: traces and logs. The logs
462
+ * signal is still governed by `exporter.logs.enabled`, which stays the one
463
+ * opt-in for content-bearing records leaving the host. `metrics` is never on by
464
+ * default: a destination receives hook-derived metrics only when it lists them.
462
465
  */
463
- signals: z4.array(exportSignalSchema).min(1).max(2).readonly().optional()
466
+ signals: z4.array(exportSignalSchema).min(1).max(3).readonly().optional()
464
467
  }).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"
468
+ (destination) => destination.endpoint !== void 0 || destination.tracesEndpoint !== void 0 || destination.logsEndpoint !== void 0 || destination.metricsEndpoint !== void 0,
469
+ "a destination needs an endpoint, or a tracesEndpoint / logsEndpoint / metricsEndpoint"
467
470
  );
471
+ var DEFAULT_DESTINATION_SIGNALS = Object.freeze(["traces", "logs"]);
468
472
  var exportDestinationsSchema = z4.array(exportDestinationSchema).max(MAX_EXPORT_DESTINATIONS).readonly().superRefine((destinations, context) => {
469
473
  const seen = /* @__PURE__ */ new Set();
470
474
  destinations.forEach((destination, index) => {
@@ -509,7 +513,8 @@ var legacyDestination = (exporter) => ({
509
513
  protocol: exporter.protocol,
510
514
  ...exporter.endpoint === void 0 ? {} : { endpoint: exporter.endpoint },
511
515
  ...exporter.logs.endpoint === void 0 ? {} : { logsEndpoint: exporter.logs.endpoint },
512
- signals: { traces: true, logs: exporter.logs.enabled },
516
+ ...exporter.metrics?.endpoint === void 0 ? {} : { metricsEndpoint: exporter.metrics.endpoint },
517
+ signals: { traces: true, logs: exporter.logs.enabled, metrics: exporter.metrics?.enabled === true },
513
518
  headers: {}
514
519
  });
515
520
  var hasConfiguredDestinations = (exporter) => exporter.destinations !== void 0 && exporter.destinations.length > 0;
@@ -518,14 +523,14 @@ var resolveExportDestinations = (exporter) => {
518
523
  return [legacyDestination(exporter)];
519
524
  }
520
525
  const resolved = [];
521
- if (exporter.endpoint !== void 0 || exporter.logs.endpoint !== void 0) {
526
+ if (exporter.endpoint !== void 0 || exporter.logs.endpoint !== void 0 || exporter.metrics?.endpoint !== void 0) {
522
527
  resolved.push(legacyDestination(exporter));
523
528
  }
524
529
  for (const destination of exporter.destinations ?? []) {
525
530
  if (destination.enabled === false) {
526
531
  continue;
527
532
  }
528
- const signals = destination.signals ?? exportSignalSchema.options;
533
+ const signals = destination.signals ?? DEFAULT_DESTINATION_SIGNALS;
529
534
  resolved.push({
530
535
  name: destination.name,
531
536
  source: "destinations",
@@ -533,9 +538,11 @@ var resolveExportDestinations = (exporter) => {
533
538
  ...destination.endpoint === void 0 ? {} : { endpoint: destination.endpoint },
534
539
  ...destination.tracesEndpoint === void 0 ? {} : { tracesEndpoint: destination.tracesEndpoint },
535
540
  ...destination.logsEndpoint === void 0 ? {} : { logsEndpoint: destination.logsEndpoint },
541
+ ...destination.metricsEndpoint === void 0 ? {} : { metricsEndpoint: destination.metricsEndpoint },
536
542
  signals: {
537
543
  traces: signals.includes("traces"),
538
- logs: exporter.logs.enabled && signals.includes("logs")
544
+ logs: exporter.logs.enabled && signals.includes("logs"),
545
+ metrics: signals.includes("metrics")
539
546
  },
540
547
  headers: { ...destination.headers ?? {} }
541
548
  });
@@ -577,6 +584,9 @@ var describeExportDestinations = (exporter) => {
577
584
  const logsOrigin = endpointOrigin(
578
585
  destination.logsEndpoint ?? destination.endpoint ?? destination.tracesEndpoint
579
586
  );
587
+ const metricsOrigin = endpointOrigin(
588
+ destination.metricsEndpoint ?? destination.endpoint ?? destination.tracesEndpoint
589
+ );
580
590
  const variables = Object.values(destination.headers).map(parseHeaderValueReference).flatMap((reference) => reference.kind === "env" ? [reference.variable] : []);
581
591
  return {
582
592
  name: destination.name,
@@ -585,6 +595,7 @@ var describeExportDestinations = (exporter) => {
585
595
  signals: exportSignalSchema.options.filter((signal) => destination.signals[signal]),
586
596
  ...tracesOrigin === void 0 || !destination.signals.traces ? {} : { tracesEndpointOrigin: tracesOrigin },
587
597
  ...logsOrigin === void 0 || !destination.signals.logs ? {} : { logsEndpointOrigin: logsOrigin },
598
+ ...metricsOrigin === void 0 || !destination.signals.metrics ? {} : { metricsEndpointOrigin: metricsOrigin },
588
599
  headerNames: destination.source === "exporter" ? [...exporter.headerNames].sort() : Object.keys(destination.headers).sort(),
589
600
  headerVariables: [...new Set(variables)].sort()
590
601
  };
@@ -599,7 +610,7 @@ var describeExportDestinations = (exporter) => {
599
610
  source: "destinations",
600
611
  protocol: destination.protocol ?? exporter.protocol,
601
612
  ...destination.endpoint === void 0 ? {} : { endpoint: destination.endpoint },
602
- signals: { traces: false, logs: false },
613
+ signals: { traces: false, logs: false, metrics: false },
603
614
  headers: { ...destination.headers ?? {} }
604
615
  },
605
616
  false
@@ -626,6 +637,18 @@ var DEFAULT_LOGS_POLICY = Object.freeze({
626
637
  includeContent: false,
627
638
  maxBatchSize: 128
628
639
  });
640
+ var metricsPolicySchema = z5.strictObject({
641
+ enabled: z5.boolean(),
642
+ /** Full URL. Absent, derived from `endpoint` (`/v1/traces` becomes `/v1/metrics`). */
643
+ endpoint: z5.string().url().max(2048).optional(),
644
+ temporality: z5.enum(["cumulative", "delta"]),
645
+ includeSessionId: z5.boolean()
646
+ });
647
+ var DEFAULT_METRICS_POLICY = Object.freeze({
648
+ enabled: false,
649
+ temporality: "cumulative",
650
+ includeSessionId: true
651
+ });
629
652
  var exporterPolicySchema = z5.strictObject({
630
653
  enabled: z5.boolean(),
631
654
  protocol: z5.enum(["http/protobuf", "http/json", "none"]),
@@ -656,6 +679,11 @@ var exporterPolicySchema = z5.strictObject({
656
679
  * a second top-level section would invite two of each to drift apart.
657
680
  */
658
681
  logs: logsPolicySchema,
682
+ /**
683
+ * Hook-derived metrics. Optional so an `ExporterPolicy` built by hand before
684
+ * metrics existed stays valid; absent reads as {@link DEFAULT_METRICS_POLICY}.
685
+ */
686
+ metrics: metricsPolicySchema.optional(),
659
687
  /**
660
688
  * Additional OTLP destinations, each sent every batch in parallel.
661
689
  *
@@ -704,8 +732,9 @@ var otelHookConfigPatchSchema = z5.strictObject({
704
732
  // `logs` is unwrapped and re-partialled for the same reason `privacy.limits` is:
705
733
  // merging happens per leaf, so a layer must be able to set `logs.enabled` alone
706
734
  // without also restating the endpoint and the batch size.
707
- exporter: exporterPolicySchema.omit({ logs: true, spool: true }).partial().extend({
735
+ exporter: exporterPolicySchema.omit({ logs: true, metrics: true, spool: true }).partial().extend({
708
736
  logs: logsPolicySchema.partial().optional(),
737
+ metrics: metricsPolicySchema.partial().optional(),
709
738
  spool: spoolPolicySchema.partial().optional()
710
739
  }).optional(),
711
740
  privacy: privacyPolicySchema.omit({ limits: true }).partial().extend({ limits: privacyPolicySchema.shape.limits.partial().optional() }).optional(),
@@ -725,7 +754,8 @@ var DEFAULT_EXPORTER_POLICY = Object.freeze({
725
754
  maxRetryAttempts: 2,
726
755
  serviceName: "coding-agent",
727
756
  resourceAttributes: EMPTY_RESOURCE_ATTRIBUTES,
728
- logs: DEFAULT_LOGS_POLICY
757
+ logs: DEFAULT_LOGS_POLICY,
758
+ metrics: DEFAULT_METRICS_POLICY
729
759
  });
730
760
  var DEFAULT_DETECTION_POLICY = Object.freeze({
731
761
  minimumConfidence: "strong",
@@ -747,6 +777,10 @@ var DEFAULT_CONFIG = Object.freeze({
747
777
  providers: DEFAULT_PROVIDERS_POLICY
748
778
  });
749
779
  var readsClaudeTranscriptUsage = (config) => config.providers?.claudeCode?.readTranscriptUsage === true;
780
+ var effectiveMetricsPolicy = (exporter) => ({
781
+ ...DEFAULT_METRICS_POLICY,
782
+ ...exporter.metrics ?? {}
783
+ });
750
784
 
751
785
  // src/config/resolve.ts
752
786
  import { z as z8 } from "zod";
@@ -1085,6 +1119,11 @@ var resolveConfig = (layers = []) => {
1085
1119
  "exporter.logs.enabled is true but neither a logs endpoint nor a trace endpoint to derive one from is configured"
1086
1120
  );
1087
1121
  }
1122
+ if (!withDestinations && parsed.data.exporter.metrics?.enabled === true && parsed.data.exporter.metrics.endpoint === void 0 && parsed.data.exporter.endpoint === void 0) {
1123
+ notes.push(
1124
+ "exporter.metrics.enabled is true but neither a metrics endpoint nor a trace endpoint to derive one from is configured"
1125
+ );
1126
+ }
1088
1127
  if (parsed.data.exporter.logs.includeContent && parsed.data.privacy.contentMode === "omit") {
1089
1128
  notes.push(
1090
1129
  "exporter.logs.includeContent is true but privacy.contentMode is omit, so no content is disclosed to describe"
@@ -1116,6 +1155,9 @@ var describeDestinationAttributes = (config) => {
1116
1155
  if (destination.logsEndpointOrigin !== void 0) {
1117
1156
  attributes[`${prefix}.logs_endpoint_origin`] = destination.logsEndpointOrigin;
1118
1157
  }
1158
+ if (destination.metricsEndpointOrigin !== void 0) {
1159
+ attributes[`${prefix}.metrics_endpoint_origin`] = destination.metricsEndpointOrigin;
1160
+ }
1119
1161
  attributes[`${prefix}.header_names`] = [...destination.headerNames];
1120
1162
  attributes[`${prefix}.header_variables`] = [...destination.headerVariables];
1121
1163
  }
@@ -1134,6 +1176,8 @@ var describeResolvedConfig = (config) => {
1134
1176
  };
1135
1177
  const endpointOrigin2 = originOf(config.exporter.endpoint);
1136
1178
  const logsEndpointOrigin = originOf(config.exporter.logs.endpoint);
1179
+ const metrics = effectiveMetricsPolicy(config.exporter);
1180
+ const metricsEndpointOrigin = originOf(metrics.endpoint);
1137
1181
  return {
1138
1182
  "exporter.enabled": config.exporter.enabled,
1139
1183
  "exporter.protocol": config.exporter.protocol,
@@ -1142,6 +1186,10 @@ var describeResolvedConfig = (config) => {
1142
1186
  "exporter.logs_include_content": config.exporter.logs.includeContent,
1143
1187
  "exporter.logs_max_batch_size": config.exporter.logs.maxBatchSize,
1144
1188
  ...logsEndpointOrigin === void 0 ? {} : { "exporter.logs_endpoint_origin": logsEndpointOrigin },
1189
+ "exporter.metrics_enabled": metrics.enabled,
1190
+ "exporter.metrics_temporality": metrics.temporality,
1191
+ "exporter.metrics_include_session_id": metrics.includeSessionId,
1192
+ ...metricsEndpointOrigin === void 0 ? {} : { "exporter.metrics_endpoint_origin": metricsEndpointOrigin },
1145
1193
  "exporter.header_names": [...config.exporter.headerNames],
1146
1194
  // Names only. A resource attribute *name* is already on the wire in every
1147
1195
  // exported resource, so disclosing it here adds nothing; a *value* may hold
@@ -1171,10 +1219,17 @@ var describeResolvedConfig = (config) => {
1171
1219
  var OTLP_ENDPOINT_VARIABLES = Object.freeze({
1172
1220
  generic: "OTEL_EXPORTER_OTLP_ENDPOINT",
1173
1221
  traces: "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT",
1174
- logs: "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT"
1222
+ logs: "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT",
1223
+ metrics: "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT"
1175
1224
  });
1176
1225
  var OTLP_TRACES_PATH = "/v1/traces";
1177
1226
  var OTLP_LOGS_PATH = "/v1/logs";
1227
+ var OTLP_METRICS_PATH = "/v1/metrics";
1228
+ var SIGNAL_PATHS = Object.freeze({
1229
+ traces: OTLP_TRACES_PATH,
1230
+ logs: OTLP_LOGS_PATH,
1231
+ metrics: OTLP_METRICS_PATH
1232
+ });
1178
1233
  var withoutTrailingSlashes = (value) => {
1179
1234
  let end = value.length;
1180
1235
  while (end > 0 && value.charCodeAt(end - 1) === 47) {
@@ -1185,9 +1240,9 @@ var withoutTrailingSlashes = (value) => {
1185
1240
  var otlpSignalEndpointFromBase = (base, signal) => {
1186
1241
  const trimmed = withoutTrailingSlashes(base);
1187
1242
  if (trimmed.endsWith(OTLP_TRACES_PATH)) {
1188
- return signal === "traces" ? trimmed : `${trimmed.slice(0, trimmed.length - OTLP_TRACES_PATH.length)}${OTLP_LOGS_PATH}`;
1243
+ return signal === "traces" ? trimmed : `${trimmed.slice(0, trimmed.length - OTLP_TRACES_PATH.length)}${SIGNAL_PATHS[signal]}`;
1189
1244
  }
1190
- return `${trimmed}${signal === "traces" ? OTLP_TRACES_PATH : OTLP_LOGS_PATH}`;
1245
+ return `${trimmed}${SIGNAL_PATHS[signal]}`;
1191
1246
  };
1192
1247
 
1193
1248
  // src/config/environment.ts
@@ -1208,6 +1263,12 @@ var ENVIRONMENT_VARIABLES = Object.freeze({
1208
1263
  /** Standard per-signal endpoint; the weaker source of the two. */
1209
1264
  otlpLogsEndpoint: "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT",
1210
1265
  logsIncludeContent: "OTEL_HOOK_LOGS_INCLUDE_CONTENT",
1266
+ metricsEnabled: "OTEL_HOOK_METRICS_ENABLED",
1267
+ metricsEndpoint: "OTEL_HOOK_METRICS_ENDPOINT",
1268
+ /** Standard per-signal endpoint; the weaker source of the two. */
1269
+ otlpMetricsEndpoint: "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT",
1270
+ /** Standard: `cumulative`, `delta`, or `lowmemory` (read as `delta` here). */
1271
+ otlpMetricsTemporality: "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE",
1211
1272
  serviceName: "OTEL_HOOK_SERVICE_NAME",
1212
1273
  otlpServiceName: "OTEL_SERVICE_NAME",
1213
1274
  serviceNamespace: "OTEL_HOOK_SERVICE_NAMESPACE",
@@ -1370,6 +1431,22 @@ var parseEnvironmentConfig = (env) => {
1370
1431
  ...logsEndpoint === void 0 ? {} : { endpoint: logsEndpoint },
1371
1432
  ...logsIncludeContent === void 0 ? {} : { includeContent: logsIncludeContent }
1372
1433
  };
1434
+ const metricsEnabled = readBoolean(ENVIRONMENT_VARIABLES.metricsEnabled);
1435
+ const metricsEndpoint = readString(ENVIRONMENT_VARIABLES.metricsEndpoint) ?? readString(ENVIRONMENT_VARIABLES.otlpMetricsEndpoint) ?? (hookEndpoint === void 0 && otlpTracesEndpoint !== void 0 && otlpBaseEndpoint !== void 0 ? otlpSignalEndpointFromBase(otlpBaseEndpoint, "metrics") : void 0);
1436
+ const temporalityRaw = readString(ENVIRONMENT_VARIABLES.otlpMetricsTemporality)?.toLowerCase();
1437
+ let metricsTemporality;
1438
+ if (temporalityRaw === "cumulative") {
1439
+ metricsTemporality = "cumulative";
1440
+ } else if (temporalityRaw === "delta" || temporalityRaw === "lowmemory") {
1441
+ metricsTemporality = "delta";
1442
+ } else if (temporalityRaw !== void 0) {
1443
+ warn(ENVIRONMENT_VARIABLES.otlpMetricsTemporality, "expected cumulative, delta, or lowmemory");
1444
+ }
1445
+ const metrics = {
1446
+ ...metricsEnabled === void 0 ? {} : { enabled: metricsEnabled },
1447
+ ...metricsEndpoint === void 0 ? {} : { endpoint: metricsEndpoint },
1448
+ ...metricsTemporality === void 0 ? {} : { temporality: metricsTemporality }
1449
+ };
1373
1450
  const otlpHeaders = resolveOtlpHeaders(env);
1374
1451
  for (const { variable, detail } of otlpHeaders.warnings) {
1375
1452
  warn(variable, detail);
@@ -1384,7 +1461,8 @@ var parseEnvironmentConfig = (env) => {
1384
1461
  ...serviceName === void 0 ? {} : { serviceName },
1385
1462
  ...serviceNamespace === void 0 ? {} : { serviceNamespace },
1386
1463
  ...Object.keys(resourceAttributes).length === 0 ? {} : { resourceAttributes },
1387
- ...Object.keys(logs).length === 0 ? {} : { logs }
1464
+ ...Object.keys(logs).length === 0 ? {} : { logs },
1465
+ ...Object.keys(metrics).length === 0 ? {} : { metrics }
1388
1466
  };
1389
1467
  const limits = {
1390
1468
  ...maxStringLength === void 0 ? {} : { maxStringLength },
@@ -1415,10 +1493,12 @@ export {
1415
1493
  CONFIG_SOURCE_PRECEDENCE,
1416
1494
  DEFAULT_CONFIG,
1417
1495
  DEFAULT_DESTINATION_NAME,
1496
+ DEFAULT_DESTINATION_SIGNALS,
1418
1497
  DEFAULT_DETECTION_POLICY,
1419
1498
  DEFAULT_DIAGNOSTICS_POLICY,
1420
1499
  DEFAULT_EXPORTER_POLICY,
1421
1500
  DEFAULT_LOGS_POLICY,
1501
+ DEFAULT_METRICS_POLICY,
1422
1502
  DEFAULT_PROVIDERS_POLICY,
1423
1503
  DEFAULT_SPOOL_POLICY,
1424
1504
  DESTINATION_NAME_PATTERN,
@@ -1445,6 +1525,7 @@ export {
1445
1525
  describeResourceAttributeNames,
1446
1526
  detectionPolicySchema,
1447
1527
  diagnosticsPolicySchema,
1528
+ effectiveMetricsPolicy,
1448
1529
  effectiveSpoolPolicy,
1449
1530
  endpointOrigin,
1450
1531
  exportDestinationSchema,
@@ -1456,6 +1537,7 @@ export {
1456
1537
  isSecretResourceAttributeKey,
1457
1538
  logsPolicySchema,
1458
1539
  mergeOtlpHeaders,
1540
+ metricsPolicySchema,
1459
1541
  otelHookConfigPatchSchema,
1460
1542
  otelHookConfigSchema,
1461
1543
  otlpSignalEndpointFromBase,