-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add context to Sentry Hook #336
Conversation
f9a8435
to
c7fe2f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks for continuing your efforts to get Sentry right.
I am still wondering about the need to pass the request context just everywhere (shouldn't that just be available "globally"?), but I am fine doing so. One idea to reduce the need to pass the context as a parameter could be to attach it as an attribute to the objects that we use...
I was just checking the list of log occurrences and thought some additional might get a context. Precisely, I thought of the following:
-
internal/api/api.go:45
-
internal/api/websocket.go:50
-
internal/api/websocket.go:65
# might be more difficult -
internal/api/websocket.go:71
# might be more difficult -
internal/api/websocket.go:100
-
internal/api/ws/codeocean_reader.go:100
-
internal/api/ws/codeocean_reader.go:113
-
internal/api/ws/codeocean_writer.go:130
-
internal/api/ws/codeocean_writer.go:142
-
internal/api/ws/codeocean_writer.go:146
-
internal/api/ws/codeocean_writer.go:150
-
internal/nomad/api_querier.go:94
-
internal/nomad/api_querier.go:132
-
internal/nomad/api_querier.go:135
-
internal/runner/nomad_runner.go:291
-
internal/runner/nomad_runner.go:293
Sure, not every occurrence of log
is a good indicator, as some tasks happen asynchronously outside a request (such as then handling of Nomad events when a new runner was started). I tried filtering the list above; and some might not be achievable easily (which you might want to skip), but others might work quite easily.
Finally, I was wondering whether we need to extract the transaction ID ourselves. In the Logrus integration you mentioned, their library is doing so (for example, see here). I might work already the current way; I haven't tested it. Once the PR you referenced is merged, we might also want to evaluate switching to their Logrus integration, as this will potentially be maintained by them in the future.
c7fe2f7
to
372b8b4
Compare
Codecov Report
@@ Coverage Diff @@
## main #336 +/- ##
==========================================
+ Coverage 74.31% 74.37% +0.06%
==========================================
Files 37 37
Lines 3290 3306 +16
==========================================
+ Hits 2445 2459 +14
- Misses 680 682 +2
Partials 165 165
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
With this context, tracing information stored in the context can be associated with sentry events/issues.
that represents its lifespan.
45247b8
to
535ee22
Compare
Code Climate has analyzed commit 535ee22 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 68.5% (65% is the threshold). This pull request will bring the total coverage in the repository to 71.1% (0.0% change). View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you! I am really looking forward to having all those nice enhancements in Sentry. (I am still somewhat surprised by the need to pass the context to each location manually, but have accepted that for now.)
When checking Sentry, we still have the issue of two errors being shown (as expected), but at least they now seem to be connected 💪 :
Closes #326
With updating our Sentry Hook, tracing information stored in the passed context can be associated with sentry events/issues.
With this first commit, we added the context just to log statements where an context was available. In many places we do not pass the (request) context. I think it would be a good practice to do so in the future, (not only) because we then could associate Sentry issues with Sentry Traces. We may use this PR for a refactoring into the direction of more context passing.
I noticed, that Sentry developed its own Logrus Hook 4 months ago. We may think about switching to that. At this moment their implementation does not support the tracing association but there is an open PR getsentry/sentry-go#522