@osfactory/otel-hook 0.9.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 (51) hide show
  1. package/README.md +124 -4
  2. package/dist/{adapter-BJiz6lqM.d.ts → adapter-DiLknaTF.d.ts} +14 -2
  3. package/dist/cli.js +2272 -730
  4. package/dist/cli.js.map +1 -1
  5. package/dist/config.d.ts +13 -4
  6. package/dist/config.js +128 -23
  7. package/dist/config.js.map +1 -1
  8. package/dist/{destinations-C6Bm89W6.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/{events-B3MHoJTD.d.ts → events-CSD_YiJ2.d.ts} +2 -0
  12. package/dist/{export-destinations-d8tZV0G4.d.ts → export-destinations-QWKGGEjk.d.ts} +131 -6
  13. package/dist/{filesystem-store-r-nNA3BA.d.ts → filesystem-store-D3SCNmbX.d.ts} +1 -1
  14. package/dist/{hook-zA1b4cWd.d.ts → hook-BOecWGSz.d.ts} +10 -5
  15. package/dist/index.d.ts +16 -16
  16. package/dist/index.js +1808 -251
  17. package/dist/index.js.map +1 -1
  18. package/dist/install.d.ts +4 -4
  19. package/dist/install.js +31 -2
  20. package/dist/install.js.map +1 -1
  21. package/dist/integration.d.ts +37 -12
  22. package/dist/integration.js +3271 -1551
  23. package/dist/integration.js.map +1 -1
  24. package/dist/lifecycle.d.ts +55 -4
  25. package/dist/lifecycle.js +277 -4
  26. package/dist/lifecycle.js.map +1 -1
  27. package/dist/{memory-Bl9ANVff.d.ts → memory-Cs51jyRk.d.ts} +2 -2
  28. package/dist/{semconv-fPRb-dpU.d.ts → metric-model-DDnWxL9d.d.ts} +154 -2
  29. package/dist/model.d.ts +1 -1
  30. package/dist/model.js +7 -0
  31. package/dist/model.js.map +1 -1
  32. package/dist/{payload-Ci8_ERm6.d.ts → payload-ChtrEX6A.d.ts} +41 -2
  33. package/dist/{ports-n7KFOpKo.d.ts → ports-CeqLq31i.d.ts} +87 -2
  34. package/dist/providers.d.ts +146 -10
  35. package/dist/providers.js +397 -13
  36. package/dist/providers.js.map +1 -1
  37. package/dist/{registry-B8ZHc2bc.d.ts → registry-CcJNF3WY.d.ts} +2 -2
  38. package/dist/runtime.d.ts +8 -8
  39. package/dist/runtime.js +1404 -1219
  40. package/dist/runtime.js.map +1 -1
  41. package/dist/{schema-BxiVsU-d.d.ts → schema-DMnoU1V_.d.ts} +93 -1
  42. package/dist/state.d.ts +4 -4
  43. package/dist/state.js +630 -39
  44. package/dist/state.js.map +1 -1
  45. package/dist/telemetry.d.ts +6 -6
  46. package/dist/telemetry.js +872 -19
  47. package/dist/telemetry.js.map +1 -1
  48. package/dist/testing.d.ts +11 -9
  49. package/dist/testing.js +264 -34
  50. package/dist/testing.js.map +1 -1
  51. package/package.json +3 -1
@@ -1,28 +1,28 @@
1
- import { O as OtelHookConfig } from './schema-BxiVsU-d.js';
1
+ import { O as OtelHookConfig } from './schema-DMnoU1V_.js';
2
2
  import { OverallHealth } from './diagnostics.js';
3
3
  import { OtelHookErrorInfo } from './errors.js';
4
- import { DeliveryClaimOutcome, UsageAccumulatorSnapshot, LifecycleCleanupReport, CallbackDeduplicator, UsageAccumulator, SpanCorrelator, LifecycleJanitor } from './lifecycle.js';
4
+ import { DeliveryClaimOutcome, UsageAccumulatorSnapshot, LifecycleCleanupReport, CallbackDeduplicator, UsageAccumulator, SpanCorrelator, MetricSeriesStore, LifecycleJanitor } from './lifecycle.js';
5
5
  import { P as PrivacyService } from './service-CbI9CObT.js';
6
- import { P as ProviderRegistry } from './registry-B8ZHc2bc.js';
7
- import { a as DeliveryOrigin, c as DeliveryUnavailableReason, H as HookIngestInput, e as HookIngestOutcome, U as UsageObservation, O as OtelHook } from './hook-zA1b4cWd.js';
8
- import { C as Clock, I as IdGenerator, d as Logger, W as WorktreeLocator } from './ports-n7KFOpKo.js';
9
- import { F as FilesystemStateStore } from './filesystem-store-r-nNA3BA.js';
10
- import { p as OtlpTelemetrySink, o as OtlpLogTelemetrySink, b as DurableSpool, D as DurableLogSpool, E as ExportDestinationSinks, u as SkippedExportDestination } from './export-destinations-d8tZV0G4.js';
6
+ import { P as ProviderRegistry } from './registry-CcJNF3WY.js';
7
+ import { a as DeliveryOrigin, c as DeliveryUnavailableReason, H as HookIngestInput, e as HookIngestOutcome, U as UsageObservation, O as OtelHook } from './hook-BOecWGSz.js';
8
+ import { C as Clock, I as IdGenerator, d as Logger, W as WorktreeLocator, P as PayloadEnricher } from './ports-CeqLq31i.js';
9
+ import { F as FilesystemStateStore } from './filesystem-store-D3SCNmbX.js';
10
+ import { w as OtlpTelemetrySink, t as OtlpLogTelemetrySink, d as DurableSpool, D as DurableLogSpool, E as ExportDestinationSinks, B as SkippedExportDestination } from './export-destinations-QWKGGEjk.js';
11
11
  import 'zod';
12
12
  import './primitives-CJ8-rn-f.js';
13
13
  import './taxonomy-DwhTtuWd.js';
14
14
  import '@opentelemetry/api';
15
- import './events-B3MHoJTD.js';
16
- import './semconv-fPRb-dpU.js';
15
+ import './events-CSD_YiJ2.js';
16
+ import './metric-model-DDnWxL9d.js';
17
17
  import '@opentelemetry/core';
18
18
  import '@opentelemetry/resources';
19
19
  import '@opentelemetry/sdk-trace';
20
20
  import './content-M9xIKG7h.js';
21
21
  import './policy-CimmCfRp.js';
22
- import './adapter-BJiz6lqM.js';
22
+ import './adapter-DiLknaTF.js';
23
23
  import './identity-BrVBs901.js';
24
24
  import './keys-Dej5bN3L.js';
25
- import './destinations-C6Bm89W6.js';
25
+ import './destinations-BIl3gGzx.js';
26
26
  import '@opentelemetry/sdk-logs';
27
27
 
28
28
  /**
@@ -189,11 +189,27 @@ type HookProcessOutcome = {
189
189
  readonly delivery: DeliveryReport;
190
190
  /** Running per-scope totals after applying this invocation's deltas. */
191
191
  readonly usageRollups: readonly UsageRollup[];
192
+ /**
193
+ * Hook-derived metrics for this callback (issue #69). Absent when no destination
194
+ * takes metrics, or when nothing was recorded (a redelivery, a callback whose
195
+ * telemetry was lost and will be retried, or a batch with nothing to measure).
196
+ */
197
+ readonly metrics?: MetricsReport;
192
198
  /** Cleanup performed opportunistically; absent when no sweep ran. */
193
199
  readonly cleanup?: LifecycleCleanupReport;
194
200
  /** Diagnostics raised by this module, in addition to `ingest.diagnostics`. */
195
201
  readonly diagnostics: readonly OtelHookErrorInfo[];
196
202
  };
203
+ type MetricsReport = {
204
+ /** Data points derived for this callback, before fan-out. */
205
+ readonly points: number;
206
+ /** Per destination taking metrics: points delivered or spooled, and refused. */
207
+ readonly destinations: readonly {
208
+ readonly name: string;
209
+ readonly accepted: number;
210
+ readonly rejected: number;
211
+ }[];
212
+ };
197
213
  type UsageRollup = {
198
214
  readonly scope: UsageObservation["scope"];
199
215
  readonly scopeKey: string;
@@ -229,6 +245,8 @@ interface HookRuntime {
229
245
  readonly usageAccumulator: UsageAccumulator;
230
246
  /** Backs the cross-process pairing the sink applies to every exported span. */
231
247
  readonly spanCorrelator: SpanCorrelator;
248
+ /** Cumulative metric series state (issue #69). */
249
+ readonly metricSeries: MetricSeriesStore;
232
250
  readonly janitor: LifecycleJanitor;
233
251
  /** Ingest one observation, then apply lifecycle accumulation. Never throws. */
234
252
  process(input: HookProcessInput): Promise<HookProcessOutcome>;
@@ -302,6 +320,13 @@ type HookRuntimeOptions = {
302
320
  * `null` to disable resolution entirely.
303
321
  */
304
322
  readonly worktreeLocator?: WorktreeLocator | null;
323
+ /**
324
+ * Payload enrichers run before the adapter parses (see `PayloadEnricher`).
325
+ * When absent, the configuration decides: `providers.claudeCode.readTranscriptUsage`
326
+ * adds the Claude Code transcript-usage enricher, and nothing else is added.
327
+ * Pass `[]` to run none regardless of configuration.
328
+ */
329
+ readonly payloadEnrichers?: readonly PayloadEnricher[];
305
330
  };
306
331
  /**
307
332
  * Smallest stale-claim window that cannot expire while a live process is still
@@ -329,4 +354,4 @@ declare const minimumStaleClaimMillis: (input: {
329
354
  }) => number;
330
355
  declare const createHookRuntime: (options: HookRuntimeOptions) => HookRuntime;
331
356
 
332
- export { type DeliveryReport, type HookProcessInput, type HookProcessOutcome, type HookRuntime, type HookRuntimeDelivery, type HookRuntimeOptions, type HookShutdownReport, type UsageRollup, createHookRuntime, minimumStaleClaimMillis };
357
+ export { type DeliveryReport, type HookProcessInput, type HookProcessOutcome, type HookRuntime, type HookRuntimeDelivery, type HookRuntimeOptions, type HookShutdownReport, type MetricsReport, type UsageRollup, createHookRuntime, minimumStaleClaimMillis };