Python agent and FastCGI web server

The New Relic Python agent can be used with FastCGI in conjunction with flup. There are no known special requirements or restrictions, so you can follow the general integration procedures in Install New Relic for Python.

Admin script integration example

For FastCGI, the web application is always managed as an external process. If you have integrated the FastCGI/WSGI adapter for flup, as in:

#!/usr/bin/env python

import sys
from fcgi import WSGIServer

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

ret = WSGIServer(application).run()

and if you are starting your FastCGI process as a Python script directly with Python as python app.py, instead run:

NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program python app.py

For more on the install process, see Install New Relic for Python.

For more help

Join the discussion about Python in the New Relic Online Technical Community! The Technical Community is a public platform to discuss and troubleshoot your New Relic toolset.

If you need additional help, get support at support.newrelic.com.