Download the PHP package prlkhv/module-graphql-ai-profiler without Composer

On this page you can find all versions of the php package prlkhv/module-graphql-ai-profiler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package module-graphql-ai-profiler

Prlkhv_GraphQlAiProfiler

Why is this exists

No one longer want to read a lot of profiler data and dig into performance traces to find out why is this request slow. Another fact, almost everyone use AI tools to explain their profile result. Soooo, I decided to remove this annoying step with copy-pasting profile result to your AI assistant with this tool

Server-side GraphQL profiler for Magento 2. It instruments GraphQL execution, builds an in-memory span tree (every resolver + every SQL query), and injects it into the GraphQL response under extensions.profiling — OTLP-shaped, or a compact LLM-friendly format for AI-assisted analysis.

No OTel Collector, no exporter, no MCP. The profiling payload rides back on the same response the client already receives, so you can profile any GraphQL request by adding a header — no separate tooling, no APM.

It also ships with a Claude Code skill so you can ask an AI "why is this request slow?" and get a root-cause analysis with next steps (see Using it with Claude).


Installation

Via Composer (recommended)

Manual

Copy this directory to app/code/Prlkhv/GraphQlAiProfiler, then:


Setup

The module is inert until every activation condition is met. Configure it under Stores → Configuration → Advanced → Developer → GraphQL Profiler, or via CLI:

Model\Config::isActive() returns true only when all of these hold:

# Condition Config path Default
1 Enabled dev/graphql_profiler/enabled = 1 0
2 Deploy mode allowed dev/graphql_profiler/mode_allowlist contains the current mode developer
3 Secret matches request header X-GraphQl-Profiler == dev/graphql_profiler/secret (hash_equals) empty

If any fails, every plugin passes through with near-zero overhead and nothing profiling-related appears in the response.

All settings


Usage

Add the activation header to any GraphQL request. Choose a response format with X-GraphQl-Profiler-Format.

Verbose OTLP format (default)

The response gains extensions.profiling with an OTLP-shaped resourceSpans tree. Feed it to any OTLP-aware viewer, or read it directly.

Compact "AI" format

Add X-GraphQl-Profiler-Format: ai for a compact, LLM-friendly payload: the OTLP envelope is dropped, keys are single letters, IDs are truncated to 6 hex chars, and timestamps are microsecond offsets from trace start. Add X-GraphQl-Profiler-Sql: 1 to include the (truncated) raw SQL per query.

The payload carries no legend — the key mapping is a stable contract in AI_FORMAT_MAPPING.md.

Tip: for any query containing nested quotes, put the body in a file and use curl --data @body.json. Inline -d mangles the \" escapes and produces invalid JSON.

Request headers

Header Values Effect
X-GraphQl-Profiler the secret Required. Activates profiling for this request.
X-GraphQl-Profiler-Format ai Compact format. Omit for verbose OTLP.
X-GraphQl-Profiler-Sql 1 Include raw SQL (db.statement) in each db.query span.

Using it with Claude

This module bundles a Claude Code skill (.claude/skills/graphql-profiler/) that turns the profiler into an AI debugging tool. Ask in plain language:

why is this request slow: { products(search: "bag", pageSize: 5) { items { sku price_range { minimum_price { final_price { value } } } } } }

Claude will send the request through the profiler (asking you for the secret and endpoint if it doesn't have them), replay it warm, then analyze the span tree and report:

Enabling the skill

The skill lives at .claude/skills/graphql-profiler/ inside this module. Claude Code discovers skills under a project's .claude/skills/ directory, so either:

Then, in Claude Code, invoke it explicitly with /graphql-profiler or just ask a "why is this slow" question and it triggers automatically.

The skill is two files: SKILL.md (the playbook) and scripts/analyze.py (a zero-dependency Python 3 span analyzer). You can also run the analyzer standalone:


How it works

Four plugins, all no-ops when the profiler is inactive:

Plugin Instruments Emits
ResolverPlugin ResolverInterface::resolve a span per resolver call
BatchResolverPlugin BatchResolverInterface::resolve a span per batch resolve
DbAdapterPlugin Pdo\Mysql::query / multiQuery a db.query span with SQL hash
ResponseInjectorPlugin QueryProcessor::process serializes the tree into extensions.profiling

Spans are held in a per-request SpanCollector; timing comes from a monotonic Clock (hrtime). The DbAdapterPlugin guards against re-entrancy so config lookups it triggers don't recurse.

OTLP encoding notes


⚠️ Security

Do not enable this in production. When active it exposes server internals and SQL statements (db.statement, truncated) in the GraphQL response.

These layers exist to make accidental exposure hard. Treat the secret like a credential and keep mode_allowlist at developer unless you fully understand the exposure.


License

Elastic License 2.0 (ELv2). You may use this module freely, including inside commercial projects. You may not:

For a commercial license granting those rights, contact Ivan Perelekhov <[email protected]>.


All versions of module-graphql-ai-profiler with dependencies

PHP Build Version
Package Version
Requires php Version ~8.1.0||~8.2.0||~8.3.0||~8.4.0
magento/framework Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package prlkhv/module-graphql-ai-profiler contains the following files

Loading the files please wait ...