Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion newrelic/hooks/datastore_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ async def _nr_wrapper_AsyncElasticsearch_method_(wrapped, instance, args, kwargs
("msearch_template", _extract_args_search_templates_index),
("mtermvectors", _extract_args_index),
("open_point_in_time", _extract_args_index),
("options", None),
("ping", None),
("put_script", None),
("rank_eval", _extract_args_requests_index),
Expand Down
19 changes: 18 additions & 1 deletion tests/datastore_elasticsearch/test_async_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from conftest import ES_SETTINGS, IS_V8_OR_ABOVE
from conftest import ES_SETTINGS, IS_V8_OR_ABOVE, RUN_IF_V8_OR_ABOVE
from elasticsearch._async import client
from testing_support.fixture.event_loop import event_loop as loop
from testing_support.fixtures import override_application_settings
Expand Down Expand Up @@ -215,3 +215,20 @@ def test_async_elasticsearch_operation_enabled_empty_transaction_settings(async_

def test_async_elasticsearch_no_transaction(async_client, loop):
loop.run_until_complete(_exercise_es(async_client))


@RUN_IF_V8_OR_ABOVE
@background_task()
def test_async_elasticsearch_options_no_crash(async_client, loop):
"""Test that the options method on the async client doesn't cause a crash when run with the agent"""

async def _test():
client_with_auth = async_client.options(basic_auth=("username", "password"))
assert client_with_auth is not None
assert client_with_auth != async_client

# If options was instrumented, this would cause a crash since the first call would return an unexpected coroutine
client_chained = async_client.options(basic_auth=("user", "pass")).options(request_timeout=60)
assert client_chained is not None

loop.run_until_complete(_test())
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async def _test():

def _test_methods_wrapped(_object, ignored_methods=None):
if not ignored_methods:
ignored_methods = {"perform_request", "transport"}
ignored_methods = {"perform_request", "transport", "options"}

def is_wrapped(m):
return hasattr(getattr(_object, m), "__wrapped__")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _test():

def _test_methods_wrapped(_object, ignored_methods=None):
if not ignored_methods:
ignored_methods = {"perform_request", "transport"}
ignored_methods = {"perform_request", "transport", "options"}

def is_wrapped(m):
return hasattr(getattr(_object, m), "__wrapped__")
Expand Down
Loading