mirror of
https://github.com/getsentry/sentry-for-ai.git
synced 2026-09-14 14:28:22 +08:00
64dfeaa1f1
These per-SDK skills, plus a handful of setup/workflow skills, are superseded by the sentry-instrument skill and the references/sdks/ trees. Move them under skills-legacy/ so they are excluded from the plugin build and skipped by the drift automation, while skills.sentry.dev can still serve them as a fallback for existing URL consumers. Moves 26 skills: the 19 per-SDK skills plus sentry-sdk-skill-creator, sentry-fix-issues, the three sentry-span-streaming-* skills, sentry-instrument-logging, and sentry-instrumentation-guide. Regenerates SKILL_TREE.md and repaths the moved entries in CODEOWNERS. sentry-sdk is intentionally left in place; its removal is handled in a separate PR.
3.2 KiB
3.2 KiB
Profiling — Sentry PHP SDK
Requires the Excimer PHP extension (Linux/macOS only — Windows not supported)
Prerequisites
Excimer extension must be installed:
# Linux (recommended)
apt-get install php-excimer
# PECL
pecl install excimer
# Enable (if needed)
phpenmod -s fpm excimer
Excimer requires PHP 7.2+ and does not support Windows.
Version Requirements
| Framework | Min SDK Version |
|---|---|
| PHP (base) | sentry/sentry ≥ 3.15.0 |
| Laravel | sentry/sentry-laravel ≥ 3.3.0 |
| Symfony | sentry/sentry-symfony ≥ 4.7.0 |
Configuration
Profiling requires traces_sample_rate > 0. profiles_sample_rate is relative to traces_sample_rate.
PHP (base SDK)
\Sentry\init([
'dsn' => '___PUBLIC_DSN___',
'traces_sample_rate' => 1.0,
'profiles_sample_rate' => 1.0, // relative to traces_sample_rate
]);
Laravel (config/sentry.php)
return [
'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')),
'traces_sample_rate' => env('SENTRY_TRACES_SAMPLE_RATE') === null ? null : (float) env('SENTRY_TRACES_SAMPLE_RATE'),
'profiles_sample_rate' => env('SENTRY_PROFILES_SAMPLE_RATE') === null ? null : (float) env('SENTRY_PROFILES_SAMPLE_RATE'),
];
.env:
SENTRY_TRACES_SAMPLE_RATE=1.0
SENTRY_PROFILES_SAMPLE_RATE=1.0
Symfony (config/packages/sentry.yaml)
sentry:
options:
traces_sample_rate: 1.0
profiles_sample_rate: 1.0
How profiles_sample_rate Works
profiles_sample_rate is a fraction of already-sampled transactions, not of all requests:
Effective profiling rate = traces_sample_rate × profiles_sample_rate
Examples:
traces_sample_rate: 1.0, profiles_sample_rate: 1.0 → 100% of requests profiled
traces_sample_rate: 0.5, profiles_sample_rate: 0.5 → 25% of requests profiled
traces_sample_rate: 0.1, profiles_sample_rate: 1.0 → 10% of requests profiled
Reducing Latency Impact
Profiling data is sent to Sentry after generating the response, not before:
- Laravel (FastCGI): Uses terminable middleware — data sent after response is dispatched
- Symfony (FastCGI): Uses
kernel.terminateevent — same behavior - Non-FastCGI servers: Use a local Relay instance:
PHP App → local Relay (127.0.0.1) → Sentry Cloud
Best Practices
- Start with
profiles_sample_rate: 1.0in development to verify setup - In production, reduce
traces_sample_rate(e.g.,0.1) — profiling follows automatically - Profiling has no meaningful overhead on Linux with Excimer; Relay is only needed to avoid latency on non-FastCGI servers
- Profiles are capped at 30 seconds per transaction
Troubleshooting
| Issue | Solution |
|---|---|
| No profiles appearing | Verify Excimer is installed (php -m | grep excimer) and traces_sample_rate > 0 |
profiles_sample_rate has no effect |
Check SDK version meets minimum requirement |
| Windows deployment | Profiling is not supported on Windows — use Linux or macOS |
| High latency from profiling | Use FastCGI (terminable middleware) or deploy a local Relay instance |