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

Clear thread local variables when forked #1214

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

estolfo
Copy link
Contributor

@estolfo estolfo commented Dec 16, 2021

Thread local variables are copied over when a process is forked so we should clear the MongoSpy thread locals when forked.

@apmmachine
Copy link
Collaborator

apmmachine commented Dec 16, 2021

💔 Tests Failed

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-03-31T05:45:19.763+0000

  • Duration: 24 min 26 sec

Test stats 🧪

Test Results
Failed 263
Passed 26441
Skipped 33
Total 26737

Test errors 263

Expand to view the tests failures

> Show only the first 10 test failures

Tests / Tests / Ruby:ruby:3.0#sinatra-2.0 / Spy: Sidekiq starts when sidekiq processors do – Spy: Sidekiq
    Expand to view the error details

     failed Spy: Sidekiq starts when sidekiq processors do 
    

    Expand to view the stacktrace

     
            undefined method `logger=' for Sidekiq:Module
    Did you mean?  logger
    ["./spec/elastic_apm/spies/sidekiq_spec.rb:57:in `block (2 levels) in <module:ElasticAPM>'"]
           
    

Tests / Tests / Ruby:ruby:3.0#sinatra-2.0 / Spy: Sidekiq with an agent instruments jobs – with an agent
    Expand to view the error details

     failed Spy: Sidekiq with an agent instruments jobs 
    

    Expand to view the stacktrace

     
            undefined method `logger=' for Sidekiq:Module
    Did you mean?  logger
    ["./spec/elastic_apm/spies/sidekiq_spec.rb:57:in `block (2 levels) in <module:ElasticAPM>'"]
           
    

Tests / Tests / Ruby:ruby:3.0#sinatra-2.0 / Spy: Sidekiq with an agent reports errors – with an agent
    Expand to view the error details

     failed Spy: Sidekiq with an agent reports errors 
    

    Expand to view the stacktrace

     
            undefined method `logger=' for Sidekiq:Module
    Did you mean?  logger
    ["./spec/elastic_apm/spies/sidekiq_spec.rb:57:in `block (2 levels) in <module:ElasticAPM>'"]
           
    

Tests / Tests / Ruby:ruby:3.0#sinatra-2.0 / Spy: Elasticsearch spans requests – Spy: Elasticsearch
    Expand to view the error details

     failed Spy: Elasticsearch spans requests 
    

    Expand to view the stacktrace

     
            undefined method `name' for nil:NilClass
    ["./spec/elastic_apm/spies/elasticsearch_spec.rb:61:in `block (2 levels) in <module:ElasticAPM>'", "/usr/local/bundle/gems/webmock-3.18.1/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'"]
           
    

Tests / Tests / Ruby:ruby:3.0#sinatra-2.0 / Spy: Elasticsearch a post request with body when capture_elasticsearch_queries is true uses the body in the statement – when capture_elasticsearch_queries is true
    Expand to view the error details

     failed Spy: Elasticsearch a post request with body when capture_elasticsearch_queries is true uses the body in the statement 
    

    Expand to view the stacktrace

     
            undefined method `name' for nil:NilClass
    ["./spec/elastic_apm/spies/elasticsearch_spec.rb:96:in `block (4 levels) in <module:ElasticAPM>'", "/usr/local/bundle/gems/webmock-3.18.1/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'"]
           
    

Tests / Tests / Ruby:ruby:3.0#sinatra-2.0 / Spy: Elasticsearch a post request with body when capture_elasticsearch_queries is true filters sensitive information – when capture_elasticsearch_queries is true
    Expand to view the error details

     failed Spy: Elasticsearch a post request with body when capture_elasticsearch_queries is true filters sensitive information 
    

    Expand to view the stacktrace

     
            undefined method `context' for nil:NilClass
    ["./spec/elastic_apm/spies/elasticsearch_spec.rb:123:in `block (4 levels) in <module:ElasticAPM>'", "/usr/local/bundle/gems/webmock-3.18.1/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'"]
           
    

Tests / Tests / Ruby:ruby:3.0#sinatra-2.0 / Spy: Elasticsearch a post request with body when capture_elasticsearch_queries is false does not use the body in the statement – when capture_elasticsearch_queries is false
    Expand to view the error details

     failed Spy: Elasticsearch a post request with body when capture_elasticsearch_queries is false does not use the body in the statement 
    

    Expand to view the stacktrace

     
            undefined method `name' for nil:NilClass
    ["./spec/elastic_apm/spies/elasticsearch_spec.rb:147:in `block (4 levels) in <module:ElasticAPM>'", "/usr/local/bundle/gems/webmock-3.18.1/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'"]
           
    

Tests / Tests / Ruby:ruby:3.0#sinatra-2.0 / Spy: Faraday falls back to localhost when hostname not provided – Spy: Faraday
    Expand to view the error details

     failed Spy: Faraday falls back to localhost when hostname not provided 
    

    Expand to view the stacktrace

     
            Absolute URI missing hierarchical segment: 'http://:80'
    ["/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:2470:in `validate'", "/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:2410:in `defer_validation'", "/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:839:in `initialize'", "/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:152:in `new'", "/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:152:in `parse'", "/usr/local/bundle/gems/webmock-3.18.1/lib/webmock/http_lib_adapters/net_http.rb:136:in `start'", "/usr/local/bundle/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:112:in `request_with_wrapped_block'", "/usr/local/bundle/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:102:in `perform_request'", "/usr/local/bundle/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:66:in `block in call'", "/usr/local/bundle/gems/faraday-2.7.4/lib/faraday/adapter.rb:45:in `connection'", "/usr/local/bundle/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:65:in `call'", "/usr/local/bundle/gems/faraday-2.7.4/lib/faraday/request/url_encoded.rb:25:in `call'", "/usr/local/bundle/gems/faraday-2.7.4/lib/faraday/rack_builder.rb:153:in `build_response'", "/usr/local/bundle/gems/faraday-2.7.4/lib/faraday/connection.rb:444:in `run_request'", "./lib/elastic_apm/spies/faraday.rb:106:in `block (2 levels) in run_request'", "./lib/elastic_apm/spies.rb:74:in `block in without_net_http'", "./lib/elastic_apm/spies/net_http.rb:42:in `disable_in'", "./lib/elastic_apm/spies.rb:73:in `without_net_http'", "./lib/elastic_apm/spies/faraday.rb:103:in `block in run_request'", "./lib/elastic_apm.rb:301:in `with_span'", "./lib/elastic_apm/spies/faraday.rb:97:in `run_request'", "/usr/local/bundle/gems/faraday-2.7.4/lib/faraday/connection.rb:200:in `get'", "/usr/local/bundle/gems/faraday-2.7.4/lib/faraday.rb:145:in `method_missing'", "./spec/elastic_apm/spies/faraday_spec.rb:172:in `block (4 levels) in <module:ElasticAPM>'", "./lib/elastic_apm.rb:189:in `with_transaction'", "./spec/elastic_apm/spies/faraday_spec.rb:171:in `block (3 levels) in <module:ElasticAPM>'", "./spec/support/with_agent.rb:32:in `with_agent'", "./spec/elastic_apm/spies/faraday_spec.rb:170:in `block (2 levels) in <module:ElasticAPM>'", "/usr/local/bundle/gems/webmock-3.18.1/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'"]
           
    

Tests / Tests / Ruby:ruby:3.0#sinatra-2.0 / Spy: NetHTTP supports path being a uri – Spy: NetHTTP
    Expand to view the error details

     failed Spy: NetHTTP supports path being a uri 
    

    Expand to view the stacktrace

     
            Absolute URI missing hierarchical segment: 'http://:80'
    ["/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:2470:in `validate'", "/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:2410:in `defer_validation'", "/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:839:in `initialize'", "/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:152:in `new'", "/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:152:in `parse'", "/usr/local/bundle/gems/webmock-3.18.1/lib/webmock/http_lib_adapters/net_http.rb:136:in `start'", "./spec/elastic_apm/spies/net_http_spec.rb:251:in `block (4 levels) in <module:ElasticAPM>'", "./lib/elastic_apm.rb:189:in `with_transaction'", "./spec/elastic_apm/spies/net_http_spec.rb:250:in `block (3 levels) in <module:ElasticAPM>'", "./spec/support/with_agent.rb:32:in `with_agent'", "./spec/elastic_apm/spies/net_http_spec.rb:249:in `block (2 levels) in <module:ElasticAPM>'", "/usr/local/bundle/gems/webmock-3.18.1/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'"]
           
    

Tests / Tests / Ruby:ruby:3.0#sinatra-2.0 / Spy: NetHTTP defaults missing host to localhost – Spy: NetHTTP
    Expand to view the error details

     failed Spy: NetHTTP defaults missing host to localhost 
    

    Expand to view the stacktrace

     
            Absolute URI missing hierarchical segment: 'http://:80'
    ["/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:2470:in `validate'", "/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:2410:in `defer_validation'", "/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:839:in `initialize'", "/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:152:in `new'", "/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:152:in `parse'", "/usr/local/bundle/gems/webmock-3.18.1/lib/webmock/http_lib_adapters/net_http.rb:136:in `start'", "./spec/elastic_apm/spies/net_http_spec.rb:236:in `block (4 levels) in <module:ElasticAPM>'", "./lib/elastic_apm.rb:189:in `with_transaction'", "./spec/elastic_apm/spies/net_http_spec.rb:235:in `block (3 levels) in <module:ElasticAPM>'", "./spec/support/with_agent.rb:32:in `with_agent'", "./spec/elastic_apm/spies/net_http_spec.rb:234:in `block (2 levels) in <module:ElasticAPM>'", "/usr/local/bundle/gems/webmock-3.18.1/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'"]
           
    

Steps errors 99

Expand to view the steps failures

Show only the first 10 steps failures

Shell Script
  • Took 2 min 3 sec . View more details here
  • Description: ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-8-jdk rails-6.0
Shell Script
  • Took 2 min 4 sec . View more details here
  • Description: ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-8-jdk rails-5.2
Shell Script
  • Took 2 min 4 sec . View more details here
  • Description: ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-8-jdk rails-5.2
Shell Script
  • Took 2 min 53 sec . View more details here
  • Description: ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-8-jdk sinatra-2.0
Shell Script
  • Took 2 min 55 sec . View more details here
  • Description: ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-8-jdk sinatra-2.0
Shell Script
  • Took 2 min 55 sec . View more details here
  • Description: ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-8-jdk grape-1.5
Shell Script
  • Took 2 min 56 sec . View more details here
  • Description: ./spec/scripts/spec.sh docker.elastic.co/observability-ci/jruby:9.2-8-jdk grape-1.5
Restore files previously stashed
  • Took 0 min 0 sec . View more details here
  • Description: coverage-ruby-2.6-rails-6.1
Read yaml from files in the workspace or text.
  • Took 0 min 0 sec . View more details here
  • Description: .ci/.jenkins_main_framework.yml
Error signal
  • Took 0 min 0 sec . View more details here
  • Description: Ruby:ruby:3.0#rails-6.1 tests failed : hudson.AbortException: script returned exit code 1

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • run benchmark tests : Run the benchmark test.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@estolfo estolfo changed the title Clear MongoSpy thread local when forked Clear thread local variables when forked Dec 17, 2021
@mikker
Copy link
Contributor

mikker commented Dec 17, 2021

Wow, what a find! 👏

@jclusso
Copy link
Contributor

jclusso commented Dec 19, 2021

@estolfo still no luck for us. We're still seeing all those random spans getting collected on that one worker.

@apmmachine
Copy link
Collaborator

apmmachine commented May 17, 2022

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (1/1) 💚
Files 99.2% (124/125)
Classes 99.2% (124/125)
Lines 94.579% (4135/4372)
Conditionals 100.0% (0/0) 💚

@jclusso
Copy link
Contributor

jclusso commented Jun 28, 2022

@estolfo we're still using this branch and I was wondering if this is going to get merged or what exactly is happening here. Wanted to get us back on the main version.

@estolfo
Copy link
Contributor Author

estolfo commented Jun 30, 2022

Hi @jclusso I made these changes hoping they would fix the issues you were seeing but when we tested, they didn't. So I am hesitant to merge these changes without a specific reason, though in theory, they make sense. @jaggederest is working on the agent now so I'll ask him to review these changes and help decide if they should be merged.
By the way, have you tried the latest stable of the Ruby agent recently? Does it work for you?

@jclusso
Copy link
Contributor

jclusso commented Jun 30, 2022

Going to try running the main branch. We’ve been sitting on your fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
APM-Agents (OLD)
  
In Progress
Development

Successfully merging this pull request may close these issues.

None yet

4 participants