-
Notifications
You must be signed in to change notification settings - Fork 602
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
Set Elasticsearch operation dynamically #1543
Set Elasticsearch operation dynamically #1543
Conversation
end | ||
|
||
def test_segment_operation_returns_OPERATION_when_method_nil | ||
skip('How can I stub only the Array#index method?') |
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.
I'm assuming this means that the following line trying to stub isn't working how you want. I'm not sure how to do it with minitest stubs as I'm less familiar with that, but maybe James has some ideas since he's more familiar that.
I've used mocha more often so I'm more familiar with it. I'm pretty sure we can do this with mocha stubs though, using any_instance.
Array.any_instance.stubs(:index).returns(nil)
any_instance isn't really recommended generally, but we still do use it quite a lot in the agent tests already. If we do it this way, we'd also want to make sure mocha_teardown
gets added to the teardown method in here as well, so the stub doesn't leak past the test.
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.
Oh, I'm bummed I missed this until now! I readjusted the code and the tests a bit to make this case work in a different way. I'd be curious to see what you think!
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.
oh its cool, I'm glad you figured out another way to test it!
c94232a
to
a6f901d
Compare
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.
This awesome, thank you!
lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb
Outdated
Show resolved
Hide resolved
…ion.rb Co-authored-by: James Bunch <[email protected]>
SimpleCov Report
|
Overview
caller_locations
query
, the fallback value is proposed to becomeperform_request
since the dynamic operations are set to the methods called, it seems odd to have the operation default be unrelated to any Elasticsearch method name. Totally down to revert this change, however!instrumentation.elasticsearch
config value innewrelic.yml
Relates to #1525