@osfactory/otel-hook 0.12.0 → 0.13.1

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 (40) hide show
  1. package/README.md +6 -4
  2. package/dist/{adapter-DQiPu8xF.d.ts → adapter-DyCb7y1N.d.ts} +1 -1
  3. package/dist/cli.js +260 -74
  4. package/dist/cli.js.map +1 -1
  5. package/dist/{export-destinations-CI7z4n3i.d.ts → export-destinations-DUeQKr_C.d.ts} +2 -2
  6. package/dist/{filesystem-store-CmnUlj1O.d.ts → filesystem-store-B3CpiIRl.d.ts} +1 -1
  7. package/dist/{hook-vM_cgqS2.d.ts → hook-D5imE0Qc.d.ts} +3 -3
  8. package/dist/index.d.ts +10 -10
  9. package/dist/index.js +252 -66
  10. package/dist/index.js.map +1 -1
  11. package/dist/install.d.ts +3 -3
  12. package/dist/install.js +14 -2
  13. package/dist/install.js.map +1 -1
  14. package/dist/integration.d.ts +7 -7
  15. package/dist/integration.js +211 -58
  16. package/dist/integration.js.map +1 -1
  17. package/dist/lifecycle.d.ts +9 -2
  18. package/dist/lifecycle.js +10 -3
  19. package/dist/lifecycle.js.map +1 -1
  20. package/dist/{memory-DdU1U91y.d.ts → memory-B3r6sZtC.d.ts} +1 -1
  21. package/dist/{metric-model-C9lLqqpI.d.ts → metric-model-B4lIuk6i.d.ts} +10 -1
  22. package/dist/{payload-BT19hiVZ.d.ts → payload-CdDKeRpH.d.ts} +1 -1
  23. package/dist/{ports-C3k_5eOQ.d.ts → ports-DhpSDIkp.d.ts} +8 -1
  24. package/dist/providers.d.ts +27 -11
  25. package/dist/providers.js +132 -43
  26. package/dist/providers.js.map +1 -1
  27. package/dist/{registry-gyJqaWmp.d.ts → registry-BKQhhIO3.d.ts} +1 -1
  28. package/dist/runtime.d.ts +6 -6
  29. package/dist/runtime.js +12 -2
  30. package/dist/runtime.js.map +1 -1
  31. package/dist/state.d.ts +3 -3
  32. package/dist/state.js +20 -6
  33. package/dist/state.js.map +1 -1
  34. package/dist/telemetry.d.ts +3 -3
  35. package/dist/telemetry.js +72 -6
  36. package/dist/telemetry.js.map +1 -1
  37. package/dist/testing.d.ts +6 -6
  38. package/dist/testing.js +63 -8
  39. package/dist/testing.js.map +1 -1
  40. package/package.json +2 -1
@@ -1,7 +1,7 @@
1
- import { j as StateStore, C as Clock } from './ports-C3k_5eOQ.js';
1
+ import { j as StateStore, C as Clock } from './ports-DhpSDIkp.js';
2
2
  import { Attributes } from '@opentelemetry/api';
3
3
  import { b as CanonicalEvent, f as CanonicalUsage } from './events-fcomX6d5.js';
4
- import { p as SpanFamily, s as SpanScopeRef, m as SpanCorrelation, j as MetricObservation, k as MetricPoint } from './metric-model-C9lLqqpI.js';
4
+ import { p as SpanFamily, s as SpanScopeRef, m as SpanCorrelation, j as MetricObservation, k as MetricPoint } from './metric-model-B4lIuk6i.js';
5
5
  import 'zod';
6
6
  import './errors.js';
7
7
  import './primitives-CJ8-rn-f.js';
@@ -163,6 +163,13 @@ type SpanCorrelationFacts = {
163
163
  readonly endedAt?: number;
164
164
  readonly parent?: SpanScopeRef;
165
165
  readonly attributes?: Attributes;
166
+ /**
167
+ * Set when this record is a *new run* of a scope whose span was already
168
+ * exported (a resumed Claude Code session fires `SessionStart` again for the
169
+ * same session id): the run's start event id, mixed into its span id so the
170
+ * second run never re-uses the id already on the wire.
171
+ */
172
+ readonly runKey?: string;
166
173
  };
167
174
  type SpanStartInput = {
168
175
  readonly sessionId: string;
package/dist/lifecycle.js CHANGED
@@ -271,7 +271,7 @@ import {
271
271
  } from "@opentelemetry/semantic-conventions/incubating";
272
272
 
273
273
  // src/version.ts
274
- var VERSION = "0.12.0";
274
+ var VERSION = "0.13.1";
275
275
 
276
276
  // src/telemetry/export-identity.ts
277
277
  import { ATTR_SESSION_ID } from "@opentelemetry/semantic-conventions/incubating";
@@ -1185,6 +1185,7 @@ var encodeRecord = (record) => ({
1185
1185
  ...record.endEventId === void 0 ? {} : { endEventId: record.endEventId },
1186
1186
  ...record.endedAt === void 0 ? {} : { endedAt: record.endedAt },
1187
1187
  ...record.exported === true ? { exported: true } : {},
1188
+ ...record.runKey === void 0 ? {} : { runKey: record.runKey },
1188
1189
  ...record.parent === void 0 ? {} : { parentFamily: record.parent.family, parentScopeKey: record.parent.scopeKey },
1189
1190
  ...encodeAttributes(record.attributes)
1190
1191
  }
@@ -1208,6 +1209,7 @@ var decodeRecord = (attributes) => {
1208
1209
  return { kind: "corrupt" };
1209
1210
  }
1210
1211
  const exported = attributes["exported"] === true;
1212
+ const runKey = optionalString(attributes["runKey"]);
1211
1213
  const parentFamily = attributes["parentFamily"];
1212
1214
  const parentScopeKey = optionalString(attributes["parentScopeKey"]);
1213
1215
  const parent = isSpanFamily(parentFamily) && parentScopeKey !== void 0 ? { family: parentFamily, scopeKey: parentScopeKey } : void 0;
@@ -1222,6 +1224,7 @@ var decodeRecord = (attributes) => {
1222
1224
  ...endedAt === void 0 ? {} : { endedAt },
1223
1225
  ...parent === void 0 ? {} : { parent },
1224
1226
  ...exported ? { exported: true } : {},
1227
+ ...runKey === void 0 ? {} : { runKey },
1225
1228
  ...decodedAttributes === void 0 ? {} : { attributes: decodedAttributes }
1226
1229
  }
1227
1230
  };
@@ -1230,13 +1233,15 @@ var factsOf = (record) => ({
1230
1233
  ...record.startedAt === void 0 ? {} : { startedAt: record.startedAt },
1231
1234
  ...record.endedAt === void 0 ? {} : { endedAt: record.endedAt },
1232
1235
  ...record.parent === void 0 ? {} : { parent: record.parent },
1233
- ...record.attributes === void 0 ? {} : { attributes: record.attributes }
1236
+ ...record.attributes === void 0 ? {} : { attributes: record.attributes },
1237
+ ...record.runKey === void 0 ? {} : { runKey: record.runKey }
1234
1238
  });
1235
1239
  var correlationTimesOf = (facts, options = { withStart: true }) => ({
1236
1240
  ...facts.startedAt === void 0 || !options.withStart ? {} : { startMillis: facts.startedAt },
1237
1241
  ...facts.endedAt === void 0 ? {} : { endMillis: facts.endedAt },
1238
1242
  ...facts.parent === void 0 ? {} : { parent: facts.parent },
1239
- ...facts.attributes === void 0 ? {} : { attributes: facts.attributes }
1243
+ ...facts.attributes === void 0 ? {} : { attributes: facts.attributes },
1244
+ ...facts.runKey === void 0 ? {} : { runSpanIdDiscriminator: facts.runKey }
1240
1245
  });
1241
1246
  var orphanClassificationOf = (reason) => {
1242
1247
  switch (reason) {
@@ -1296,10 +1301,12 @@ var createSpanCorrelator = (deps) => {
1296
1301
  return existing.exported === true ? { status: "published", facts: factsOf(completed) } : { status: "recorded", facts: factsOf(completed) };
1297
1302
  }
1298
1303
  }
1304
+ const previouslyExported = decoded.kind === "present" && decoded.record.exported === true;
1299
1305
  const fresh = {
1300
1306
  providerId: input.providerId,
1301
1307
  startEventId: input.eventId,
1302
1308
  startedAt: input.occurredAt,
1309
+ ...previouslyExported ? { runKey: input.eventId } : {},
1303
1310
  ...input.parent === void 0 ? {} : { parent: input.parent },
1304
1311
  ...input.attributes === void 0 ? {} : { attributes: input.attributes }
1305
1312
  };