Skip to content

Add MySQL trace functionality#2

Closed
epli2 wants to merge 2 commits into
mainfrom
claude/add-mysql-trace-m434f
Closed

Add MySQL trace functionality#2
epli2 wants to merge 2 commits into
mainfrom
claude/add-mysql-trace-m434f

Conversation

@epli2

@epli2 epli2 commented Mar 2, 2026

Copy link
Copy Markdown
Owner

claude added 2 commits March 2, 2026 01:07
Adds end-to-end MySQL query observability without any application
instrumentation, using the existing LD_PRELOAD agent.

Changes:
- phantom-core: new `mysql` module with `MysqlTrace`, `MysqlResponseKind`
  (Ok/ResultSet/Err), and `MysqlStore` trait
- phantom-storage: `FjallMysqlStore` — Fjall-backed `MysqlStore` with two
  partitions (by span_id and by timestamp) for ordered queries
- phantom-agent: `connect()` hook detects MySQL connections by port
  (default 3306, overridable via `PHANTOM_MYSQL_PORT`); per-FD state machine
  (`MysqlConnState`) handles handshake, COM_QUERY, and server response
  parsing (OK / ERR / ResultSet); emits `MysqlTraceMsg` JSON over the
  existing Unix datagram socket with `msg_type = "mysql"`
- phantom-capture: `dispatch_agent_message()` peeks at `msg_type` to route
  HTTP vs MySQL; `start_mysql_aware()` returns both channels; existing
  `CaptureBackend::start()` preserved for backward compatibility
- phantom-tui: new MySQL tab (key `2`); `App` tracks MySQL traces and
  selected index; UI renders list with Time/Query/Result/Duration columns
  and a detail pane; status bar shows `HTTP: N | MySQL: N`
- src/main.rs: opens `FjallMysqlStore`; proxy backend uses a dummy MySQL
  channel; ldpreload backend uses `start_mysql_aware()`; JSONL mode emits
  MySQL traces as `{"type":"mysql", ...}` objects

https://claude.ai/code/session_015N7iRe1Pkx41rHgvgKQaTC
Records the design decisions, implementation order, and test strategy
that guided the MySQL trace feature addition.

https://claude.ai/code/session_015N7iRe1Pkx41rHgvgKQaTC

epli2 commented Jul 6, 2026

Copy link
Copy Markdown
Owner Author

Closing this PR for now based on the project roadmap (ROADMAP.md, §1.2 and §9 / ADR-1).

Rationale:

  • The current roadmap prioritizes finishing the HTTP-layer core experience (persistent CA/HTTPS trust, compression handling, TUI usability) before adding a second protocol. Landing MySQL tracing now would double the surface area (storage, TUI, JSONL schema) while that core is still being hardened.
  • This branch is based on a main from several months ago (d77ef69) and touches files that have since changed significantly (src/main.rs, crates/phantom-tui/src/{app,ui,lib}.rs), so it would need a substantial rebase regardless.
  • The roadmap's Phase 4 (long-term research track, task P4-4) calls for generalizing HttpTrace into a protocol-agnostic event model before adding non-HTTP protocols (MySQL/PostgreSQL/Redis/gRPC) as plugins. The packet-parsing work here is valuable and is intended to be reused at that point.

This isn't a rejection of the feature — I've opened #6 to track it as deferred, future work referencing this PR. Closing without prejudice; feel free to reopen or link a fresh branch once P4-4 lands.


Generated by Claude Code

@epli2 epli2 closed this Jul 6, 2026
epli2 pushed a commit that referenced this pull request Jul 6, 2026
Analyze current implementation and open PRs (#2, #4), redefine phantom's
concept as a local-first API development toolbox (observe / perturb /
record-replay / spec-gen), and lay out a 5-phase roadmap (P0-P4) with
per-task dependencies, implementation steps, acceptance criteria, and an
LLM-agent working protocol.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EgPcomgY5nj8RuU8V1G82Y
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.

2 participants