Skip to content
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

Implement Sentry integration #16

Merged
merged 2 commits into from
Aug 8, 2020
Merged

Implement Sentry integration #16

merged 2 commits into from
Aug 8, 2020

Conversation

agis
Copy link
Collaborator

@agis agis commented Aug 3, 2020

This patch adds support for Workers to emit various RSpecQ internal events to
a Sentry[1] instance.

Reporting to Sentry is opt-in and is enabled by setting the SENTRY_DSN
environment variable (see
https://github.com/getsentry/raven-ruby#raven-only-runs-when-sentry_dsn-is-set).
If SENTRY_DSN is not set this is a noop.

Events emitted:

  • [error] the spec file split command failed; slow spec files files will
    be scheduled as a whole so build times will be negatively impacted
  • [warning] no previous timings were found in Redis; scheduling will be random
    so build times will be negatively impacted
  • [info] slow files were detected and will be split, including the
    actual filenames

The above are still printed to the standard output of the worker.

Closes #8

[1] https://sentry.io

lib/rspecq/worker.rb Outdated Show resolved Hide resolved
lib/rspecq/worker.rb Outdated Show resolved Hide resolved
lib/rspecq/worker.rb Outdated Show resolved Hide resolved
lib/rspecq/worker.rb Show resolved Hide resolved
lib/rspecq/worker.rb Outdated Show resolved Hide resolved
lib/rspecq/worker.rb Show resolved Hide resolved
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
end

s.add_dependency "redis"
s.add_dependency "sentry-raven"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note that although raven-ruby has only one dependency at the moment as far as I can tell, this could create unnecessary issues with gem incompatibilities when the integration is not used. So perhaps in the future the whole integration along with dependencies can become opt-in?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could do this by not adding sentry-raven as a dependency and requiring the user to explicitly add it to their Gemfile. That said, I believe we should hold on until this pops up as an issue.

lib/rspecq/worker.rb Outdated Show resolved Hide resolved
lib/rspecq/worker.rb Show resolved Hide resolved
lib/rspecq/worker.rb Show resolved Hide resolved
@agis
Copy link
Collaborator Author

agis commented Aug 5, 2020

@georgepsarakis I actually removed the Sentry event of the "New/untimed job" because it was too spammy and caused a flood of events. It makes more sense to report that via StatsD (#2).

This patch adds support for Workers to emit various RSpecQ internal events to
a Sentry[1] instance.

Reporting to Sentry is opt-in and is enabled by setting the SENTRY_DSN
environment variable (see
https://github.com/getsentry/raven-ruby#raven-only-runs-when-sentry_dsn-is-set).
If SENTRY_DSN is not set this is a noop.

Events emitted:

- [error] the spec file split command failed; slow spec files files will
  be scheduled as a whole so build times will be negatively impacted
- [warning] no previous timings were found in Redis; scheduling will be random
  so build times will be negatively impacted
- [info] slow files were detected and will be split, including the
  actual filenames

The above are still printed to the standard output of the worker.

Closes #8

[1] https://sentry.io
Usually RSpec prints errors to stderr, so we have to grab it too in
order to display a helpful error message in case this command fails.

Ideally we'd do this with popen3, but this is good enough for now,
considering #6.
@agis agis merged commit fb26b45 into master Aug 8, 2020
@agis agis deleted the gh8-sentry branch August 8, 2020 19:08
agis added a commit that referenced this pull request Aug 8, 2020
@agis agis mentioned this pull request Aug 26, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sentry integration
3 participants