Skip to content

Commit 4155ec6

Browse files
committed
Wrap the import of elasticsearch for versioning in a try/except
1 parent b36cbd6 commit 4155ec6

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Pending
4+
5+
### Fixed
6+
- Wrap an import of elasticsearch in a try/except.
7+
([Issue 744](https://github.com/scoutapp/scout_apm_python/issues/744))
8+
39
## [2.26.0] 2022-07-27
410

511
### Added

src/scout_apm/instruments/elasticsearch.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
import logging
55
from collections import namedtuple
66

7-
import elasticsearch
87
import wrapt
98

109
from scout_apm.compat import get_pos_args, unwrap_decorators
1110
from scout_apm.core.tracked_request import TrackedRequest
1211

1312
try:
13+
from elasticsearch import VERSION as ELASTICSEARCH_VERSION
1414
from elasticsearch import Elasticsearch
1515
except ImportError: # pragma: no cover
1616
Elasticsearch = None
17+
ELASTICSEARCH_VERSION = (0, 0, 0)
1718

1819
try:
1920
# Transport was moved to elastic_transport as of v8.0.0
@@ -100,7 +101,7 @@ def ensure_installed():
100101
}
101102

102103
CLIENT_METHODS = VERSIONED_CLIENT_METHODS["v7"][:]
103-
if elasticsearch.VERSION > (8, 0, 0):
104+
if ELASTICSEARCH_VERSION > (8, 0, 0):
104105
CLIENT_METHODS += VERSIONED_CLIENT_METHODS["v8"]
105106

106107

0 commit comments

Comments
 (0)