Scout Python Application Performance Monitoring (APM) Agent
aaugustin and dlanderson Support Python 2.7 - phase 1 - cleanup (#132)
* Test with the latest releases of CPython and PyPy.
* DRY between .python-version and Makefile.
* Update Python / Django support matrix.

Rationale:
- include all currently supported versions
- keep Django 1.8 LTS (sigh) except for Python 3.2 and 3.3

Source:
https://docs.djangoproject.com/en/stable/faq/install/#what-python-version-can-i-use-with-django
https://docs.djangoproject.com/en/1.11/faq/install/#what-python-version-can-i-use-with-django

* Remove useless shebang.
* Prevent a spurious check-manifest error.
* Remove unnecessary dependencies.
* Uniformize import style.
* Remove comments that don't add value.
* Remove comments describing import groups.
* Add isort configuration.
* Run isort.
* Enforce isort in `tox -e check`.
* Replace `make isort` with `make style`...
* Adapt flake8 configuration for black.
* Run black.
* Enforce black in `tox -e check`.
* Add black to `make style`.
* Enable __future__ features consistently.
* Remove useless parentheses.
* Fix bare except: statements.
* Use idiomatic truthiness checks.
* Fix all flake8 warnings.
* Format logging strings lazily.
* Remove unused module.
* Simplify usage of the subprocess module.

Catch OSError instead of FileNotFoundError: it works on Python 2.7 & 3.

* Classes that don't have a parent inherit object.

Some did, most didn't. Normalize towards inheriting object because that
will work on Python 2.7 and 3.

* Streamline AppMetadata.data.

* Avoid filter(lambda...) and map(lambda...).

List comprehensions or explicit constructs are preferred.

* Remove bootstrap task.

Its purpose was forgotten -- perhaps a trace of wrestling with CI.

* Remove unnecessary files from sdist.

Only keep source code and license.
Latest commit eebf6c9 Nov 19, 2018

README.md

Scout Python APM Agent

Monitor the performance of Python Django apps, Flask apps, and Celery workers with Scout's Python APM Agent. Detailed performance metrics and transaction traces are collected once the scout-apm package is installed and configured.

screenshot

Requirements

Python Versions:

Scout APM works with the following frameworks:

For frameworks not listed above, you can use the agent's instrumentation API. See the Python help docs for more information.

Quick Start

A Scout account is required. Signup for Scout.

pip install scout-apm

Django

# settings.py
INSTALLED_APPS = (
  'scout_apm.django', # should be listed first
  # ... other apps ...
)

# Scout settings
SCOUT_MONITOR = True
SCOUT_KEY     = "[AVAILABLE IN THE SCOUT UI]"
SCOUT_NAME    = "A FRIENDLY NAME FOR YOUR APP"

Flask

These instructions assume the app uses SQLAlchemy. If that isn't the case, remove the referencing lines.

from scout_apm.flask import ScoutApm
from scout_apm.flask.sqlalchemy import instrument_sqlalchemy

# Setup a flask 'app' as normal

## Attaches ScoutApm to the Flask App
ScoutApm(app)

## Instrument the SQLAlchemy handle
instrument_sqlalchemy(db)

# Scout settings
app.config['SCOUT_MONITOR'] = True
app.config['SCOUT_KEY']     = "[AVAILABLE IN THE SCOUT UI]"
app.config['SCOUT_NAME']    = "A FRIENDLY NAME FOR YOUR APP"

Pyramid

Add the SCOUT_* settings to the Pyramid config, and then config.include('scout_apm.pyramid')

import scout_apm.pyramid

if __name__ == '__main__':
    with Configurator() as config:
        config.add_settings(
            SCOUT_KEY = '...',
            SCOUT_MONITOR = True,
            SCOUT_NAME = 'My Pyramid App'
        )
        config.include('scout_apm.pyramid')

        # Rest of your config...

Bottle

from scout_apm.bottle import ScoutPlugin

app = bottle.default_app()
app.config.update({'scout.name': "YOUR_APP_NAME",
                   'scout.key': "YOUR_KEY"
                   'scout.monitor': "true"})

scout = ScoutPlugin()
bottle.install(scout)

For full installation instructions, including information on configuring Scout via environment variables, see our Python docs.

Documentation

For full installation and troubleshooting documentation, visit our help site.

Support

Please contact us at support@scoutapp.com or create an issue in this repo.