Skip to content

Async Elasticsearch Instrumentation #1362

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

Merged
merged 32 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9557df0
Adds async Elasticsearch support
fagnerzulin Feb 20, 2025
e9e07a7
Formatting and fixups
TimPansino Apr 7, 2025
4b670d1
Fix elasticsearch async import hooks
TimPansino Apr 7, 2025
9e6282e
Properly close clients
TimPansino Apr 7, 2025
01a21b9
More test fixes
TimPansino Apr 8, 2025
4544edf
More fixes
TimPansino Apr 21, 2025
6f5a90f
Format
TimPansino Apr 21, 2025
ae1754d
Deduplicate instance info code
TimPansino Apr 21, 2025
24affcc
Remove duplicate _async_ aliases
TimPansino Apr 21, 2025
5aa5c30
More code cleanup
TimPansino Apr 21, 2025
e9ceb3b
Change client fixture scopes to function for cleanup
TimPansino Apr 21, 2025
edfe432
Fix async client tests
TimPansino Apr 21, 2025
807b23d
Fix transport tests
TimPansino Apr 21, 2025
dc285fe
Ruff format
TimPansino Apr 21, 2025
121b475
Fix instance info on v7
TimPansino Apr 21, 2025
61f5c17
Fix mget tests on v7
TimPansino Apr 21, 2025
33de080
Merge branch 'main' into feat-async-elasticsearch
mergify[bot] Apr 21, 2025
502dcde
Merge branch 'main' into feat-async-elasticsearch
mergify[bot] Apr 21, 2025
466d613
Merge branch 'main' into feat-async-elasticsearch
mergify[bot] Apr 21, 2025
a32c566
Bump tests
TimPansino Apr 21, 2025
a359d13
Merge branch 'main' into feat-async-elasticsearch
mergify[bot] Apr 21, 2025
1ee8943
Merge branch 'main' into feat-async-elasticsearch
mergify[bot] Apr 22, 2025
c59258f
Merge branch 'main' into feat-async-elasticsearch
mergify[bot] Apr 22, 2025
412cc8d
Merge branch 'main' into feat-async-elasticsearch
mergify[bot] Apr 22, 2025
e870838
Remove duplicate import hook
TimPansino Apr 24, 2025
e01ebb3
Use get_package_version_tuple
TimPansino Apr 24, 2025
aace788
Add comments to try/except on imports
TimPansino Apr 24, 2025
4f26369
Fix up pytest skip markers
TimPansino Apr 24, 2025
2d25101
Add no transaction tests for full coverage
TimPansino Apr 24, 2025
f14e0f9
Remove old test code for ESv6
TimPansino Apr 24, 2025
858c8a5
Merge branch 'main' into feat-async-elasticsearch
mergify[bot] Apr 24, 2025
8267ae1
Merge branch 'main' into feat-async-elasticsearch
TimPansino Apr 24, 2025
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
67 changes: 65 additions & 2 deletions newrelic/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3066,15 +3066,30 @@ def _process_module_builtin_defaults():
_process_module_definition(
"elasticsearch.client", "newrelic.hooks.datastore_elasticsearch", "instrument_elasticsearch_client"
)
_process_module_definition(
"elasticsearch._async.client",
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch__async_client",
)
# v8 and above
_process_module_definition(
"elasticsearch._sync.client", "newrelic.hooks.datastore_elasticsearch", "instrument_elasticsearch_client_v8"
)
_process_module_definition(
"elasticsearch._async.client",
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch__async_client_v8",
)

# v7 and below
_process_module_definition(
"elasticsearch.client.cat", "newrelic.hooks.datastore_elasticsearch", "instrument_elasticsearch_client_cat"
)
_process_module_definition(
"elasticsearch._async.client.cat",
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch__async_client_cat",
)
# v8 and above
_process_module_definition(
"elasticsearch._sync.client.cat",
Expand All @@ -3088,30 +3103,43 @@ def _process_module_builtin_defaults():
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch_client_cluster",
)
_process_module_definition(
"elasticsearch._async.client.cluster",
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch__async_client_cluster",
)
# v8 and above
_process_module_definition(
"elasticsearch._sync.client.cluster",
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch_client_cluster_v8",
)

# v7 and below
_process_module_definition(
"elasticsearch.client.indices",
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch_client_indices",
)
_process_module_definition(
"elasticsearch._async.client.indices",
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch__async_client_indices",
)
# v8 and above
_process_module_definition(
"elasticsearch._sync.client.indices",
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch_client_indices_v8",
)

# v7 and below
_process_module_definition(
"elasticsearch.client.nodes", "newrelic.hooks.datastore_elasticsearch", "instrument_elasticsearch_client_nodes"
)
_process_module_definition(
"elasticsearch._async.client.nodes",
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch__async_client_nodes",
)
# v8 and above
_process_module_definition(
"elasticsearch._sync.client.nodes",
Expand All @@ -3125,6 +3153,11 @@ def _process_module_builtin_defaults():
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch_client_snapshot",
)
_process_module_definition(
"elasticsearch._async.client.snapshot",
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch__async_client_snapshot",
)
# v8 and above
_process_module_definition(
"elasticsearch._sync.client.snapshot",
Expand All @@ -3136,6 +3169,11 @@ def _process_module_builtin_defaults():
_process_module_definition(
"elasticsearch.client.tasks", "newrelic.hooks.datastore_elasticsearch", "instrument_elasticsearch_client_tasks"
)
_process_module_definition(
"elasticsearch._async.client.tasks",
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch__async_client_tasks",
)
# v8 and above
_process_module_definition(
"elasticsearch._sync.client.tasks",
Expand All @@ -3149,6 +3187,11 @@ def _process_module_builtin_defaults():
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch_client_ingest",
)
_process_module_definition(
"elasticsearch._async.client.ingest",
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch__async_client_ingest",
)
# v8 and above
_process_module_definition(
"elasticsearch._sync.client.ingest",
Expand All @@ -3162,23 +3205,43 @@ def _process_module_builtin_defaults():
"newrelic.hooks.datastore_elasticsearch",
"instrument_elasticsearch_connection_base",
)
_process_module_definition(
"elasticsearch._async.http_aiohttp",
"newrelic.hooks.datastore_elasticsearch",
"instrument_async_elasticsearch_connection_base",
)
# v8 and above
_process_module_definition(
"elastic_transport._node._base",
"newrelic.hooks.datastore_elasticsearch",
"instrument_elastic_transport__node__base",
)
_process_module_definition(
"elastic_transport._node._base_async",
"newrelic.hooks.datastore_elasticsearch",
"instrument_async_elastic_transport__node__base",
)

# v7 and below
_process_module_definition(
"elasticsearch.transport", "newrelic.hooks.datastore_elasticsearch", "instrument_elasticsearch_transport"
)
_process_module_definition(
"elasticsearch._async.transport",
"newrelic.hooks.datastore_elasticsearch",
"instrument_async_elasticsearch_transport",
)
# v8 and above
_process_module_definition(
"elastic_transport._transport",
"newrelic.hooks.datastore_elasticsearch",
"instrument_elastic_transport__transport",
)
_process_module_definition(
"elastic_transport._async_transport",
"newrelic.hooks.datastore_elasticsearch",
"instrument_async_elastic_transport__transport",
)

_process_module_definition("pika.adapters", "newrelic.hooks.messagebroker_pika", "instrument_pika_adapters")
_process_module_definition("pika.channel", "newrelic.hooks.messagebroker_pika", "instrument_pika_channel")
Expand Down
Loading
Loading