-
Notifications
You must be signed in to change notification settings - Fork 0
Add comprehensive README documentation for MariaDB Profiler #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
51eacbc
README.mdを作成
claude 0c30887
Rewrite README in English
claude 1b9446b
Skip CI when PR has no_run label
claude 14b765e
Auto-cancel superseded workflow runs on same branch
claude dff105d
Add JetBrains Plugin to release workflow
claude c19cd34
Add IntelliJ Plugin section to README
39ff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| # MariaDB Profiler for PHP | ||
|
|
||
| A MariaDB/MySQL query profiler that runs as a PHP extension. It hooks into PHP's `mysqlnd` driver to intercept, record, and analyze all executed SQL queries. | ||
|
|
||
| Works with any database access method that uses mysqlnd, including PDO, mysqli, and Laravel Eloquent. | ||
|
|
||
| ## IntelliJ Plugin Ready | ||
| <img width="4012" height="2800" alt="ss0" src="https://github.com/user-attachments/assets/a38dbc5f-69ee-4f48-9aa1-e3fb0eb07de8" /><BR> | ||
| <img width="3996" height="2436" alt="ss1" src="https://github.com/user-attachments/assets/460b75a9-996e-4c20-8e6f-818b4550f5d6" /><BR> | ||
| <img width="3996" height="2436" alt="ss2" src="https://github.com/user-attachments/assets/78388037-728d-477b-bfba-1c3f75e0e1b0" /> | ||
|
|
||
|
|
||
|
|
||
| ## Components | ||
|
|
||
| | Component | Description | | ||
| |---|---| | ||
| | `ext/mariadb_profiler/` | PHP extension (C) | | ||
| | `cli/` | CLI profiler management tool (PHP) | | ||
| | `demo/` | Docker-based web demo (Laravel + WebSocket) | | ||
| | `jetbrains-plugin/` | JetBrains IDE plugin (Kotlin) | | ||
|
|
||
| ## Features | ||
|
|
||
| - **Query interception** — Captures all SQL queries at the mysqlnd level | ||
| - **Context tags** — Stack-based tags to group queries by business logic | ||
| - **PHP backtrace** — Records call stacks at configurable depth | ||
| - **Prepared statement support** — Logs bound parameters (PHP 7.0+) | ||
| - **SQL analysis** — Automatic extraction of table and column names | ||
| - **Job management** — Concurrent profiling sessions with parent-child relationships | ||
| - **Cross-platform** — Linux / macOS / Windows | ||
|
|
||
| ## Requirements | ||
|
|
||
| | Component | Requirements | | ||
| |---|---| | ||
| | Extension | PHP 5.3 – 8.4+, mysqlnd | | ||
| | CLI tool | PHP 5.3+, Composer | | ||
| | Demo | Docker, Docker Compose | | ||
|
|
||
| ## Installation | ||
|
|
||
| ### Building the Extension | ||
|
|
||
| ```bash | ||
| cd ext/mariadb_profiler | ||
| phpize | ||
| ./configure --enable-mariadb_profiler | ||
| make | ||
| sudo make install | ||
| ``` | ||
|
|
||
| Add the following to php.ini: | ||
|
|
||
| ```ini | ||
| extension=mariadb_profiler.so | ||
| mariadb_profiler.enabled=1 | ||
| mariadb_profiler.log_dir=/var/log/mariadb_profiler | ||
| ``` | ||
|
|
||
| ### CLI Tool | ||
|
|
||
| ```bash | ||
| composer install | ||
| ``` | ||
|
|
||
| ## Configuration (php.ini) | ||
|
|
||
| ```ini | ||
| mariadb_profiler.enabled = 1 ; Enable the extension | ||
| mariadb_profiler.log_dir = /tmp/mariadb_profiler ; Log output directory | ||
| mariadb_profiler.raw_log = 1 ; Write raw text logs | ||
| mariadb_profiler.job_check_interval = 1 ; Interval to check jobs.json (seconds) | ||
| mariadb_profiler.trace_depth = 0 ; Backtrace depth (0 = disabled) | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Managing Profiling Jobs | ||
|
|
||
| ```bash | ||
| # Start a job | ||
| php cli/mariadb_profiler.php job start [<key>] | ||
|
|
||
| # End a job | ||
| php cli/mariadb_profiler.php job end <key> | ||
|
|
||
| # List jobs | ||
| php cli/mariadb_profiler.php job list | ||
|
|
||
| # Show parsed queries | ||
| php cli/mariadb_profiler.php job show <key> [--tag=<tag>] | ||
|
|
||
| # Show raw log | ||
| php cli/mariadb_profiler.php job raw <key> | ||
|
|
||
| # Export as JSON | ||
| php cli/mariadb_profiler.php job export <key> | ||
|
|
||
| # Show tag summary | ||
| php cli/mariadb_profiler.php job tags <key> | ||
|
|
||
| # Show caller summary | ||
| php cli/mariadb_profiler.php job callers <key> | ||
|
|
||
| # Purge completed jobs | ||
| php cli/mariadb_profiler.php job purge | ||
| ``` | ||
|
|
||
| ### Tagging Queries in PHP | ||
|
|
||
| ```php | ||
| // Push a tag | ||
| mariadb_profiler_tag('checkout_flow'); | ||
|
|
||
| // Queries executed here are tagged with 'checkout_flow' | ||
| $db->query('SELECT * FROM orders WHERE user_id = ?'); | ||
|
|
||
| // Get the current tag | ||
| $tag = mariadb_profiler_get_tag(); // 'checkout_flow' | ||
|
|
||
| // Pop the tag | ||
| mariadb_profiler_untag(); | ||
| ``` | ||
|
|
||
| ### Demo | ||
|
|
||
| ```bash | ||
| cd demo | ||
| docker compose up --build | ||
| # Open http://localhost:8080 | ||
| ``` | ||
|
|
||
| ## PHP Function Reference | ||
|
|
||
| | Function | Description | | ||
| |---|---| | ||
| | `mariadb_profiler_tag(string $tag): void` | Push a context tag onto the stack | | ||
| | `mariadb_profiler_untag(?string $tag = null): ?string` | Pop a tag (optionally unwind to a specific tag) | | ||
| | `mariadb_profiler_get_tag(): ?string` | Get the current tag (null if none) | | ||
|
|
||
| ## Log Formats | ||
|
|
||
| Two files are generated per job: | ||
|
|
||
| - `{job_key}.raw.log` — One query per line in text format (with timestamp, status, tag, and trace) | ||
| - `{job_key}.jsonl` — Parsed JSON format with extracted table and column names | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLIツールのPHPバージョン要件がCIと矛盾しています。
READMEでは「PHP 5.3+」と記載されていますが、
tests.ymlのtest-cliジョブでは PHP 7.4 以降のみテストされており、コメントにもgreenlion/php-sql-parserが nullable type hints (?Type) を使用するため PHP 7.1+ が必要と明記されています。実際の最低要件に合わせて記載を修正してください。📝 修正案
📝 Committable suggestion
🤖 Prompt for AI Agents