> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentcat.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sentry

> Connect AgentCat with Sentry for error tracking and monitoring.

## Overview

Integrate AgentCat with Sentry for error tracking and performance monitoring. Events are sent as logs, and optionally as transactions for performance analysis.

## Prerequisites

1. A Sentry project with a DSN (Data Source Name)
2. DSN can be found in your Sentry project settings under "Client Keys (DSN)"

## Configuration

<CodeGroup>
  ```typescript TypeScript theme={null}
  agentcat.track(server, null, {
    exporters: {
      sentry: {
        type: "sentry",
        dsn: "https://key@o123456.ingest.sentry.io/789",
        environment: "production",
        release: "1.0.0",
        enableTracing: true
      }
    }
  })
  ```

  ```python Python theme={null}
  agentcat.track(server, None, agentcat.AgentCatOptions(
    exporters={
      "sentry": {
        "type": "sentry",
        "dsn": "https://key@o123456.ingest.sentry.io/789",
        "environment": "production",
        "release": "1.0.0",
        "enable_tracing": True
      }
    }
  ))
  ```

  ```go Go theme={null}
  mcpcat.Track(s, "", &mcpcat.Options{
      Exporters: map[string]any{
          "sentry": map[string]any{
              "type":          "sentry",
              "dsn":           "https://key@o123456.ingest.sentry.io/789",
              "environment":   "production",
              "release":       "1.0.0",
              "enableTracing": true,
          },
      },
  })
  ```
</CodeGroup>

## Configuration Fields

| Field                              | Type    | Required | Description                                                                                                                                                                 |
| ---------------------------------- | ------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `dsn`                              | string  | Yes      | Sentry Data Source Name from project settings                                                                                                                               |
| `environment`                      | string  | No       | Environment name (default: "production")                                                                                                                                    |
| `release`                          | string  | No       | Release version for tracking deployments                                                                                                                                    |
| `enableTracing` / `enable_tracing` | boolean | No       | Enable performance monitoring. When true, sends transaction events to Sentry's Performance tab in addition to logs, allowing you to track duration and performance metrics. |

## Field Mapping

### Trace and Event IDs

| AgentCat Field | Sentry Field | Format                              |
| -------------- | ------------ | ----------------------------------- |
| `session_id`   | `trace_id`   | SHA256 hash (one trace per session) |
| `event_id`     | `event_id`   | Double SHA256 hash for uniqueness   |

### Log Events

All events are sent as logs with the following structure:

| Field       | Value                                 | Description              |
| ----------- | ------------------------------------- | ------------------------ |
| `timestamp` | Event timestamp                       | Unix timestamp           |
| `level`     | `"error"` or `"info"`                 | Based on `is_error` flag |
| `body`      | `"MCP {event_type}: {resource_name}"` | Formatted message        |

### Transaction Events

<Note>
  Transaction events are only sent when `enableTracing` is set to `true` in the
  configuration.
</Note>

| Field             | Value                              | Description                         |
| ----------------- | ---------------------------------- | ----------------------------------- |
| `transaction`     | `"{event_type} - {resource_name}"` | Transaction name                    |
| `start_timestamp` | Timestamp - duration               | Calculated start time               |
| `end_timestamp`   | Event timestamp                    | When the event completed            |
| `op`              | Event type                         | Operation type (e.g., "tools/call") |
| `status`          | `"internal_error"` or `"ok"`       | Based on `is_error` flag            |

### Tags

Events include the following tags for filtering and grouping:

| AgentCat Field            | Tag Name      | Condition          |
| ------------------------- | ------------- | ------------------ |
| Environment config        | `environment` | Always included    |
| Release config            | `release`     | If configured      |
| `event_type`              | `event_type`  | Always included    |
| `resource_name`           | `resource`    | If available       |
| `server_name`             | `server_name` | If available       |
| `client_name`             | `client_name` | If available       |
| `identify_actor_given_id` | `actor_id`    | If user identified |

### Extra Data

Additional context fields stored with events:

| AgentCat Field        | Extra Field      | Description              |
| --------------------- | ---------------- | ------------------------ |
| `session_id`          | `session_id`     | Session identifier       |
| `project_id`          | `project_id`     | AgentCat project ID      |
| `user_intent`         | `user_intent`    | User's intent            |
| `duration`            | `duration_ms`    | Duration in milliseconds |
| `identify_actor_name` | `actor_name`     | User name                |
| `identify_actor_data` | `actor_data`     | User metadata            |
| `client_version`      | `client_version` | MCP client version       |
| `server_version`      | `server_version` | MCP server version       |

### Error Events

When `is_error` is `true`, Sentry receives:

1. A log event (always sent)
2. A transaction event (if `enableTracing` is true)
3. A separate error event for the Issues tab

This ensures proper error tracking, alerting, and issue management in Sentry.
