Skip to content

Add OpenClaw integration — zero-code OTLP ingestion - #15

Merged
anilmurty merged 1 commit into
mainfrom
add-openclaw-integration
Apr 8, 2026
Merged

anilmurty merged 1 commit into
mainfrom
add-openclaw-integration

Conversation

@anilmurty

Copy link
Copy Markdown
Contributor

Summary

  • OTLP route aliases: POST /v1/traces forwards to the same OTLP JSON ingest handler as /api/v1/spans. POST /v1/metrics and /v1/logs are 200 stubs (OpenClaw sends all three; stubs prevent noisy warnings).
  • OpenClaw attribute mapping: _parse_span() now handles OpenClaw-specific patterns:
    • service.name resource attribute used as agent_id fallback (OpenClaw sets this, not gen_ai.agent.id)
    • gen_ai.system used as provider fallback (OpenClaw uses this instead of gen_ai.provider.name)
    • tool.* span names extract tool_name (e.g. tool.Read → Read, tool.exec → exec)
    • openclaw.model.usage spans pass through token extraction normally
  • Docs: docs/openclaw.md setup guide + examples/openclaw/README.md with config snippets and verification commands
  • README: OpenClaw added to top of zero-code OTLP table with setup guide link

Test plan

  • 11 new tests in test_openclaw_ingest.py: route aliases (3), attribute mapping (8 including realistic full-payload test)
  • All 243 tests pass
  • ruff check clean
  • Manual: configure OpenClaw diagnostics-otel → http://127.0.0.1:7391, verify spans appear in ocw traces

🤖 Generated with Claude Code

- Add standard OTLP route aliases: POST /v1/traces (forwards to ingest
  handler), POST /v1/metrics and /v1/logs (200 stubs to silence client
  warnings). OpenClaw's diagnostics-otel plugin exports to these paths.

- Enrich _parse_span() attribute mapping for OpenClaw spans:
  - service.name fallback for agent_id when gen_ai.agent.id is absent
  - gen_ai.system fallback for provider when gen_ai.provider.name is absent
  - tool.* span names extract tool_name (e.g. tool.Read -> Read)

- Add docs/openclaw.md setup guide and examples/openclaw/README.md
- Add OpenClaw to README.md framework support (top of zero-code table)
- 11 new tests covering route aliases and attribute mapping

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@anilmurty
anilmurty merged commit 68e8d71 into main Apr 8, 2026
4 checks passed
@anilmurty
anilmurty deleted the add-openclaw-integration branch April 8, 2026 17:28
anilmurty added a commit that referenced this pull request Jun 19, 2026
HoomanDgtl pushed a commit to HoomanDigital/tokenjam that referenced this pull request Jun 20, 2026
Metabuilder-Labs#5: replace the stale Metabuilder-Labs/openclawwatch#configuration URL (old
project name → 404) in both the generated config header and the onboard 'Next
steps' output with Metabuilder-Labs/tokenjam (Critical Rule 13).

Metabuilder-Labs#15: emit all four [capture] toggles — the writer omitted tool_inputs (CLAUDE.md
documents prompts/completions/tool_inputs/tool_outputs), leaving the generated
config inconsistent with the documented surface.

Tests: generated config carries all four capture toggles; no openclawwatch in
the config or console output. Lint clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
anilmurty pushed a commit that referenced this pull request Jul 2, 2026
The Claude Code backfill ran one existence-check SELECT plus one INSERT per
span in `_insert_session_idempotent` — ~2 DuckDB round-trips per span, so a
large history (~120k spans) paid ~240k statements (~100s). #13 bounded only
the quickstart first-run path; the full `tj backfill claude-code` / daemon
path still paid the full per-span cost.

Replace the per-span loop with a bulk path that processes a whole session in
a BOUNDED number of statements regardless of span count:

- Partition new-vs-existing span_ids in ONE chunked `WHERE span_id IN (...)`
  query (`_existing_span_ids`) instead of N existence SELECTs.
- Bulk-insert the new spans in a single `executemany` (`_SPAN_INSERT_SQL` +
  `_span_insert_params`, kept in lock-step with `DuckDBBackend.insert_span`).
- On `--reingest`, batch-load the existing rows' attributes in ONE chunked
  query (`_load_attrs_bulk`), compute the per-key attribute merge in Python,
  then apply the updates in a single `executemany`.

The #10 idempotency + reingest contract is preserved exactly: new spans
insert; existing spans without `--reingest` are skipped untouched; existing
spans with `--reingest` get `sub_agent_id` updated and `attributes` per-key
merged (overlay `{**stored, **parsed}`, parsed wins, never wipes a stored
key). The no-`conn` fallback path is unchanged. Drops the now-unused
single-span `_load_attrs` helper.

Tests: all existing #3/#10/#13 backfill tests pass unchanged. Adds four #15
tests — bulk insert lands every new span; existing spans are skipped without
`--reingest`; `--reingest` still merges attributes (overlay, no wipe) +
updates sub_agent_id; and a counting-connection test asserting a 400-span
session inserts in a BOUNDED number of statements (well under N execute()
calls, via executemany) rather than ~2 per span.

Co-Authored-By: Claude <[email protected]>
(cherry picked from commit 6f94fe0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant