Repository: scoutapp/scout_apm_python
Pull request #601 (2021-02-09 09:39:32)

Drop pyenv version file
This mostly gets in the way, needing updating after updating system Python. The unpinned Python versions on CI check we test with the latest Python versions at least.


Patch:
diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml
new file mode 100644
index 0000000..3a05705
--- /dev/null
+++ b/.github/workflows/pre-commit.yml
@@ -0,0 +1,22 @@
+name: pre-commit
+
+on:
+  push:
+    branches:
+    - master
+  pull_request:
+
+jobs:
+  pre-commit:
+    runs-on: ubuntu-20.04
+
+    steps:
+    - uses: actions/checkout@v2
+      with:
+        fetch-depth: 0
+
+    - uses: actions/setup-python@v2
+
+    - uses: pre-commit/action@v2.0.0
+      with:
+        token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 9a75665..acc9ffa 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,6 +1,6 @@
 repos:
 - repo: https://github.com/pre-commit/pre-commit-hooks
-  rev: v3.2.0
+  rev: v3.4.0
   hooks:
   - id: check-added-large-files
   - id: check-case-conflict
@@ -12,20 +12,28 @@ repos:
   - id: check-yaml
   - id: end-of-file-fixer
   - id: trailing-whitespace
-- repo: local
+- repo: https://github.com/psf/black
+  rev: 20.8b1
   hooks:
   - id: black
-    name: black
-    entry: .tox/py38-codestyle/bin/black
-    language: system
-    types: [python]
-  - id: flake8
-    name: flake8
-    entry: .tox/py38-codestyle/bin/flake8 --config=setup.cfg
-    language: system
-    types: [python]
+    language_version: python3
+- repo: https://github.com/pycqa/isort
+  rev: 5.7.0
+  hooks:
   - id: isort
-    name: isort
-    entry: .tox/py38-codestyle/bin/isort
-    language: system
-    types: [python]
+- repo: https://gitlab.com/pycqa/flake8
+  rev: 3.8.4
+  hooks:
+  - id: flake8
+    additional_dependencies:
+    - flake8-2020
+    - flake8-bugbear
+    - flake8-coding
+    - flake8-comprehensions
+    - flake8-tidy-imports
+    - flake8-print
+- repo: https://github.com/mgedmin/check-manifest
+  rev: "0.46"
+  hooks:
+  - id: check-manifest
+    args: [--no-build-isolation]
diff --git a/.python-version b/.python-version
deleted file mode 100644
index e446773..0000000
--- a/.python-version
+++ /dev/null
@@ -1,8 +0,0 @@
-3.8.5
-3.7.8
-3.6.11
-3.5.9
-3.4.10
-2.7.18
-pypy3.6-7.1.1
-pypy2.7-7.1.1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 113918b..918c604 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog
 
+- Instrument new Elasticsearch methods `close_point_in_time()` and
+  `open_point_in_time()`.
+  ([PR #602](https://github.com/scoutapp/scout_apm_python/pull/602))
+
 ## [2.17.1] 2021-02-01
 
 ### Fixed
diff --git a/MANIFEST.in b/MANIFEST.in
index ba9d101..320b885 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,6 +1,7 @@
 global-exclude *.py[cod]
 prune __pycache__
 prune tests
+recursive-include src *.c
 include CHANGELOG.md
 include DEVELOPMENT.md
 include LICENSE
diff --git a/src/scout_apm/core/config.py b/src/scout_apm/core/config.py
index 8dc8682..076f0a1 100644
--- a/src/scout_apm/core/config.py
+++ b/src/scout_apm/core/config.py
@@ -222,7 +222,7 @@ class Defaults(object):
             "core_agent_socket_path": "tcp://127.0.0.1:6590",
             "core_agent_version": "v1.3.0",  # can be an exact tag name, or 'latest'
             "disabled_instruments": [],
-            "download_url": "https://s3-us-west-1.amazonaws.com/scout-public-downloads/apm_core_agent/release",  # noqa: E501
+            "download_url": "https://s3-us-west-1.amazonaws.com/scout-public-downloads/apm_core_agent/release",  # noqa: B950
             "framework": "",
             "framework_version": "",
             "hostname": None,
diff --git a/src/scout_apm/instruments/elasticsearch.py b/src/scout_apm/instruments/elasticsearch.py
index 5b5eb60..bdfd4c4 100644
--- a/src/scout_apm/instruments/elasticsearch.py
+++ b/src/scout_apm/instruments/elasticsearch.py
@@ -36,6 +36,7 @@ CLIENT_METHODS = [
     ClientMethod("bulk", True),
     ClientMethod("clear_scroll", False),
     ClientMethod("close", False),
+    ClientMethod("close_point_in_time", False),
     ClientMethod("count", True),
     ClientMethod("create", True),
     ClientMethod("delete", True),
@@ -57,6 +58,7 @@ CLIENT_METHODS = [
     ClientMethod("msearch", True),
     ClientMethod("msearch_template", True),
     ClientMethod("mtermvectors", True),
+    ClientMethod("open_point_in_time", True),
     ClientMethod("ping", False),
     ClientMethod("put_script", False),
     ClientMethod("rank_eval", True),
diff --git a/tox.ini b/tox.ini
index d16a6c1..324c1ba 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,7 +1,6 @@
 [tox]
 isolated_build = True
 envlist =
-    py38-codestyle
     {py27,py34,py35}-django18
     {py27,py34,py35,py36}-django111
     {py34,py35,py36,py37,py38}-django20
@@ -68,22 +67,3 @@ deps =
     webtest
 commands =
     pytest {posargs}
-
-[testenv:py38-codestyle]
-deps =
-    check-manifest
-    black
-    flake8
-    flake8-2020
-    flake8-bugbear
-    flake8-coding
-    flake8-comprehensions
-    flake8-tidy-imports
-    flake8-print
-    isort
-    pre-commit
-    twine
-commands =
-    check-manifest
-    pre-commit run --all-files
-    twine check {distdir}/*


Test patch:
diff --git a/pytest.ini b/pytest.ini
index 0f27be3..9265f1f 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -49,6 +49,8 @@ filterwarnings =
     ; Deprecations in our libraries
     ignore:dns.hash module will be removed.*:DeprecationWarning:dns.hash
     ignore:Pipeline\.hmset\(\) is deprecated\. Use Pipeline\.hset\(\) instead\.:DeprecationWarning
+    ; eventlet warning against use of Python 2.7
+    ignore:Support for your Python version is deprecated and will be removed in the future:DeprecationWarning:eventlet
     ; Appears in both gettext and Django:
     ignore:parameter codeset is deprecated:DeprecationWarning
     ignore:"errors" is deprecated. Use "encoding_errors" instead:DeprecationWarning:redis.client
@@ -64,5 +66,3 @@ filterwarnings =
     ; Django 3.1 warnings
     ; RemovedInDjango40Warning to be fixed in https://github.com/encode/django-rest-framework/issues/7406
     ignore:django\.conf\.urls\.url\(\) is deprecated.*:PendingDeprecationWarning:rest_framework.routers
-    ; Django 2.7 Support deprecation warning
-    ignore:Support for your Python version is deprecated and will be removed in the future:DeprecationWarning
diff --git a/tests/unit/core/test_web_requests.py b/tests/unit/core/test_web_requests.py
index 357c826..d9ad4d5 100644
--- a/tests/unit/core/test_web_requests.py
+++ b/tests/unit/core/test_web_requests.py
@@ -131,8 +131,8 @@ def test_track_request_queue_time_invalid(header_value, tracked_request):
         "Root=1-{start_time}-12456789abcdef012345678",
         "Root=1-{start_time}-12456789abcdef012345678;CalledFrom=app",
         "Self=1-{start_time}-12456789abcdef012345678",
-        "Self=1-{start_time}-12456789abcdef012345678;Root=1-123-abcdef012345678912345678",  # noqa: E501
-        "Self=1-{start_time}-12456789abcdef012345678;Root=1-123-abcdef012345678912345678;CalledFrom=app",  # noqa: E501
+        "Self=1-{start_time}-12456789abcdef012345678;Root=1-123-abcdef012345678912345678",  # noqa: B950
+        "Self=1-{start_time}-12456789abcdef012345678;Root=1-123-abcdef012345678912345678;CalledFrom=app",  # noqa: B950
     ],
 )
 def test_track_amazon_request_queue_time_valid(header_value, tracked_request):
@@ -146,21 +146,25 @@ def test_track_amazon_request_queue_time_valid(header_value, tracked_request):
     queue_time_ns = tracked_request.tags["scout.queue_time_ns"]
     assert isinstance(queue_time_ns, int) and queue_time_ns > 0
 
+
 @pytest.mark.parametrize(
     "header_value",
     [
         "Root=1-{start_time}-12456789abcdef012345678",
         "Root=1-{start_time}-12456789abcdef012345678;CalledFrom=app",
         "Self=1-{start_time}-12456789abcdef012345678",
-        "Self=1-{start_time}-12456789abcdef012345678;Root=1-123-abcdef012345678912345678",  # noqa: E501
-        "Self=1-{start_time}-12456789abcdef012345678;Root=1-123-abcdef012345678912345678;CalledFrom=app",  # noqa: E501
+        "Self=1-{start_time}-12456789abcdef012345678;Root=1-123-abcdef012345678912345678",  # noqa: B950
+        "Self=1-{start_time}-12456789abcdef012345678;Root=1-123-abcdef012345678912345678;CalledFrom=app",  # noqa: B950
     ],
 )
-def test_track_amazon_request_queue_time_hexidecimal_valid(header_value, tracked_request):
-    start_time = format(int(datetime_to_timestamp(dt.datetime.utcnow())), 'x')
+def test_track_amazon_request_queue_time_hexidecimal_valid(
+    header_value, tracked_request
+):
+    start_time = format(int(datetime_to_timestamp(dt.datetime.utcnow())), "x")
 
     result = track_amazon_request_queue_time(
-        "Root=1-{start_time}-12456789abcdef012345678".format(start_time=start_time), tracked_request
+        "Root=1-{start_time}-12456789abcdef012345678".format(start_time=start_time),
+        tracked_request,
     )
 
     assert result is True