Skip to content

sentry-rails: NoMethodError: undefined method `span' for nil:NilClass #1539

@timhaines

Description

@timhaines

Describe the bug
In a sidekiq job, I'm getting an error at gems/sentry-rails-4.6.5/app/jobs/sentry/send_event_job.rb:26:in:

In perform, Sentry.get_current_scope must be returning nil, resulting in:

NoMethodError: undefined method 'span' for nil:NilClass

Environment

  • Ruby Version: 2.7.4p191
  • SDK Version: 4.6.5
  • Integration Versions (if any):
  • e.g. Rails 6.1.4, Sidekiq 6.2.1

Sentry Config

This is not necessary but could be helpful.

dsn is actually not set, as I don't have SENTRY_DSN setup in my env.

Sentry.init do |config|
    config.dsn = ENV["SENTRY_DSN"]
    config.breadcrumbs_logger = [:active_support_logger, :http_logger]

    # Set tracesSampleRate to 1.0 to capture 100%
    # of transactions for performance monitoring.
    # We recommend adjusting this value in production
    config.traces_sample_rate = 0.5

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

    config.async = lambda do |event, hint|
      Sentry::SendEventJob.perform_later(event, hint)
    end
  end
end

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions