diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 23974ac9..1b2d055b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,10 +15,10 @@ jobs: strategy: matrix: os: [ ubuntu-22.04 ] - python: ["3.10"] + python: ["3.14"] manylinux_image: [ manylinux2014, manylinux_2_28 ] # Disable for platforms where pure Python wheels would be generated - cibw_skip: [ "pp38-* pp39-* pp310-* pp311-* pp312-* pp313-*" ] + cibw_skip: [ "pp38-* pp39-* pp310-* pp311-*" ] steps: - uses: actions/checkout@v4 @@ -61,7 +61,7 @@ jobs: - uses: actions/setup-python@v5 name: Install Python with: - python-version: "3.10" + python-version: "3.14" - name: Install cibuildwheel run: | @@ -83,7 +83,7 @@ jobs: runs-on: ubuntu-24.04 strategy: matrix: - python: ["3.10"] + python: ["3.14"] steps: - uses: actions/checkout@v4 @@ -91,14 +91,14 @@ jobs: name: Install Python with: python-version: ${{ matrix.python }} - - name: Install packaging tools + - name: Install build run: | - python -m pip install --upgrade pip setuptools importlib_metadata wheel + python -m pip install --upgrade pip build - name: Build Python pure Python wheel env: SCOUT_DISABLE_EXTENSIONS: "1" - run: python setup.py bdist_wheel + run: python -m build --wheel - uses: actions/upload-artifact@v4 with: @@ -114,10 +114,14 @@ jobs: - uses: actions/setup-python@v5 name: Install Python with: - python-version: "3.10" + python-version: "3.14" + + - name: Install build + run: | + python -m pip install --upgrade pip build - name: Build sdist - run: python setup.py sdist + run: python -m build --sdist - uses: actions/upload-artifact@v4 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index ef78f182..7c4e1f24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## Pending +### Fixed +- Attach `transaction_id` to error context to support querying for matching logs in errors service. ## [3.5.0] 2025-10-31 ### Added diff --git a/pyproject.toml b/pyproject.toml index 7fc76fcf..67d42768 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,16 +1,86 @@ -[tool.poetry] -name="scout_apm_python" -description = "Scout APM Python Agent" -readme = "README.md" -version = "0.1.0" -authors = ["Developers "] - [build-system] -requires = ["setuptools >= 40.6.0", "wheel"] +requires = ["setuptools>=61.0", "wheel"] build-backend = "setuptools.build_meta" +[project] +name = "scout_apm" +version = "3.5.0" +description = "Scout Application Performance Monitoring Agent" +readme = "README.md" +license = "MIT" +authors = [ + { name = "Scout", email = "support@scoutapm.com" } +] +requires-python = ">=3.8, <4" +keywords = ["apm", "performance monitoring", "development"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Framework :: Bottle", + "Framework :: Django", + "Framework :: Django :: 3.2", + "Framework :: Django :: 4.0", + "Framework :: Django :: 4.1", + "Framework :: Django :: 4.2", + "Framework :: Flask", + "Intended Audience :: Developers", + "Topic :: System :: Monitoring", + "Operating System :: MacOS", + "Operating System :: POSIX", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +dependencies = [ + "asgiref", + "psutil>=5", + "urllib3", + "certifi", + "wrapt>=1.10,<2.0", +] + +[project.urls] +Homepage = "https://github.com/scoutapp/scout_apm_python" +Documentation = "https://docs.scoutapm.com/#python-agent" +Changelog = "https://github.com/scoutapp/scout_apm_python/blob/master/CHANGELOG.md" + +[project.scripts] +core-agent-manager = "scout_apm.core.cli.core_agent_manager:main" + +[tool.setuptools] +zip-safe = false +package-dir = { "" = "src" } +ext-modules = [ + { name = "scout_apm.core._objtrace", sources = ["src/scout_apm/core/_objtrace.c"], optional = true } +] + +[tool.setuptools.packages.find] +where = ["src"] + [tool.black] target-version = ["py311"] [tool.isort] profile = "black" + +[tool.check-manifest] +ignore = [ + ".python-version", + "CHANGELOG.md", + "ci*", + "pytest.ini", + "tests*", + "tox.ini", +] + +[tool.coverage.run] +branch = true + +[tool.flake8] +max-line-length = 80 +select = ["C", "E", "F", "W", "B", "B950", "I", "T", "YTT"] +ignore = ["E203", "E501", "W503"] +accept-encodings = "utf-8" +ban-relative-imports = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index a802c15d..00000000 --- a/setup.cfg +++ /dev/null @@ -1,22 +0,0 @@ -[check-manifest] -ignore = - .python-version - CHANGELOG.md - ci* - pytest.ini - tests* - tox.ini - -[coverage:run] -branch = True - -[flake8] -# core -# black-recommended setup with flake8-bugbear -max-line-length = 80 -select = C,E,F,W,B,B950,I,T,YTT -ignore = E203,E501,W503 -# flake8-coding -accept-encodings = utf-8 -# flake8-tidy-imports -ban-relative-imports = true diff --git a/setup.py b/setup.py deleted file mode 100644 index 9389b4b1..00000000 --- a/setup.py +++ /dev/null @@ -1,89 +0,0 @@ -# coding=utf-8 - -import os -import sys - -from setuptools import Extension, find_packages, setup - -with open("README.md", "r") as fp: - long_description = fp.read() - -packages = find_packages("src") - -compile_extensions = ( - # Python 3+ - sys.version_info >= (3,) - # Not Jython - and not sys.platform.startswith("java") - # Not PyPy - and "__pypy__" not in sys.builtin_module_names - # Not explicitly disabled - and (os.environ.get("SCOUT_DISABLE_EXTENSIONS", "") == "") -) -if compile_extensions: - ext_modules = [ - Extension( - name=str("scout_apm.core._objtrace"), - sources=[str("src/scout_apm/core/_objtrace.c")], - optional=True, - ) - ] -else: - ext_modules = [] - -setup( - name="scout_apm", - version="3.5.0", - description="Scout Application Performance Monitoring Agent", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/scoutapp/scout_apm_python", - project_urls={ - "Documentation": "https://docs.scoutapm.com/#python-agent", - "Changelog": ( - "https://github.com/scoutapp/scout_apm_python/blob/master/CHANGELOG.md" - ), - }, - author="Scout", - author_email="support@scoutapm.com", - license="MIT", - zip_safe=False, - python_requires=">=3.8, <4", - packages=packages, - package_dir={str(""): str("src")}, - ext_modules=ext_modules, - entry_points={ - "console_scripts": [ - "core-agent-manager = scout_apm.core.cli.core_agent_manager:main" - ] - }, - install_requires=[ - "asgiref", - "psutil>=5", - "urllib3", - "certifi", - "wrapt>=1.10,<2.0", - ], - keywords=["apm", "performance monitoring", "development"], - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Framework :: Bottle", - "Framework :: Django", - "Framework :: Django :: 3.2", - "Framework :: Django :: 4.0", - "Framework :: Django :: 4.1", - "Framework :: Django :: 4.2", - "Framework :: Flask", - "Intended Audience :: Developers", - "Topic :: System :: Monitoring", - "License :: OSI Approved :: MIT License", - "Operating System :: MacOS", - "Operating System :: POSIX", - "Operating System :: POSIX :: Linux", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - ], -) diff --git a/src/scout_apm/core/error.py b/src/scout_apm/core/error.py index 71c77563..95260cf1 100644 --- a/src/scout_apm/core/error.py +++ b/src/scout_apm/core/error.py @@ -45,6 +45,7 @@ def send( context = {} context.update(tracked_request.tags) + context["transaction_id"] = tracked_request.request_id if custom_params: context["custom_params"] = custom_params diff --git a/tests/unit/core/test_error.py b/tests/unit/core/test_error.py index 72318efc..04bee17e 100644 --- a/tests/unit/core/test_error.py +++ b/tests/unit/core/test_error.py @@ -74,7 +74,7 @@ def test_monitor_ignore_exceptions(error_monitor_errors): "request_session": None, "environment": None, "request_components": None, - "context": {"spam": "foo"}, + "context": {"spam": "foo", "transaction_id": "sample_id"}, "host": None, "revision_sha": "", }, @@ -101,7 +101,7 @@ def test_monitor_ignore_exceptions(error_monitor_errors): "controller": "test-controller", "action": None, }, - "context": {"spam": "foo"}, + "context": {"spam": "foo", "transaction_id": "sample_id"}, "host": None, "revision_sha": "", }, @@ -128,7 +128,7 @@ def test_monitor_ignore_exceptions(error_monitor_errors): "controller": "DataView", "action": "detail", }, - "context": {"spam": "foo"}, + "context": {"spam": "foo", "transaction_id": "sample_id"}, "host": None, "revision_sha": "", }, @@ -155,7 +155,11 @@ def test_monitor_ignore_exceptions(error_monitor_errors): "controller": "test-controller", "action": "detail", }, - "context": {"spam": "foo", "custom_params": {"baz": 3}}, + "context": { + "spam": "foo", + "transaction_id": "sample_id", + "custom_params": {"baz": 3}, + }, "host": None, "revision_sha": "", }, @@ -247,7 +251,7 @@ def test_monitor_with_logged_payload( assert "ZeroDivisionError" in actual_message assert "division by zero" in actual_message assert ( - "tests/unit/core/test_error.py:227:in test_monitor_with_logged_payload" + "tests/unit/core/test_error.py:231:in test_monitor_with_logged_payload" in actual_message ) assert "sample.app" in actual_message