Repository: scoutapp/scout_apm_python
Pull request #686 (2021-09-27 17:16:35)

[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/mgedmin/check-manifest: 0.46 → 0.47](https://github.com/mgedmin/check-manifest/compare/0.46...0.47)



Patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 454573d..bd8c650 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -33,7 +33,7 @@ repos:
     - flake8-tidy-imports
     - flake8-print
 - repo: https://github.com/mgedmin/check-manifest
-  rev: "0.46"
+  rev: "0.47"
   hooks:
   - id: check-manifest
     args: [--no-build-isolation]
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 51ee1dc..732b8a9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@
 ### Added
 - Rework release Github action to utilize newer versions of cibuildwheel when available.
 - Added `search_mvt` instrumentation for ElasticSearch 7.15.0.
+- Default core agent version to v1.3.1. Support ARM64 core agent architecture.
+  ([Issue #683](https://github.com/scoutapp/scout_apm_python/issues/683))
 
 ### Fixed
 
diff --git a/src/scout_apm/core/config.py b/src/scout_apm/core/config.py
index 3c9d97f..939db86 100644
--- a/src/scout_apm/core/config.py
+++ b/src/scout_apm/core/config.py
@@ -220,7 +220,7 @@ class Defaults(object):
             "core_agent_log_level": "info",
             "core_agent_permissions": 700,
             "core_agent_socket_path": "tcp://127.0.0.1:6590",
-            "core_agent_version": "v1.3.0",  # can be an exact tag name, or 'latest'
+            "core_agent_version": "v1.3.1",  # 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: B950
             "errors_batch_size": 5,
diff --git a/src/scout_apm/core/platform_detection.py b/src/scout_apm/core/platform_detection.py
index fea8a6c..8cc1533 100644
--- a/src/scout_apm/core/platform_detection.py
+++ b/src/scout_apm/core/platform_detection.py
@@ -8,14 +8,28 @@ def is_valid_triple(triple):
     values = triple.split("-", 1)
     return (
         len(values) == 2
-        and values[0] in ("i686", "x86_64", "unknown")
+        and values[0] in ("i686", "x86_64", "aarch64", "unknown")
         and values[1]
         in ("unknown-linux-gnu", "unknown-linux-musl", "apple-darwin", "unknown")
+        # Validate _apple_darwin_aarch64_override was applied.
+        and triple != "aarch64-apple-darwin"
     )
 
 
+def _apple_darwin_aarch64_override(triple):
+    """
+    If using M1 ARM64 machine, still use x86_64.
+    See https://github.com/scoutapp/scout_apm_python/issues/683
+    """
+    if triple == "aarch64-apple-darwin":
+        return "x86_64-apple-darwin"
+    return triple
+
+
 def get_triple():
-    return "{arch}-{platform}".format(arch=get_arch(), platform=get_platform())
+    return _apple_darwin_aarch64_override(
+        "{arch}-{platform}".format(arch=get_arch(), platform=get_platform())
+    )
 
 
 def get_arch():
@@ -27,6 +41,8 @@ def get_arch():
         return "i686"
     elif arch == "x86_64":
         return "x86_64"
+    elif arch == "aarch64":
+        return "aarch64"
     else:
         return "unknown"
 


Test patch:
diff --git a/tests/unit/core/test_platform_detection.py b/tests/unit/core/test_platform_detection.py
index 141a825..37808bc 100644
--- a/tests/unit/core/test_platform_detection.py
+++ b/tests/unit/core/test_platform_detection.py
@@ -15,15 +15,39 @@ def test_get_triple():
     assert platform_detection.is_valid_triple(triple)
 
 
+@pytest.mark.parametrize(
+    "machine, system, result",
+    [
+        ("x86_64", "Darwin", "x86_64-apple-darwin"),
+        ("aarch64", "Darwin", "x86_64-apple-darwin"),
+        ("x86_64", "Linux", "x86_64-unknown-linux-musl"),
+        ("aarch64", "Linux", "aarch64-unknown-linux-musl"),
+    ],
+)
+@mock.patch("platform.machine")
+@mock.patch("platform.system")
+def test_aarch64_apple_darwin_override(
+    platform_system, platform_machine, machine, system, result
+):
+    platform_machine.return_value = machine
+    platform_system.return_value = system
+    assert platform_detection.get_triple() == result
+
+
 @pytest.mark.parametrize(
     "triple, validity",
     [
         ("x86_64-apple-darwin", True),
         ("i686-unknown-linux-gnu", True),
+        ("aarch64-unknown-linux-gnu", True),
+        ("aarch64-unknown-linux-musl", True),
+        ("x86_64-apple-darwin", True),
         ("unknown-unknown-linux-musl", True),
         ("", False),
         ("unknown", False),
         ("---", False),
+        ("i686-apple-darwin", True),
+        ("aarch64-apple-darwin", False),
     ],
 )
 def test_is_valid_triple(triple, validity):
@@ -35,6 +59,7 @@ def test_is_valid_triple(triple, validity):
     [
         ("i686", "i686"),
         ("x86_64", "x86_64"),
+        ("aarch64", "aarch64"),
         ("i386", "unknown"),
         ("arm", "unknown"),
         ("", "unknown"),