phptek / silverstripe-sentry

Flexible Sentry compatible bug aggregation client for Silverstripe applications.
BSD 3-Clause "New" or "Revised" License
12 stars 22 forks source link

Performance Monitoring #95

Open samandeggs opened 5 months ago

samandeggs commented 5 months ago

Hi @phptek as per your previous comment on #93 here is my current status of work, it's not a lot, but it does fire them off. You obviously need your DSN set, and for this implementation you need to set SENTRY_TRACES_SAMPLE_RATE as an .env variable.

1 will mean everything is logged, which is useful for testing, and Sentry recommend using 0.20 for production, so only 1 in 5 requests are actually logged. You could reduce this if needing an even smaller sample size, but this appeared to be working as expected in my basic testing. This information will need to be added to the README.md which I have not done yet.

Feel free to contribute, or offer advice here for this to be rounded out. The last actual feature needs to be the management of the Transaction's life-cycle, where in SentryAdaptor.php:192's function startTransaction() you will see that it starts and ends it straight away. It has to be started at the beginning of the request, and ended at the closing of it for the timings to actually make sense, or as something similar that is as close to the metal that is reasonable. I'm not quite sure how to hook into this yet - at least in an elegant way. My initial thought was to include an extension of the request handler itself, but that might be the wrong direction.

It is also likely that there is some missing data when it comes to stack tracing the performance monitoring, but presumably when it's plugged into the life-cycle properly it will have a lot more context available to it as well.