@osfactory/otel-hook 0.11.0 → 0.13.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 +32 -5
- package/dist/{adapter-DiLknaTF.d.ts → adapter-DyCb7y1N.d.ts} +2 -2
- package/dist/cli.js +507 -108
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +3 -3
- package/dist/config.js +16 -3
- package/dist/config.js.map +1 -1
- package/dist/{destinations-BIl3gGzx.d.ts → destinations-DvqsPulb.d.ts} +1 -1
- package/dist/{events-CSD_YiJ2.d.ts → events-fcomX6d5.d.ts} +22 -0
- package/dist/{export-destinations-QWKGGEjk.d.ts → export-destinations-Bey2djRk.d.ts} +11 -6
- package/dist/{filesystem-store-D3SCNmbX.d.ts → filesystem-store-B3CpiIRl.d.ts} +1 -1
- package/dist/{hook-BOecWGSz.d.ts → hook-D5imE0Qc.d.ts} +11 -5
- package/dist/index.d.ts +14 -14
- package/dist/index.js +525 -143
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +4 -4
- package/dist/install.js +19 -2
- package/dist/install.js.map +1 -1
- package/dist/integration.d.ts +16 -10
- package/dist/integration.js +447 -111
- package/dist/integration.js.map +1 -1
- package/dist/lifecycle.d.ts +3 -3
- package/dist/lifecycle.js +10 -2
- package/dist/lifecycle.js.map +1 -1
- package/dist/{memory-Cs51jyRk.d.ts → memory-B3r6sZtC.d.ts} +2 -2
- package/dist/{metric-model-DDnWxL9d.d.ts → metric-model-CFIeUwqd.d.ts} +6 -2
- package/dist/model.d.ts +1 -1
- package/dist/model.js +9 -1
- package/dist/model.js.map +1 -1
- package/dist/{payload-ChtrEX6A.d.ts → payload-CdDKeRpH.d.ts} +1 -1
- package/dist/{ports-CeqLq31i.d.ts → ports-DhpSDIkp.d.ts} +41 -3
- package/dist/providers.d.ts +30 -14
- package/dist/providers.js +131 -42
- package/dist/providers.js.map +1 -1
- package/dist/{registry-CcJNF3WY.d.ts → registry-BKQhhIO3.d.ts} +2 -2
- package/dist/runtime.d.ts +97 -9
- package/dist/runtime.js +269 -26
- package/dist/runtime.js.map +1 -1
- package/dist/{schema-DMnoU1V_.d.ts → schema-SpFM6YQY.d.ts} +24 -1
- package/dist/state.d.ts +4 -4
- package/dist/state.js +9 -1
- package/dist/state.js.map +1 -1
- package/dist/telemetry.d.ts +6 -6
- package/dist/telemetry.js +80 -22
- package/dist/telemetry.js.map +1 -1
- package/dist/testing.d.ts +10 -8
- package/dist/testing.js +161 -30
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -286,7 +286,7 @@ otel-hook doctor --json
|
|
|
286
286
|
|
|
287
287
|
Reports the version, an attribute-safe configuration snapshot, a real
|
|
288
288
|
write/read/delete probe of the state directory, spool depth, exporter
|
|
289
|
-
configuration, privacy mode, and the adapter count. With
|
|
289
|
+
configuration, privacy mode, [session context](docs/session-context.md), and the adapter count. With
|
|
290
290
|
[multiple destinations](#multiple-destinations) it also reports each one: its
|
|
291
291
|
signals and endpoint origins, the environment variables its headers reference (by
|
|
292
292
|
name — never a value), any that are missing, and its spool depth and drops. Exits 1 when any check fails,
|
|
@@ -639,10 +639,12 @@ resource), no content, and no per-event ids.
|
|
|
639
639
|
retried, records nothing. A callback replayed after a crash restates its series'
|
|
640
640
|
totals instead of adding to them.
|
|
641
641
|
|
|
642
|
-
These numbers are **hook-derived**.
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
642
|
+
These numbers are **hook-derived**. For Claude Code, tokens exist only with
|
|
643
|
+
`providers.claudeCode.readTranscriptUsage` on: each turn's main-thread requests are
|
|
644
|
+
counted on its `Stop` generation, and each subagent's requests on a generation of
|
|
645
|
+
its own at `SubagentStop` (#68), named for the subagent's model and carrying
|
|
646
|
+
`otelhook.subagent.id`. A harness that already books Claude Code usage from native
|
|
647
|
+
telemetry should not add both.
|
|
646
648
|
|
|
647
649
|
| Field | Default | Flag | Variable |
|
|
648
650
|
| --- | --- | --- | --- |
|
|
@@ -938,6 +940,28 @@ const enriched = await attachClaudeTranscriptTurn(hookPayload);
|
|
|
938
940
|
|
|
939
941
|
See [finding 8](docs/claude-code-usage-contract.md#finding-8-the-model-is-on-sessionstart-and-in-the-transcript-never-on-stop).
|
|
940
942
|
|
|
943
|
+
#### Session context
|
|
944
|
+
|
|
945
|
+
A session's environment is fixed when the agent starts, but the work it does is
|
|
946
|
+
not: it can start in the main checkout and move into a slot later. A harness can
|
|
947
|
+
write what the session is working on to a **session context** file, and
|
|
948
|
+
otel-hook puts it on every span, log record and metric point from then on:
|
|
949
|
+
|
|
950
|
+
```bash
|
|
951
|
+
otel-hook run --provider claude-code --session-context-dir /home/dev/.har/sessions
|
|
952
|
+
# or, in --config-file: { "sessionContext": { "dir": "/home/dev/.har/sessions" } }
|
|
953
|
+
```
|
|
954
|
+
|
|
955
|
+
The hook reads `<dir>/<agent-tool>/<session-id>.json` (`claude_code`, `codex`,
|
|
956
|
+
`cursor`, …), picks the segment in force at each event's time, and applies its
|
|
957
|
+
attributes. They override the same keys from the Resource, on records and on the
|
|
958
|
+
Resource itself, so a stale `factory.attempt.id` from the environment is not
|
|
959
|
+
exported. Subagent events use their parent session's file. `factory.local.*` is
|
|
960
|
+
never applied. No file, an invalid one, or no segment in force: nothing is added,
|
|
961
|
+
and the hook never fails. There is no environment variable for it, because Claude
|
|
962
|
+
Code strips `OTEL_*` variables from hooks. Format and rules:
|
|
963
|
+
[docs/session-context.md](docs/session-context.md).
|
|
964
|
+
|
|
941
965
|
### Multiple destinations
|
|
942
966
|
|
|
943
967
|
`exporter.destinations` sends every batch to several OTLP endpoints at once — a
|
|
@@ -1124,6 +1148,9 @@ these namespaces are therefore also copied onto every span and log record:
|
|
|
1124
1148
|
described above, resolved (and trimmed) on its own. Other attributes, such as
|
|
1125
1149
|
`deployment.environment`, stay on the Resource only.
|
|
1126
1150
|
|
|
1151
|
+
[Session context](#session-context) attributes are layered over these on every
|
|
1152
|
+
record, and override the same keys on the Resource.
|
|
1153
|
+
|
|
1127
1154
|
Diagnostics report resource attribute **names** only — `doctor --json` shows
|
|
1128
1155
|
`exporter.resource_attribute_names`. A name is already on the wire in every
|
|
1129
1156
|
exported resource; a value is not disclosed anywhere a name would do.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { OtelHookErrorInfo } from './errors.js';
|
|
3
|
-
import { I as UsageTemporality, n as ModelDescriptor, b as CanonicalEvent, u as TargetHint, e as CanonicalEventType } from './events-
|
|
3
|
+
import { I as UsageTemporality, n as ModelDescriptor, b as CanonicalEvent, u as TargetHint, e as CanonicalEventType } from './events-fcomX6d5.js';
|
|
4
4
|
import { I as IdentityClaim, d as InvocationIdentity } from './identity-BrVBs901.js';
|
|
5
5
|
import { R as ResolvedProviderId, g as ProviderId, h as SourceTransport, d as EventId } from './primitives-CJ8-rn-f.js';
|
|
6
6
|
import { e as PrivacyLimits } from './policy-CimmCfRp.js';
|
|
7
7
|
import { P as PrivacyService } from './service-CbI9CObT.js';
|
|
8
|
-
import { C as Clock, I as IdGenerator, d as Logger } from './ports-
|
|
8
|
+
import { C as Clock, I as IdGenerator, d as Logger } from './ports-DhpSDIkp.js';
|
|
9
9
|
import { A as AttributionOutcome, a as AttributionReason } from './taxonomy-DwhTtuWd.js';
|
|
10
10
|
|
|
11
11
|
/** Raw input offered to adapters. `payload` is `unknown` on purpose. */
|