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

My api-only mode rails service not working on 5.10 #2077

Closed
stuckyi-slayer opened this issue Jul 25, 2023 · 4 comments
Closed

My api-only mode rails service not working on 5.10 #2077

stuckyi-slayer opened this issue Jul 25, 2023 · 4 comments

Comments

@stuckyi-slayer
Copy link

stuckyi-slayer commented Jul 25, 2023

Issue Description

I installed sentry-ruby, sentry-rails gem on my service. it is api-only mode and i commented unnecessary frameworks.
and i found i commented active_job/railtie, i can't load service. I got following message.

error messages

1: from /var/app/current/vendor/bundle/ruby/2.7.0/gems/sentry-rails-5.10.0/app/jobs/sentry/send_event_job.rb:2:in `<main>'
/var/app/current/vendor/bundle/ruby/2.7.0/gems/sentry-rails-5.10.0/app/jobs/sentry/send_event_job.rb:7:in `<module:Sentry>': uninitialized constant ActiveJob::Base (NameError)
Did you mean?  Base64

application.rb

...
require 'rails'
# Pick the frameworks you want:
require 'active_model/railtie'
#require "active_job/railtie"
require 'active_record/railtie'
# require "active_storage/engine"
require 'action_controller/railtie'
...

when i uncomment active_job/railtie, then errors gone.

Reproduction Steps

comment following in application.rb

# require "active_job/railtie"

Expected Behavior

puma start normally.

Actual Behavior

puma can not start.

Ruby Version

2.7.8

SDK Version

5.10

Integration and Its Version

Rails 7.0.6

Sentry Config

# frozen_string_literal: true

# See Also https://docs.sentry.io/platforms/ruby/guides/rails/configuration/options/
Sentry.init do |config|
  config.dsn = Rails.application.credentials.sentry_dsn
  config.breadcrumbs_logger = %i[active_support_logger http_logger]

  # Set traces_sample_rate to 1.0 to capture 100%
  # of transactions for performance monitoring.
  # We recommend adjusting this value in production.
  config.traces_sampler = if Rails.env.staging?
                            lambda do |sampling_context|
                              # transaction_context is the transaction object in hash form
                              # keep in mind that sampling happens right after the transaction is initialized
                              # for example, at the beginning of the request
                              transaction_context = sampling_context[:transaction_context]

                              # transaction_context helps you sample transactions with more sophistication
                              # for example, you can provide different sample rates based on the operation or name
                              op = transaction_context[:op]
                              transaction_name = transaction_context[:name]

                              case op
                              when /http/
                                case transaction_name
                                when /health/
                                  0.0 # ignore health_check requests
                                else
                                  1.0
                                end
                              else
                                0.0 # ignore all other transactions
                              end
                            end
                          else
                            lambda do |sampling_context|
                              # transaction_context is the transaction object in hash form
                              # keep in mind that sampling happens right after the transaction is initialized
                              # for example, at the beginning of the request
                              transaction_context = sampling_context[:transaction_context]

                              # transaction_context helps you sample transactions with more sophistication
                              # for example, you can provide different sample rates based on the operation or name
                              op = transaction_context[:op]
                              transaction_name = transaction_context[:name]

                              case op
                              when /http/
                                case transaction_name
                                when /health/
                                  0.0 # ignore health_check requests
                                else
                                  0.1
                                end
                              else
                                0.0 # ignore all other transactions
                              end
                            end
                          end

  filter = ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters)
  config.before_send = lambda do |event, _hint|
    filter.filter(event.to_hash)
  end

  config.enabled_environments = %w[production staging]
  config.max_breadcrumbs = 30
  config.send_default_pii = true
  config.send_modules = false
end
@sl0thentr0py
Copy link
Member

@stuckyi-slayer seems you're still using config.async, please remove it from your sentry initializer, see here for more info.

@stuckyi-slayer
Copy link
Author

stuckyi-slayer commented Jul 31, 2023

@stuckyi-slayer seems you're still using config.async, please remove it from your sentry initializer, see here for more info.

I don't have async options.
this is my sentry.rb
❯ cat sentry.rb

# frozen_string_literal: true

# See Also https://docs.sentry.io/platforms/ruby/guides/rails/configuration/options/
Sentry.init do |config|
  config.dsn = Rails.application.credentials.sentry_dsn
  config.breadcrumbs_logger = %i[active_support_logger http_logger]

  # Set traces_sample_rate to 1.0 to capture 100%
  # of transactions for performance monitoring.
  # We recommend adjusting this value in production.
  config.traces_sampler = if Rails.env.staging?
                            lambda do |sampling_context|
                              # transaction_context is the transaction object in hash form
                              # keep in mind that sampling happens right after the transaction is initialized
                              # for example, at the beginning of the request
                              transaction_context = sampling_context[:transaction_context]

                              # transaction_context helps you sample transactions with more sophistication
                              # for example, you can provide different sample rates based on the operation or name
                              op = transaction_context[:op]
                              transaction_name = transaction_context[:name]

                              case op
                              when /http/
                                case transaction_name
                                when /health/
                                  0.0 # ignore health_check requests
                                else
                                  1.0
                                end
                              else
                                0.0 # ignore all other transactions
                              end
                            end
                          else
                            lambda do |sampling_context|
                              # transaction_context is the transaction object in hash form
                              # keep in mind that sampling happens right after the transaction is initialized
                              # for example, at the beginning of the request
                              transaction_context = sampling_context[:transaction_context]

                              # transaction_context helps you sample transactions with more sophistication
                              # for example, you can provide different sample rates based on the operation or name
                              op = transaction_context[:op]
                              transaction_name = transaction_context[:name]

                              case op
                              when /http/
                                case transaction_name
                                when /health/
                                  0.0 # ignore health_check requests
                                else
                                  0.1
                                end
                              else
                                0.0 # ignore all other transactions
                              end
                            end
                          end

  filter = ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters)
  config.before_send = lambda do |event, _hint|
    filter.filter(event.to_hash)
  end

  config.enabled_environments = %w[production staging]
  config.max_breadcrumbs = 30
  config.send_default_pii = true
  config.send_modules = false
end

@sl0thentr0py
Copy link
Member

@stuckyi-slayer I tried loading without active_job/railtie and it works for me, can you please make a complete reproduction case and link me to it?

@getsantry
Copy link

getsantry bot commented Aug 23, 2023

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Aug 23, 2023
@getsantry getsantry bot closed this as completed Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants