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

undefined method 'resource=' for nil:NilClass: Disabling tracing breaks grape application on 1.0.0.beta1 #1940

Closed
ivoanjo opened this issue Mar 18, 2022 · 2 comments · Fixed by #1943
Assignees
Labels
bug Involves a bug integrations Involves tracing integrations
Projects
Milestone

Comments

@ivoanjo
Copy link
Member

ivoanjo commented Mar 18, 2022

Found this issue while doing a few experiments.

To reproduce, use:

  1. config.ru:
require_relative 'fibonacci'

puts "prof-fibonacci started at #{Time.new.utc}"

FibClient.new.start

run FibServer
  1. Gemfile:
source 'https://rubygems.org'

gem 'google-protobuf'
gem 'ddtrace', '= 1.0.0.beta1'

gem 'grape', '~> 1.6', '>= 1.6.2'
gem 'open-uri'
  1. fibonacci.rb:
require 'grape'
require 'active_support/cache'
require 'ddtrace'
require 'open-uri'

Datadog.configure do |c|
  c.tracing.instrument :grape
  c.tracing.enabled = false
end

class FibServer < Grape::API
  format :json

  resource :test do
    params { requires :n, type: Integer }
    route_param :n do
      get(:test) { '' }
    end
  end
end

class FibClient
  def fib_request
    URI.open("http://127.0.0.1:18080/test/1/test")
    sleep 0.1
  end

  def wait_for_webserver
    fib_request
    puts "Web server started!"
  rescue Errno::ECONNREFUSED
    print '.'
    retry
  end

  def start
    Thread.new do
      wait_for_webserver

      puts "Workload generator started!"


      loop {
        fib_request
        print '.'
      }
    end
  end
end

And this is what happens when I run it:

$ bundle exec ddtracerb exec rackup -p 18080 -q
prof-fibonacci started at 2022-03-18 11:17:32 UTC
...................................................................[2022-03-18 11:17:32] INFO  WEBrick 1.6.1
.[2022-03-18 11:17:32] INFO  ruby 2.7.5 (2021-11-24) [x86_64-darwin19]
..........................................................................................................................................................................................................................................................................................................[2022-03-18 11:17:32] INFO  WEBrick::HTTPServer#start: pid=49243 port=18080
.E, [2022-03-18T11:17:32.862290 #49243] ERROR -- ddtrace: [ddtrace] (/Users/ivo.anjo/.rvm/gems/ruby-2.7.5/gems/ddtrace-1.0.0.beta1/lib/datadog/tracing/contrib/grape/endpoint.rb:67:in `rescue in endpoint_start_process') undefined method `resource=' for nil:NilClass
Did you mean?  rescue
Web server started!
Workload generator started!
E, [2022-03-18T11:17:32.974755 #49243] ERROR -- ddtrace: [ddtrace] (/Users/ivo.anjo/.rvm/gems/ruby-2.7.5/gems/ddtrace-1.0.0.beta1/lib/datadog/tracing/contrib/grape/endpoint.rb:67:in `rescue in endpoint_start_process') undefined method `resource=' for nil:NilClass
Did you mean?  rescue
.E, [2022-03-18T11:17:33.085210 #49243] ERROR -- ddtrace: [ddtrace] (/Users/ivo.anjo/.rvm/gems/ruby-2.7.5/gems/ddtrace-1.0.0.beta1/lib/datadog/tracing/contrib/grape/endpoint.rb:67:in `rescue in endpoint_start_process') undefined method `resource=' for nil:NilClass
Did you mean?  rescue
.E, [2022-03-18T11:17:33.191058 #49243] ERROR -- ddtrace: [ddtrace] (/Users/ivo.anjo/.rvm/gems/ruby-2.7.5/gems/ddtrace-1.0.0.beta1/lib/datadog/tracing/contrib/grape/endpoint.rb:67:in `rescue in endpoint_start_process') undefined method `resource=' for nil:NilClass
@ivoanjo ivoanjo changed the title "undefined method `resource=' for nil:NilClass" -- Disabling tracing breaks grape application on 1.0.0.beta1 undefined method resource=' for nil:NilClass`: Disabling tracing breaks grape application on 1.0.0.beta1 Mar 18, 2022
@ivoanjo ivoanjo changed the title undefined method resource=' for nil:NilClass`: Disabling tracing breaks grape application on 1.0.0.beta1 ``undefined method resource=' for nil:NilClass```: Disabling tracing breaks grape application on 1.0.0.beta1 Mar 18, 2022
@ivoanjo ivoanjo changed the title ``undefined method resource=' for nil:NilClass```: Disabling tracing breaks grape application on 1.0.0.beta1 undefined method 'resource=' for nil:NilClass: Disabling tracing breaks grape application on 1.0.0.beta1 Mar 18, 2022
@delner delner self-assigned this Mar 18, 2022
@delner delner added bug Involves a bug integrations Involves tracing integrations labels Mar 18, 2022
@delner delner added this to the 1.0.0.beta2 milestone Mar 18, 2022
@delner delner added this to Review in progress in 1.0 Mar 18, 2022
@delner
Copy link
Contributor

delner commented Mar 18, 2022

Opened a PR to fix this: #1943.

@delner
Copy link
Contributor

delner commented Mar 22, 2022

Opened an additional PR for Rake. While it doesn't raise an error like Grape, it does help prevent tracing from running when it shouldn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Involves a bug integrations Involves tracing integrations
Projects
1.0
Review in progress
Development

Successfully merging a pull request may close this issue.

2 participants