-
-
Notifications
You must be signed in to change notification settings - Fork 198
feat: Add Tracing #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Tracing #358
Conversation
Record sql queries as spans
|
I was just reading about this today on Sentry’s docs and was hoping PHP and Laravel would be added as the docs just have Python and JavaScript. This would be fantastic! Would the terminable option be useful for this? https://laravel.com/docs/7.x/middleware#terminable-middleware |
Instrument view renders
|
@dmyers Yes PHP/Laravel will be supported next :) That's a good point, maybe we should finish the transaction in I was also trying to measure/instrument the 217ms gap but I am not sure what's causing this. It's not the middleware, I guess the ServiceProviders but not sure how to measure them. |
Move all renders as a child
Use fromTraceparent function to start a trace
|
Just tried this out. Seems to be working when I'm browsing our app, however, I'm getting the following error within PHPUnit tests. (50% of all tests are failing) I would also I would love to have an option to silence any error a just report them if the tracer is failing. Even if it's failing in the terminate middleware this would result in the complete request failing if using Laravel Vapor, as the terminate is called before the response is returned. |
|
@markstaun Thanks for the feedback, we'll fix this. |
|
Sounds great, really looking forward to deploying this to production! |
|
if you aren't seeing alternatively, Sentry could check if the view engine resolver has already been resolved in other than that, it works quite well for us, providing insight into our slowest rendering views 👍 |
|
@Josh-G good one thanks for letting us know, could you show me a package that resolves the view engine so I can test with working around that? Having a hard time coming up with one. @markstaun I believe the issue in testing should be fixed! |
@stayallive One of the two service providers in |
|
@Josh-G, thanks, I'll figure it out from here, I'll let you know once it's fixed 👍 |
|
Actually @Josh-G, I think I already got it, let me know how this works for you! |
|
@stayallive Perfect, thanks! Have tested and no longer requires a specific service provider order :) works out of the box |
|
Anything special that is needed to get this to work for WordPress? |
|
This code is specific to Laravel and will not work for any other platform. The PHP SDK is currently in the works to get all tracing related code integrated (getsentry/sentry-php#1031) and once that is stable other integrations could start implementing it. To instrument WordPress the WordPress integration will need to write a similar kind of code hooking into parts of WordPress to get some meaningful tracing information. |
|
@stayallive Should I start a ticket for that or is official WordPress PHP Tracing/Performance support not expected? |
|
@archon810 you are ofcourse free to open a ticket to track the interest but the WordPress integration is technically not an official integration while PHP, Laravel (and Symfony) are so it might take a bit longer. |
|
Just tested this branch again with our codebase, but some of our tests are failing. And here is the actual exception that is catched in the EventFactory.php:114. |
|
@markstaun I fixed this in the latest commit in PHP repo getsentry/sentry-php@67f15ce |
|
Thanks, I can confirm that it's working and all our tests are now passing 👌 |
* feat: Add Tracing (#358) * feat: Add Tracing Middleware Record sql queries as spans * feat: Auto prepend middleware Instrument view renders * ref: Change code comments * ref: Use terminate to send transaction * Rename view engine decorator * Improve transaction context name/description * Prevent crashes when using missing defines * Do not remove all leading `/` keep 1 * Add fallback autoload + bootstrap span * Set the transaction name from the event handler * Cleanup query span * Prevent errors on Laravel 5.3 and below * CS * feat: Use correct route and add data * ref: Add name * fix: Route naming * feat: Start transaction in serviceProvider Move all renders as a child * ref: Rename to view.render * ref: Move back to starting transaction in middleware Use fromTraceparent function to start a trace * ref: Small refactor * feat: Update composer.json * ref: Add traces_sample_rate * Refactor active span retrieval * Guard against the active span not being set * Docblock updates * Correctly return rendered view without span * Move tracing related code to the Tracing namespace * Improve the route name detection order * Do not use route names ending with a `.` * Fix not wrapping the view enines when resolver is already resolved * feat: Rework code to use transaction on the hub Co-authored-by: Alex Bouma <[email protected]> * meta: Bump version 2.0.0-beta.0 * meta: Change version 2.0.0-beta1 * meta: Define beta version 3.0.0-beta1 for php sdk * meta: Changelog * Update CHANGELOG.md Co-authored-by: Alex Bouma <[email protected]> * feat: Add publish command (#379) * feat: Add publish command * fix: Typos * feat: Counterpart to PHP polish apm pr (#384) * meta: Prepare 2.x * fix: Travis * ref: Fix tests * fix: tests * ref: Master Co-authored-by: Alex Bouma <[email protected]>
Installation
Read
https://docs.sentry.io/performance-monitoring/performance/
to understand the concept behind Tracing/Performance in Sentry.
Make sure you have following in you
composer.jsonAfter that run
composer update.Make sure the installation of
sentry/sentry,sentry/sdkandsentry/sentry-laravelin the output looks something like this:The important part is that both
sentry/sentryandsentry/sdkare3.xwheresentry/sentry-laravelisdev-performance/beta.After that add
'traces_sample_rate' => 1.0,to the file inconfig/sentry.php.Note that the value should be larger than
0.0and smaller or equal than1.0(to send everything).More info can be found here: https://docs.sentry.io/performance-monitoring/getting-started/
Connecting your frontend
To setup tracing for your Vue frontend, follow: https://docs.sentry.io/performance-monitoring/getting-started/?platform=vue
An additional step you should take is, add this to your blade template rendering the
<head>tag{!! Sentry\Laravel\Integration::sentryTracingMeta() !!}This adds a meta tag similar to
<meta name="sentry-trace" content="ae02a316231d490c870b14f27aba8d29-c4a72ffd39444c84-1"/>to your header and tells the frontend code to pick up the trace.Known Issues
Papertrail
/users/{id}instead of/users/1sentry.breadcrumbs.sql_queriesoption?This works together with getsentry/sentry-php#1031
Resulting in: