amarc-sudo/sentry-enhanced-tracing
Add the package as a local path repository in your main composer.json:
{
"repositories": [
{
"type": "path",
"url": "./packages/sentry-enhanced-tracing"
}
],
"require": {
"amarc-sudo/sentry-enhanced-tracing": "dev-main"
}
}
Then run:
composer require amarc-sudo/sentry-enhanced-tracing:dev-main
Create a symlink to your local package:
# From your project root
ln -s ./packages/sentry-enhanced-tracing vendor/amarc-sudo/sentry-enhanced-tracing
# From your project root
composer config repositories.sentry-enhanced-tracing path ./packages/sentry-enhanced-tracing
composer require amarc-sudo/sentry-enhanced-tracing [@dev](https://github.com/dev)
Add to your config/bundles.php:
<?php
return [
// ... other bundles
AmarcSudo\SentryEnhancedTracing\SentryEnhancedTracingBundle::class => ['all' => true],
];
<?php
// src/Controller/TestSentryController.php
namespace App\Controller;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Cache\CacheInterface;
class TestSentryController extends AbstractController
{
#[Route('/test-sentry', name: 'test_sentry')]
public function testSentry(
EntityManagerInterface $em,
CacheInterface $cache
): JsonResponse {
// This will create database spans under kernel.controller
$users = $em->getRepository(User::class)->findAll();
// This will create cache spans under kernel.controller
$cached = $cache->get('test_key', function() {
return 'cached_value';
});
// This will create template spans under kernel.response
return $this->render('test_sentry.html.twig', [
'users' => $users,
'cached' => $cached,
]);
}
}
{# templates/test_sentry.html.twig #}
<html>
<head>
<title>Sentry Test</title>
</head>
<body>
<h1>Sentry Enhanced Tracing Test</h1>
<p>Users found: {{ users|length }}</p>
<p>Cached value: {{ cached }}</p>
</body>
</html>
# Make a request to see spans in Sentry
curl http://localhost:8000/test-sentry
You should see in your Sentry dashboard:
GET /test-sentry (250ms)
├── Event Listeners Phase: kernel.request (15ms)
│ ├── db.query: SELECT user_id, username FROM users... (8ms)
│ └── cache.get: security:user:context (2ms)
├── Event Listeners Phase: kernel.controller (180ms)
│ ├── db.query: SELECT * FROM users (120ms)
│ ├── cache.get: test_key (5ms)
│ └── cache.set: test_key (3ms)
└── Event Listeners Phase: kernel.response (45ms)
├── twig.render: test_sentry.html.twig (40ms)
└── cache.set: twig:template:hash (2ms)
php bin/console cache:clear
# Check if services are registered
php bin/console debug:container sentry
php bin/console debug:container AmarcSudo\\SentryEnhancedTracing
# Check listener priorities
php bin/console debug:event-dispatcher kernel.request
php bin/console debug:event-dispatcher kernel.response
# config/packages/dev/sentry.yaml
sentry:
options:
debug: true
traces_sample_rate: 1.0
tail -f var/log/dev.log | grep -i sentry
php bin/console debug:config sentry
php bin/console debug:config sentry_enhanced_tracing
// In your test controller
throw new \Exception('Test Sentry exception handling');
# Use Apache Bench to test performance impact
ab -n 100 -c 10 http://localhost:8000/test-sentry
# Check memory usage
php bin/console debug:container --show-private | grep -i memory
bundles.php registrationcomposer.jsontraces_sample_rate > 0debug:event-dispatcherFor faster development, use:
# Watch files for changes
php bin/console cache:clear && php -S localhost:8000 -t public/
Make changes to the package and refresh to see updates immediately.
How can I help you explore Laravel packages today?