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
Skip first runtime report when eager load false #233
Conversation
0dbcc9f
to
563c1ef
Compare
hmm this is interesting, I don't think it would resolve the resque issue, I would have to undo my other fix to test it out... I think the problem/difference is that I can run some tests on it, thinking we need some more tests around real world start ups with different settings between processes and threads. |
Did you see I avoided skipping any results on the resque fix case here: https://github.com/danmayer/coverband/pull/232/files#diff-8d2f5459991b3a79d0afa782146382f3R6 |
I think this is a good direction I am wondering if we ever want to skip results or if it is a first hit we send to :eager_loading vs :runtime The skip was kind of a hack for data ending up in the wrong type... |
My thought was now that you have discovered that rails rake tasks skip eager load, we can pivot our logic based on whether eager load is set. Re: The resque fix. We could change that to call
I'm not 100% sure on this. I don't think we can send to eager_load because there doesn't seem to be a way for us to know when a class is being loaded when eager_load is not set since classes are loaded on demand. Even skipping first coverage report is not a guarantee as a class can be loaded at any time although I feel like skipping the first n reports may be the best solution. |
So the issues we were having heroku and runtime coverage, I don't think were eager loading, as it was eager loading.
in this case wouldn't it be a call to
yeah I guess if we explicitly document and call out it isn't loading it is |
OK, the RC3 release is live on high volume sites and with a couple of hours don't seem to have any miscategorized traffic. I think I might test this PR and some of the other ideas around load vs runtime coverage for the next release. thoughts? @kbaum |
Agreed on this being a next release thing. Think eager loading coverage could be applicable outside of rails. Non rails projects like gems tend to require most files on startup. I think it can still be helpful to know what usage came on load of files on process start vs at runtime. I think this is true for most Sinatra projects as well though I am not sure. Without this separation of load vs runtime, I imagine it would be difficult to figure out which gems are unused within any bundler file regardless of whether it’s a rails project. |
yeah I agree it is very useful just trying to figure out if it is as easily detectable... I don't know if various other frameworks have I can try to search around and see what other common plug-in like Ruby systems do... If they have patterns for other Rack / CLI based tool chains |
563c1ef
to
9cefffd
Compare
Not sure either but projects can do this manually with coverband. For example: Bundler.require(:coverband_group)
require 'coverband'
Coverband.eager_loading_coverage!
Bundler.require(:default)
require 'thing1'
require 'thing2'
require 'sinatra'
get '/' do
"Hello, world. Here is the content of HELLO_URL (#{uri}): #{response.body.inspect}\n"
end
Coverband.runtime_coverage! |
@@ -4,7 +4,7 @@ | |||
Coverband.start | |||
Coverband.runtime_coverage! | |||
# no reason to miss coverage on a first resque job | |||
Coverband::Collectors::Delta.set_default_results | |||
Coverband.coverage.disable_skip_next_report! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danmayer - what do you think of something like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice much more understandable, big +1
True that is a great simple example perhaps we just document that really well and have the app log some helpful messages if a user is doing something that doesn't match expectations... like if they never call loading or send it data but start sending runtime data... We could alert, "Coverband is working fine, but we weren't able to detect code loading so all coverage is considered run-time" |
I like the idea of the warning. |
@@ -22,8 +21,7 @@ def setup | |||
Coverband.configuration.store.clear! | |||
Coverband.start | |||
Coverband::Collectors::Coverage.instance.runtime! | |||
@rack_file = File.expand_path(TEST_RACK_APP, File.dirname(__FILE__)) | |||
require @rack_file | |||
@rack_file = require_unique_file 'fake_app/basic_rack.rb' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danmayer - was running into sporadic errors. Making use of require_unique_file
seems to clear things up.
I will try to test this again some apps and confirm it is working how we like so we can get it merged soon |
Note: This PR was merged then reverted. We ended up going with #238. |
What you uncovered here, gave me an idea for skipping first coverage report in rails when eager load is false. Let me know what you think.