Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ TRAP_TCP_PORTS=9912,8000 vendor/bin/trap
| `TRAP_XDEBUG_TRACE_MAX_SIZE` | `256M` | Uncompressed bytes read of an Xdebug trace; a longer one is cut there. |
| `TRAP_XDEBUG_TRACE_KEEP` | `20` | Xdebug traces kept on disk; a new one deletes the oldest with its event. |
| `TRAP_XDEBUG_*` | | Settings of the [Xdebug debugger](xdebug.md#settings): port, IDE address, mode, eval, agent control, idle timeout. |
| `TRAP_TRACES_MAX_SPANS` | `10000` | Maximum number of kept [OpenTelemetry](opentelemetry.md#memory-limits) spans. |
| `TRAP_TRACES_TTL` | `600` | Seconds an OpenTelemetry trace is kept after its last received span. |
| `TRAP_TELEMETRY_MAX_SPANS` | `10000` | Maximum number of transactions and spans the [Sentry pages](web-ui.md#sentry-pages) of the web UI keep. |
| `TRAP_TRACES_MAX_SPANS` | `10000` | Maximum number of [OpenTelemetry](opentelemetry.md#memory-limits) spans the console keeps to print a trace as a tree. |
| `TRAP_TRACES_TTL` | `600` | Seconds the console keeps an OpenTelemetry trace after its last received span. |
| `TRAP_TELEMETRY_MAX_SPANS` | `10000` | Maximum number of transactions and spans of the traces the [Sentry pages](web-ui.md#sentry-pages) of the web UI and the [MCP tools](mcp.md#traces) read. |
| `TRAP_TELEMETRY_MAX_LOGS` | `5000` | Maximum number of log records the Sentry pages of the web UI keep. |
| `TRAP_TELEMETRY_MAX_METRICS` | `5000` | Maximum number of metric values the Sentry pages of the web UI keep. |

Expand Down
62 changes: 38 additions & 24 deletions docs/mcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Other clients take the same URL with the `http` (Streamable HTTP) transport type

## Tools

The tools read the events Trap has caught, the [traces](#traces) it has received and the call trees of
[Xdebug traces](#xdebug-traces). The events are the ones the
[web UI](web-ui.md) shows, kept with `--mcp` alone too. An event deleted in the UI is gone for the agent. An event
The tools read the events Trap has caught, the Sentry and OpenTelemetry [traces](#traces) it has received, and the
call trees of [Xdebug traces](#xdebug-traces). The events are the ones the [web UI](web-ui.md) shows, kept with
`--mcp` alone too. An event deleted in the UI is gone for the agent. An event
the agent deletes is gone from the UI on its next load; a page already open keeps showing it.

| Tool | Arguments | Result |
Expand Down Expand Up @@ -222,14 +222,16 @@ prints it:
The body and the other sections are shown as sent. The query is one line of up to 300 characters; the request is
at most 16 KB with its body, and the headers past that are left out and counted.
- The contexts, such as `runtime`, `os` and `trace` with its IDs, one line each; the latest breadcrumbs, oldest first;
the extra data; the spans of a transaction with their durations.
the extra data.
- An envelope of several items shows each of them under `--- Item 2 of 3: attachment ---`: an attachment by its
name, type and size; an item that is not an event, such as `session`, `client_report` or `check_in`, by its
fields in one line. The web UI shows the first item only. A search looks through the first 64 KB of the whole
envelope, so the details of later items may not be found.
name, type and size; a transaction, sent with the error, by its name, duration, number of spans (itself included)
and trace ID, to read with [`get_trace`](#traces), or as an event when it has no trace ID; an item that is not an
event, such as `session`, `client_report` or `check_in`, by its fields in one line. The web UI shows the first
item only. A search looks through the first 64 KB of the whole envelope, so the details of later items may not be
found.

The sections come in this order: the metadata, the exception chain, the request, the contexts, the breadcrumbs, the
extra data and the spans. A [search](#filters) looks through the first 64 KB of the text, so the causes that would
extra data. A [search](#filters) looks through the first 64 KB of the text, so the causes that would
take the chain past 32 KB are left out and counted; past less than 32 KB when the metadata and the request are
large, so that the contexts and the breadcrumbs start within the 64 KB. A thrown exception larger than that is shown
without the code and variables of its frames, and then with fewer frame lines; so is the stack trace of an event
Expand All @@ -247,7 +249,6 @@ Bounds; what is left out is counted, as `… 5 more …`:
| Request headers | 15 in 16 KB of the request with its body |
| Breadcrumbs | the last 10 |
| Tags, user fields, contexts, extra entries | 20 |
| Spans | 20 |
| Items of an envelope | 20 |
| Characters of an exception value, message, body | 2 000 |
| Characters of another value | 300; of a code line, 200 |
Expand Down Expand Up @@ -290,29 +291,42 @@ Contexts:

### Traces

[OpenTelemetry traces](opentelemetry.md) are not events: the tools read the spans Trap keeps to join the spans of one
trace sent in separate requests, with `--mcp` alone too. The limits of that store,
[`TRAP_TRACES_MAX_SPANS` and `TRAP_TRACES_TTL`](opentelemetry.md#memory-limits), apply.
Traces are not events: [Sentry transactions and spans](sentry.md#what-an-envelope-gives) and
[OpenTelemetry spans](opentelemetry.md) go to the trace store the [Sentry pages](web-ui.md#sentry-pages) of the web
UI show, and the tools read it, with `--mcp` alone too. Its limit,
[`TRAP_TELEMETRY_MAX_SPANS`](web-ui.md#sentry-pages), applies: above it the least recently updated traces are
dropped. Clearing the Sentry pages of the web UI drops their traces for the tools too.

| Tool | Arguments | Result |
| ------------- | --------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `list_traces` | `since` (cursor), `limit`, `errors_only`, `from`, `to`, `service`, `name`, `min_duration_ms`, `search`, `regex` | `traces`: `id`, `name`, `service`, `spans`, `duration_ms`, `error`, `updated` each; `cursor`; `has_more` |
| `get_trace` | `id`, `max_length` | The trace as plain text: a header line, then the tree of all its spans as the console prints it |
| Tool | Arguments | Result |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `list_traces` | `since` (cursor), `limit`, `project`, `source`, `errors_only`, `from`, `to`, `service`, `name`, `min_duration_ms`, `search`, `regex` | `traces`: `id`, `name`, `service`, `services`, `sources`, `projects`, `spans`, `duration_ms`, `error`, `updated` each; `cursor`; `has_more` |
| `get_trace` | `id`, `max_length` | The trace as plain text: a header line, then the tree of all its spans as the console prints OpenTelemetry traces |

- `list_traces` returns the traces updated after `since`, least recently updated first, at most `limit` of them
(20 by default, 100 at most). A trace is updated by every span that arrives for it, and an updated trace is listed
again. When `has_more` is true, call again with the returned `cursor` to get the rest.
- `name` is of the root span; while it has not arrived, of the earliest span whose parent is missing.
`service` is the `service.name` of the resource of that span; when that resource has none, of another span.
- `errors_only` lists only the traces with a span of the error status.
(20 by default, 100 at most). A trace is updated by every span or transaction that arrives for it, and an updated
trace is listed again. When `has_more` is true, call again with the returned `cursor` to get the rest.
- `name` is of the root transaction: a Sentry transaction or the entry span of a service, the one without a parent
first. While no transaction has arrived, it is of the earliest span whose parent is missing. `service` is the
service of that root; when it has none, of another span. `services`, `sources` (`sentry`, `otel`) and `projects`
list those of every part of the trace: a distributed trace may cross several.
- `spans` counts the spans and the transactions. `error` is true when one of them failed: an OpenTelemetry span of
the error status, a Sentry one of `internal_error`, `unknown_error` or `error`.
- `project` is one project or a list, as in [the event filter](#filters): only the part of each trace sent to those
projects is listed and summed up. `source` is `sentry` or `otel`: only the traces with a part from it.
- `errors_only` lists only the traces with a failed span or transaction.
- `from` and `to` take the times of [the event filter](#filters) and match the time of the last update.
- `service` is one service or a list, and `name` a name; both match in any case, with `*` for any characters.
`service` matches any service of the trace; `*` takes a trace without services too.
- `min_duration_ms` lists only the traces that last that long or longer.
- `search` and `regex` match as in [the event filter](#filters), over the spans: their names, status messages,
attributes, and events, such as an exception with its message, and over the attributes of their resources,
one `key=value` line per attribute.
- `search` and `regex` match as in [the event filter](#filters), over the spans: their names (a Sentry span is named
`op: description`), status messages, attributes, and events, such as an exception with its message, and over the
attributes of OpenTelemetry resources, one `key=value` line per attribute.
- Slow traces of the last hour: `{"from": "1h", "min_duration_ms": 500}`; failed checkouts:
`{"errors_only": true, "name": "POST /checkout*"}`.
- `get_trace` takes the ID of `list_traces`, or the trace ID of a Sentry error from its `trace` context. The header
line holds the number of spans, the services, sources and projects, whether a span failed, and the time of the
last update. A Sentry span shows its op and description as its name, a kind read from its op (`http.server` is
`SERVER`, `http.client` `CLIENT`, `queue.publish` `PRODUCER`, `queue.process` `CONSUMER`, others `INTERNAL`), its `data` as attributes and a failure status as `ERROR`.
- `get_trace` cuts a text longer than `max_length` characters, 50 000 by default, and says so.

### Profiles
Expand Down
10 changes: 6 additions & 4 deletions docs/opentelemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ The Phar, the standalone binary and the Docker image do not include them, so the
## Memory limits

Spans of one trace often arrive in separate requests (a simple span processor exports each span on its own),
so Trap keeps received spans in memory to print them together. With [`--mcp`](mcp.md#traces) the MCP server
keeps a copy of its own for the agents. Each copy is limited by:
so the console keeps the spans it has printed in memory to print a trace as a tree. That buffer is limited by:

- `TRAP_TRACES_MAX_SPANS` - the maximum number of kept spans; the least recently updated traces are dropped
above it, and a single trace above it keeps only its most recent spans (default: `10000`)
Expand All @@ -59,7 +58,9 @@ keeps a copy of its own for the agents. Each copy is limited by:
The same limits can be set in [`trap.xml`](configuration.md#trapxml): `<traces maxSpans="10000" ttl="600"/>`.
Non-positive or non-numeric values fall back to the defaults.

The web UI keeps its own traces, logs and metrics, see [web UI limits](web-ui.md#sentry-pages).
The web UI and the [MCP server](mcp.md#traces) read one store of traces, logs and metrics, the one of the Sentry
pages, with the [`TRAP_TELEMETRY_*` limits](web-ui.md#sentry-pages). It keeps a trace until the limit pushes it out,
however long ago its last span came.

## Saving to a file

Expand All @@ -68,7 +69,8 @@ With the [`file` sender](senders.md#file), each export request is saved as one J

## Notes

- Traces are given to AI agents by the [MCP server](mcp.md#traces); logs and metrics are not.
- Traces are given to AI agents by the [MCP server](mcp.md#traces), along with Sentry traces; logs and metrics
are not.
- Exporters running in a browser are not supported: Trap does not answer CORS preflight requests.
- One export request may carry up to 10 MB (after decompression) and up to 10 000 spans, log records or metric
data points; a bigger one gets `413`. SDK batch processors export 512 spans at a time by default.
Expand Down
13 changes: 10 additions & 3 deletions docs/sentry.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,21 @@ With [`--mcp`](mcp.md#sentry-events), AI agents read the events with their excep
| Envelope item | Becomes |
|---------------------------------------|-----------------------------------------------------------------------------|
| `event`, `feedback` | a `sentry` event: the console, the event feed of the web UI, the MCP server |
| `transaction` | a `sentry` event, and a trace on the Traces page of the web UI |
| `transaction` | a trace: the Traces page of the web UI, the MCP trace tools |
| `transaction` without a trace ID | a `sentry` event, as `event` is: no trace can hold it |
| `span`, `spans` (Span v2) | spans of a trace; a segment span is the transaction of its service |
| `log` | log records on the Logs page of the web UI |
| `trace_metric` | metric values on the Metrics page of the web UI |
| sessions, client reports, attachments | nothing |

An envelope of only logs, metrics, spans or SDK bookkeeping makes no event. The [web UI](web-ui.md#sentry-pages)
shows the traces, logs and metrics only while it runs.
The event feed holds the errors. A transaction is a trace, not an event, also when an older SDK sends it to
`…/store/`: the console prints one line for it, with its name, duration, number of spans (the transaction included),
the failed ones and the trace ID, and AI agents read it with [`list_traces` and `get_trace`](mcp.md#traces). Spans
sent without a transaction get the same line, named after their root span. An envelope of an error and the
transaction of its request gives the error event and the trace. A `/store` payload with an exception is an error,
whatever its type. A transaction without a trace ID fits no trace and stays a `sentry` event; the console prints
one line for it too. An envelope of only transactions, logs, metrics, spans or SDK bookkeeping makes no event. Trap
keeps the traces, logs and metrics while the [web UI](web-ui.md#sentry-pages) or the [MCP server](mcp.md) runs.

The `X-Buggregator-Project` header puts the event and the data of the request into that project of the web UI;
without it they land in `default`.
Expand Down
10 changes: 5 additions & 5 deletions docs/web-ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ The Sentry section has a page for each kind of data:
that service sends its data to Trap too.
- Logs and Metrics: Sentry `log` and `trace_metric` items, OTLP logs and metrics.

Traces, logs and metrics make no events in the feed. Trap keeps them in memory while the UI or the
[MCP server](mcp.md) runs, and the UI asks for them by project and period. "Clear all" in the Sentry section
deletes them with the Sentry events.
Traces, logs and metrics make no events in the feed: a Sentry transaction is a trace, and the feed holds the errors.
Trap keeps them in memory while the UI or the [MCP server](mcp.md) runs, and the UI asks for them by project and
period. The MCP tools [`list_traces` and `get_trace`](mcp.md#traces) read the same traces. "Clear all" in the
Sentry section deletes them with the Sentry events.

Memory is bounded by these limits; values below 1 fall back to the defaults:

Expand All @@ -87,5 +88,4 @@ Memory is bounded by these limits; values below 1 fall back to the defaults:
| `TRAP_TELEMETRY_MAX_METRICS` | `/trap/telemetry/@maxMetrics`| `5000` | the oldest metric values are dropped |

`maxSpans` counts transactions and spans together; a single trace above it keeps its most recent 90%.
These limits are apart from the [OpenTelemetry limits](opentelemetry.md#memory-limits) of the console and the
MCP server.
These limits are apart from the [OpenTelemetry limits](opentelemetry.md#memory-limits) of the console.
Loading
Loading