@osfactory/otel-hook 0.8.0 → 0.9.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 CHANGED
@@ -286,7 +286,10 @@ 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. Exits 1 when any check fails,
289
+ configuration, privacy mode, and the adapter count. With
290
+ [multiple destinations](#multiple-destinations) it also reports each one: its
291
+ signals and endpoint origins, the environment variables its headers reference (by
292
+ name — never a value), any that are missing, and its spool depth and drops. Exits 1 when any check fails,
290
293
  so CI can gate on it. Every check is local: `doctor` never sends a span.
291
294
 
292
295
  ### `setup`, `diagnose`, `uninstall`
@@ -324,6 +327,10 @@ conservative by construction:
324
327
  create no directories; `--dry-run` prints the exact bytes a real run would
325
328
  write.
326
329
 
330
+ To register a hook that reads a configuration file — for example one with
331
+ [multiple destinations](#multiple-destinations) — pass the full command:
332
+ `--hook-command "otel-hook run --provider claude-code --config-file /path/to/otel-hook.json"`.
333
+
327
334
  `--scope` is `project` by default for `setup` and `uninstall` (writing into a home
328
335
  directory is the surprising choice) and `all` for `diagnose`. Only events the
329
336
  adapter turns into telemetry are registered; `--event` overrides that.
@@ -434,6 +441,8 @@ the remaining gap, and it is a *location* gap rather than a shape one: `setup`
434
441
  requires `--settings-file`. `PROVIDER_REGISTRATION_SUPPORT` carries the reason and
435
442
  the `evidenceBlocker` per provider;
436
443
  [docs/registration-evidence.md](docs/registration-evidence.md) is the long form.
444
+ End-to-end proof runs per provider (a real session, a disk OTLP receiver, and an
445
+ evidence checker) follow [docs/e2e-proof.md](docs/e2e-proof.md).
437
446
 
438
447
  ## Canonical model
439
448
 
@@ -813,6 +822,113 @@ export OTEL_RESOURCE_ATTRIBUTES="session.id=run-2041,factory.work_unit.id=wu-42,
813
822
  - Langfuse filters on span attributes, which is why `factory.*` and `vcs.*` are
814
823
  [copied onto every span](#on-records-too); `factory.local.*` is not.
815
824
 
825
+ ### Multiple destinations
826
+
827
+ `exporter.destinations` sends every batch to several OTLP endpoints at once — a
828
+ local Langfuse and a team Collector, say — with no proxy or Collector in between.
829
+ otel-hook is a short-lived process, so it does the fan-out itself: each enabled
830
+ destination is sent the same spans in parallel, each bounded by the exporter's
831
+ `timeoutMillis`, and whatever a destination could not take is kept in that
832
+ destination's own disk spool for the next hook event.
833
+
834
+ A standalone configuration, Langfuse plus a local Collector:
835
+
836
+ ```json
837
+ {
838
+ "exporter": {
839
+ "destinations": [
840
+ {
841
+ "name": "langfuse",
842
+ "endpoint": "http://localhost:3000/api/public/otel/v1/traces",
843
+ "headers": { "authorization": "env:LANGFUSE_AUTH" },
844
+ "signals": ["traces"]
845
+ },
846
+ {
847
+ "name": "collector",
848
+ "endpoint": "http://127.0.0.1:4318/v1/traces"
849
+ }
850
+ ]
851
+ }
852
+ }
853
+ ```
854
+
855
+ ```bash
856
+ # Langfuse's OTLP endpoint takes HTTP Basic auth: base64 of "public-key:secret-key".
857
+ export LANGFUSE_AUTH="Basic $(printf '%s' "$LANGFUSE_PUBLIC_KEY:$LANGFUSE_SECRET_KEY" | base64)"
858
+
859
+ otel-hook doctor --config-file ~/.config/otel-hook/destinations.json
860
+ otel-hook setup --provider claude-code \
861
+ --hook-command "otel-hook run --provider claude-code --config-file $HOME/.config/otel-hook/destinations.json"
862
+ ```
863
+
864
+ Each destination takes:
865
+
866
+ | Field | Default | Meaning |
867
+ | --- | --- | --- |
868
+ | `name` | — | Unique; lowercase letters, digits, `_` and `-`. Also its spool directory. `default` is reserved. |
869
+ | `endpoint` | — | Traces URL, as `exporter.endpoint`. The logs URL is derived from it (`/v1/traces` → `/v1/logs`). |
870
+ | `tracesEndpoint`, `logsEndpoint` | — | Per-signal URLs, overriding `endpoint`. At least one of the three is required. |
871
+ | `protocol` | `exporter.protocol` | `http/protobuf` is the protocol this build sends. |
872
+ | `headers` | `{}` | Header name → value. `"env:NAME"` reads the value from that environment variable when sending. |
873
+ | `signals` | `["traces", "logs"]` | Which signals it receives. Logs still need `exporter.logs.enabled`. |
874
+ | `enabled` | `true` | `false` keeps the entry but neither sends to it nor drains its spool. |
875
+
876
+ Everything else — timeout, batch sizes, service identity, resource attributes,
877
+ log content policy — is shared, so every destination receives the same spans with
878
+ the same trace and span ids.
879
+
880
+ **Secrets stay out of the file.** A header value of `env:LANGFUSE_AUTH` is read from
881
+ the hook's environment at send time; the variable's *name* is the only part that
882
+ ever appears in a snapshot, a diagnostic, or `doctor`. If the variable is unset or
883
+ empty, that destination sits the invocation out with a stderr diagnostic naming
884
+ the variable — it is never sent a request without its credentials — and `doctor`
885
+ fails the `destinations` check with the same name. Literal header values are
886
+ accepted for things that are not secrets (a tenant id) and are never printed either.
887
+
888
+ **The single endpoint is the `default` destination.** `exporter.endpoint`,
889
+ `exporter.logs.endpoint`, `--endpoint`, `--header`, the standard
890
+ `OTEL_EXPORTER_OTLP_ENDPOINT` / `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` /
891
+ `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` variables (see [Exporter
892
+ endpoints](#exporter-endpoints)), and the `OTEL_EXPORTER_OTLP_HEADERS` /
893
+ `OTEL_EXPORTER_OTLP_TRACES_HEADERS` / `OTEL_EXPORTER_OTLP_LOGS_HEADERS` variables
894
+ (see [Exporter headers](#exporter-headers)) still describe one destination, named
895
+ `default`, resolved exactly as described in those sections. Those header
896
+ variables apply to `default` only; a `destinations[]` entry sends exactly the
897
+ headers it lists. With no `destinations` list nothing changes. With a list,
898
+ `default` is sent to as well whenever one of those settings names an endpoint —
899
+ so an existing setup keeps receiving alongside the new ones.
900
+ The list merges as one leaf: a higher configuration layer that sets it replaces it
901
+ whole.
902
+
903
+ **A failing destination never blocks the others or the agent.** A destination
904
+ that refuses the connection, times out, or answers a retryable status (408, 429,
905
+ 500, 502, 503, 504) has the batch written to its spool; one that answers any other
906
+ error status has refused *this batch*, so it is reported and not spooled. A 500 is
907
+ treated as transient, like the OTLP-specified retryable set, because a backend
908
+ restarting or overloaded commonly answers with it; the spool's bounds below are
909
+ what keep a backend that answers 500 forever from holding batches forever. Either
910
+ way the hook exits 0 with a diagnostic on stderr, and the other destinations are
911
+ unaffected. A callback that reached at least one destination (or a spool) is
912
+ committed — retrying it would duplicate spans at the destinations that accepted.
913
+
914
+ **Spools are per destination and bounded.** Every destination queues under
915
+ `<state-dir>/<provider>/<installation>/destinations/<name>/` (`default` keeps the
916
+ original `spool` and `spool-logs` directories), and each spool is drained at the
917
+ end of the next hook event. Bounds apply per destination and per signal, and can
918
+ be set under `exporter.spool`:
919
+
920
+ | Bound | Default |
921
+ | --- | --- |
922
+ | `maxBytes` | 16 MiB |
923
+ | `maxAgeMillis` | 72 hours |
924
+ | `maxBatches` | 500 |
925
+
926
+ When a bound is reached the **oldest** batches are dropped first; a batch older
927
+ than `maxAgeMillis` is dropped rather than sent; a spooled batch a destination
928
+ later refuses with a non-retryable status is dropped instead of blocking the
929
+ queue behind it. Every drop is counted on disk, by reason, and `otel-hook doctor`
930
+ reports each destination's queued batches, bytes, and drops.
931
+
816
932
  ### Resource attributes
817
933
 
818
934
  `exporter.resourceAttributes` adds custom attributes to the OTLP Resource every