PHPackages                             baraja-core/tracy-sentry-bridge - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. baraja-core/tracy-sentry-bridge

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

baraja-core/tracy-sentry-bridge
===============================

The package provides an easy connection between Tracy and Sentry.

v1.0.1(4y ago)225.7k1PHPPHP ^8.0CI failing

Since May 17Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/baraja-core/tracy-sentry-bridge)[ Packagist](https://packagist.org/packages/baraja-core/tracy-sentry-bridge)[ Docs](https://github.com/baraja-core/tracy-sentry-bridge)[ RSS](/packages/baraja-core-tracy-sentry-bridge/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (9)Versions (5)Used By (1)

Tracy and Sentry Bridge
=======================

[](#tracy-and-sentry-bridge)

The package provides an easy connection between [Tracy](https://tracy.nette.org/) debugger and [Sentry](https://sentry.io/) error tracking service. It allows you to automatically forward all Tracy log entries to Sentry while preserving the original Tracy logging functionality.

💡 Key Principles
----------------

[](#bulb-key-principles)

- **Seamless Integration**: Works as a drop-in replacement for Tracy's default logger
- **Dual Logging**: All logs are sent to both the original Tracy logger and Sentry simultaneously
- **No Data Loss**: Original Tracy logs remain intact regardless of Sentry status
- **Automatic Severity Mapping**: Tracy log levels are automatically converted to appropriate Sentry severity levels
- **Fault Tolerant**: If Sentry logging fails, errors are captured by the fallback logger
- **Zero Configuration**: Simple one-line registration in your bootstrap

🏗️ Architecture
---------------

[](#building_construction-architecture)

The package implements Tracy's `ILogger` interface and uses the decorator pattern to wrap the original Tracy logger. This ensures that all existing logging functionality continues to work while adding Sentry integration on top.

```
┌─────────────────────────────────────────────────────────────────┐
│                     Your Application                            │
│                           │                                     │
│                     log($value, $level)                         │
│                           ▼                                     │
│  ┌─────────────────────────────────────────────────────────┐   │
│  │                   SentryLogger                           │   │
│  │                  (ILogger impl.)                         │   │
│  │                                                          │   │
│  │   ┌──────────────────────────────────────────────────┐  │   │
│  │   │                    log()                          │  │   │
│  │   │                      │                            │  │   │
│  │   │          ┌───────────┴───────────┐                │  │   │
│  │   │          ▼                       ▼                │  │   │
│  │   │   ┌─────────────┐       ┌───────────────┐         │  │   │
│  │   │   │   Fallback  │       │  logToSentry  │         │  │   │
│  │   │   │   Logger    │       │               │         │  │   │
│  │   │   │  (original) │       │ ┌───────────┐ │         │  │   │
│  │   │   └──────┬──────┘       │ │  Severity │ │         │  │   │
│  │   │          │              │ │  Mapping  │ │         │  │   │
│  │   │          ▼              │ └─────┬─────┘ │         │  │   │
│  │   │   ┌─────────────┐       │       ▼       │         │  │   │
│  │   │   │ Tracy Logs  │       │ ┌───────────┐ │         │  │   │
│  │   │   │  (files)    │       │ │  Sentry   │ │         │  │   │
│  │   │   └─────────────┘       │ │   API     │ │         │  │   │
│  │   │                         │ └───────────┘ │         │  │   │
│  │   └──────────────────────────────────────────────────┘  │   │
│  └─────────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────────┘

```

⚙️ Main Components
------------------

[](#gear-main-components)

### SentryLogger

[](#sentrylogger)

The core class that implements Tracy's `ILogger` interface. It acts as a bridge between Tracy and Sentry.

**Key Features:**

FeatureDescription`register()`Static method to automatically register the logger with Tracy`log()`Main logging method that forwards to both Sentry and fallback loggerSeverity MappingAutomatic conversion of Tracy levels to Sentry severityException HandlingProper handling of both `Throwable` objects and string messages### Severity Level Mapping

[](#severity-level-mapping)

The package automatically maps Tracy log levels to Sentry severity:

Tracy LevelSentry Severity`DEBUG``debug``INFO``info``WARNING``warning``ERROR``error``EXCEPTION``error``CRITICAL``fatal`Any unrecognized level defaults to `fatal` severity.

📦 Installation
--------------

[](#package-installation)

It's best to use [Composer](https://getcomposer.org) for installation, and you can also find the package on [Packagist](https://packagist.org/packages/baraja-core/tracy-sentry-bridge) and [GitHub](https://github.com/baraja-core/tracy-sentry-bridge).

To install, simply use the command:

```
$ composer require baraja-core/tracy-sentry-bridge
```

You can use the package manually by creating an instance of the internal classes, or register a DIC extension to link the services directly to the Nette Framework.

### Requirements

[](#requirements)

- PHP 8.0 or higher
- Tracy ^2.8 or 3.0-dev
- Sentry SDK ^3.1

🚀 Basic Usage
-------------

[](#rocket-basic-usage)

### Quick Start with Nette Framework

[](#quick-start-with-nette-framework)

In your project's `Bootstrap.php` file, initialize Sentry first and then register the bridge:

```
use Baraja\TracySentryBridge\SentryLogger;

public static function boot(): Configurator
{
    $configurator = new Configurator;

    // Initialize Sentry first
    if (\function_exists('\Sentry\init')) {
        \Sentry\init([
            'dsn' => 'https://your-sentry-dsn@sentry.io/project-id',
            'attach_stacktrace' => true,
        ]);
    }

    // Register the Tracy-Sentry bridge
    SentryLogger::register();

    return $configurator;
}
```

### Standalone Usage

[](#standalone-usage)

If you're not using Nette Framework, you can still use the package with standalone Tracy:

```
use Tracy\Debugger;
use Baraja\TracySentryBridge\SentryLogger;

// Enable Tracy
Debugger::enable();

// Initialize Sentry
\Sentry\init([
    'dsn' => 'https://your-sentry-dsn@sentry.io/project-id',
]);

// Register the bridge
SentryLogger::register();

// Now all Tracy logs will be sent to Sentry
Debugger::log('Something happened', Debugger::WARNING);
```

### Manual Instantiation

[](#manual-instantiation)

For more control, you can manually create the logger instance:

```
use Tracy\Debugger;
use Baraja\TracySentryBridge\SentryLogger;

$originalLogger = Debugger::getLogger();
$sentryLogger = new SentryLogger($originalLogger);
Debugger::setLogger($sentryLogger);
```

🛡️ Error Handling
-----------------

[](#shield-error-handling)

The package is designed to be fault-tolerant:

1. **Primary logging always works**: The fallback (original Tracy) logger is called first, ensuring your local logs are always written.
2. **Sentry failures are captured**: If the Sentry logging fails for any reason, the exception is logged to the fallback logger with `CRITICAL` level.
3. **Graceful degradation**: If Sentry SDK is not properly loaded, the package will output a warning message but won't crash your application.

```
// Example of how errors are handled internally
public function log(mixed $value, mixed $level = self::INFO): void
{
    // Always log to fallback first (guaranteed to work)
    $this->fallback->log($value, $level);

    try {
        // Then attempt Sentry logging
        $this->logToSentry($value, $level);
    } catch (\Throwable $e) {
        // If Sentry fails, log the error locally
        $this->fallback->log($e, ILogger::CRITICAL);
    }
}
```

⚡ Advanced Configuration
------------------------

[](#zap-advanced-configuration)

### Sentry Configuration Options

[](#sentry-configuration-options)

When initializing Sentry, you can customize various options:

```
\Sentry\init([
    'dsn' => 'https://your-sentry-dsn@sentry.io/project-id',
    'attach_stacktrace' => true,
    'environment' => 'production',
    'release' => 'my-app@1.0.0',
    'sample_rate' => 1.0,
    'traces_sample_rate' => 0.2,
    'send_default_pii' => false,
]);
```

### Conditional Registration

[](#conditional-registration)

You might want to only enable Sentry logging in production:

```
if (getenv('APP_ENV') === 'production' && \function_exists('\Sentry\init')) {
    \Sentry\init(['dsn' => getenv('SENTRY_DSN')]);
    SentryLogger::register();
}
```

### Logging Different Types

[](#logging-different-types)

The bridge handles different value types appropriately:

```
// Exceptions are captured with full stack trace
try {
    throw new \RuntimeException('Something went wrong');
} catch (\Throwable $e) {
    Debugger::log($e, Debugger::EXCEPTION);
}

// String messages are captured as messages
Debugger::log('User login failed', Debugger::WARNING);

// Arrays and objects are serialized
Debugger::log(['user_id' => 123, 'action' => 'failed_login'], Debugger::INFO);
```

🧪 Development &amp; Testing
---------------------------

[](#test_tube-development--testing)

The package uses PHPStan for static analysis:

```
$ composer phpstan
```

This runs PHPStan at level 8 with strict rules and Nette-specific extensions.

👥 Author
--------

[](#busts_in_silhouette-author)

**Jan Barasek** -

🤝 Contributing
--------------

[](#handshake-contributing)

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

📄 License
---------

[](#page_facing_up-license)

`baraja-core/tracy-sentry-bridge` is licensed under the MIT license. See the [LICENSE](https://github.com/baraja-core/tracy-sentry-bridge/blob/master/LICENSE) file for more details.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance52

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~328 days

Total

2

Last Release

1491d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3382204?v=4)[baraja](/maintainers/baraja)[@baraja](https://github.com/baraja)

---

Top Contributors

[![janbarasek](https://avatars.githubusercontent.com/u/4738758?v=4)](https://github.com/janbarasek "janbarasek (13 commits)")

---

Tags

errorlogmonitoringsentrysentry-bridgetracy

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/baraja-core-tracy-sentry-bridge/health.svg)

```
[![Health](https://phpackages.com/badges/baraja-core-tracy-sentry-bridge/health.svg)](https://phpackages.com/packages/baraja-core-tracy-sentry-bridge)
```

###  Alternatives

[notamedia/yii2-sentry

Yii2 logger for Sentry

1272.0M2](/packages/notamedia-yii2-sentry)[kdyby/monolog

Integration of Monolog into Nette Framework

33684.0k10](/packages/kdyby-monolog)[contributte/newrelic

NewRelic PHP agent integration for Nette Framework

19822.4k](/packages/contributte-newrelic)[mangoweb/monolog-tracy-handler

Integrates Tracy into Monolog, supports uploading Tracy bluescreens to AWS S3

20327.5k1](/packages/mangoweb-monolog-tracy-handler)[phptek/sentry

Sentry.io integration for SilverStripe. Binds Sentry.io to SilverStripe's error &amp; exception handling subsystem.

15203.5k3](/packages/phptek-sentry)[helhum/sentry-typo3

Sentry Integration for TYPO3

1833.5k](/packages/helhum-sentry-typo3)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
