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

Add ability to have many post initialization callbacks #1261

Conversation

mrexox
Copy link
Contributor

@mrexox mrexox commented Feb 2, 2021

Description

  • Add ability to have many integrations with as many changes to Configuration, as needed (current codebase allows only one post_initialization_callback)

I don't know if there is an issue about it. I faced this problem when I was trying to write my own extension of Sentry::Configuration. I suppose, it's not going to work with sentry-rails, because sentry-rails already redefined post_initialization_callback, and there was no mechanism for adding another callback to initialization process except for patching initialize method. I think this change will make it a bit easier in future.

@st0012
Copy link
Collaborator

st0012 commented Feb 2, 2021

@mrexox we already have a 4-2 branch and the PR here #1232. can you change your PR to base on that? thx

@mrexox mrexox force-pushed the add-ability-to-have-many-post-initialization-callbacks branch from 014ca79 to 5fe8e53 Compare February 2, 2021 04:37
@mrexox mrexox changed the base branch from master to 4-2 February 2, 2021 04:37
@mrexox mrexox force-pushed the add-ability-to-have-many-post-initialization-callbacks branch from 5fe8e53 to 8c2ec4e Compare February 2, 2021 04:39
@codecov-io
Copy link

codecov-io commented Feb 2, 2021

Codecov Report

Merging #1261 (1c38359) into 4-2 (58acd35) will decrease coverage by 0.31%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##              4-2    #1261      +/-   ##
==========================================
- Coverage   98.91%   98.59%   -0.32%     
==========================================
  Files          32      105      +73     
  Lines         921     4780    +3859     
==========================================
+ Hits          911     4713    +3802     
- Misses         10       67      +57     
Impacted Files Coverage Δ
sentry-rails/lib/sentry/rails/configuration.rb 100.00% <100.00%> (ø)
sentry-ruby/lib/sentry/configuration.rb 97.80% <100.00%> (ø)
sentry-ruby/spec/sentry/configuration_spec.rb 98.61% <100.00%> (ø)
sentry-ruby/spec/sentry_spec.rb 100.00% <0.00%> (ø)
sentry-ruby/lib/sentry/scope.rb 100.00% <0.00%> (ø)
...y-ruby/spec/sentry/transport/configuration_spec.rb 100.00% <0.00%> (ø)
...entry-sidekiq/lib/sentry/sidekiq/context_filter.rb 100.00% <0.00%> (ø)
sentry-ruby/lib/sentry/interface.rb 100.00% <0.00%> (ø)
sentry-ruby/spec/sentry/rake_spec.rb 100.00% <0.00%> (ø)
...y/spec/sentry/interfaces/request_interface_spec.rb 99.05% <0.00%> (ø)
... and 66 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 58acd35...1c38359. Read the comment docs.

Copy link
Collaborator

@st0012 st0012 left a comment

Choose a reason for hiding this comment

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

thanks for the idea and PR, but I think we still need some polishing here 🙂

sentry-rails/lib/sentry/rails/version.rb Outdated Show resolved Hide resolved
sentry-rails/sentry-rails.gemspec Outdated Show resolved Hide resolved
sentry-ruby/lib/sentry/configuration.rb Outdated Show resolved Hide resolved
sentry-ruby/lib/sentry/configuration.rb Outdated Show resolved Hide resolved
sentry-ruby/lib/sentry/configuration.rb Outdated Show resolved Hide resolved
sentry-ruby/spec/sentry/configuration_spec.rb Outdated Show resolved Hide resolved
@mrexox
Copy link
Contributor Author

mrexox commented Feb 2, 2021

I guess, the problem with CI is a problem with jruby. Don't know why, but it cannot find out a I18n::HashRefinement although it is being used by I18n. Tests on I18n pass OK with jruby, while these tests are failing 😕 . I'll investigate on this a bit later. Maybe someone has an idea, how to fix it?

@st0012
Copy link
Collaborator

st0012 commented Feb 2, 2021

no worries, that’s happening on master and the 4-2 branch as well, I’ll take care of that 🙂

@st0012
Copy link
Collaborator

st0012 commented Feb 2, 2021

@mrexox in case you're curious about it, the issue is a bug on jruby jruby/jruby#6547, which was surfaced because of ruby-i18n/i18n#554.

@st0012
Copy link
Collaborator

st0012 commented Feb 2, 2021

@mrexox I think if you rebase the branch against 4-2, the build will be green

@mrexox mrexox force-pushed the add-ability-to-have-many-post-initialization-callbacks branch from 59ad89c to 80979ec Compare February 2, 2021 11:32
@mrexox mrexox requested a review from st0012 February 2, 2021 11:36
Copy link
Collaborator

@st0012 st0012 left a comment

Choose a reason for hiding this comment

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

great job 👍
one last thing before merge - can you add a changelog entry for this change 😄

@st0012 st0012 merged commit b2359d0 into getsentry:4-2 Feb 2, 2021
st0012 added a commit that referenced this pull request Feb 3, 2021
* Add ThreadsInterface (#1178)

* Add ThreadsInterface

* Update changelog

* Inspect exception cause by default & don't exclude ActiveJob::DeserializationError  (#1180)

* Turn on inspect_exception_causes_for_exclusion by default

With this config turned on, we can avoid matching the surface exceptions
in integrations, which could cause issues like #1071.

Solves #642.

* Remove ActiveJob::DeserializationError from ignored list

Since the previous commit solves #642, this commit can remove
ActiveJob::DeserializationError from the ignored exceptions list.

Solves #1071.

* Update async document

* Update changelog

* Make sentry-rails a Rails engine and provide default job class for async (#1181)

* Make sentry-rails a Rails engine too

* Add Sentry::SendEventJob

Instead of letting users defining their SentryJob class, we should
provide a default job class for them.

* Update document and example for the new job class

* Update changelog

* Add configuration option for trusted proxies (#1126)

* Add configuration option for trusted proxies

* Add `trusted_proxies` configuration option to sentry-ruby
* Add existing ActionDispatch `trusted_proxies` values

* Address some PR feedback

* Isolate trusted proxy test configuration
* Add comments to explain why we reverse the forwarded_for ip list
* Call `uniq` on the trusted proxy list
* Rename `filter_local_addresses(ips) to filter_trusted_proxy_addresses(ips)

* Remove duplicated hash entry

* Update some tests after PR feedback

* retrigger checks

Co-authored-by: Stan Lo <stan001212@gmail.com>

* Only define SendEventJob when ActiveJob is defined

* Allow users to configure ActiveJob adapters to ignore (#1256)

* Allow users to configure ActiveJob adapters to ignore

* Update changelog

* Add sidekiq adapter to sentry-rails' ignored adapters list (#1257)

* Add sidekiq adapter to sentry-rails' ignored adapters list

* Update changelog

* Tag queue name and jid on sidekiq events (#1258)

* Add queue name and jid to event tags

* Update changelog

* Tag job_id and provider_job_id on ActiveJob events (#1259)

* Refactor/test ActiveJob's context data

* Tag job_id and provider_job_id on ActiveJob events

* Update changelog

* Add ability to have many post initialization callbacks (#1261)

* Add ability to have many post initialization callbacks

* Revert version bumping, fix codestyle and rewrite rspec test

* Remove dependenciy bumping from sentry-sidekiq

* Add entries to CHANGELOG

* Support config.before_breadcrumb (#1253)

* Support config.before_breadcrumb

Example:

```
config.before_breadcrumb = lambda do |breadcrumb, hint|
  breadcrumb.message = "foo"
  breadcrumb
end
```

* Update changelog

* Update sentry-ruby's changelog

* Update sentry-rails' changelog

* Update sentry-sidekiq's changelog

* Rename ignored_active_job_adapters to skippable_job_adapters (#1264)

* Update sentry-ruby's changelog

Co-authored-by: Jon-Erik Schneiderhan <45184220+jeschneiderhan@users.noreply.github.com>
Co-authored-by: Valentine Kiselev <mrexox@outlook.com>
st0012 pushed a commit that referenced this pull request Feb 3, 2021
* Add ability to have many post initialization callbacks

* Revert version bumping, fix codestyle and rewrite rspec test

* Remove dependenciy bumping from sentry-sidekiq

* Add entries to CHANGELOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants