Python on macOS
  • 1 Minute to read
  • Dark
    Light
  • PDF

Python on macOS

  • Dark
    Light
  • PDF

Article Summary

Prerequisites:
  • Supported Python Technologies
    Since Prefix and Retrace share the same modules/profiler, the supported frameworks between the two products will be the same in most cases.

1. Download and install the Prefix installation file:

Check out the Getting Started Prefix page to download and install Prefix on your workstation.

2. Get the latest Stackify Python Profiler for Prefix:

Install the Stackify Python APM agent using pip:

$ pip install stackify-python-apm

You may install your stackify-python-apm by adding it to your project's requirements.txt file.

3. Configure the Application to use the Profiler with Prefix Enabled:

Django

  • Add stackifyapm.contrib.django to INSTALLED_APPS in your settings.py:
INSTALLED_APPS = [  
            ... 
            'stackifyapm.contrib.django',
            ...
     ]
  • Add our tracing middleware to MIDDLEWARE in your settings.py:
MIDDLEWARE = [
            ...
            'stackifyapm.contrib.django.middleware.TracingMiddleware', 
            ...
     ]
  • Customize Application Name and Environment Name in your settings.py file
  • Add PREFIX_ENABLED = True to the settings.py file.
APPLICATION_NAME = 'Python Application'
ENVIRONMENT = 'Production'
PREFIX_ENABLED = True

Flask

  • Update and insert the apm settings to your application:
from stackifyapm.contrib.flask import StackifyAPM

app = Flask(__name__)
StackifyAPM(app)
  • Customize Application Name and Environment Name configuration
  • Add app.config['PREFIX_ENABLED'] = True to the configuration
app.config['APPLICATION_NAME'] = 'Python Application'
app.config['ENVIRONMENT'] = 'Production'
app.config['PREFIX_ENABLED'] = True
StackifyAPM(app)

Pyramid

  • Update and insert the apm settings to your application:
    Include our pyramid tween integration:
with Configurator() as config:
config.include('stackifyapm.contrib.pyramid')

Or explicit tween configuration:

with Configurator({
    'pyramid.tweens': ['stackifyapm.contrib.pyramid.stackifyapm_tween_factory'].
}) as config:
    ...
  • Customize Application Name and Environment Name configuration
  • Add app.config['PREFIX_ENABLED'] = True to the configuration
with Configurator({
    'APPLICATION_NAME': 'Python Application',
    'ENVIRONMENT': 'Production',
    'PREFIX_ENABLED': True,
}) as config:
    config.include('stackifyapm.contrib.pyramid')

4. Verify application requests show up in Prefix


Was this article helpful?