applicationinsights.requests module

WSGIApplication class

class applicationinsights.requests.WSGIApplication(instrumentation_key, wsgi_application, *args, **kwargs)[source]

This class represents a WSGI wrapper that enables request telemetry for existing WSGI applications. The request telemetry will be sent to Application Insights service using the supplied instrumentation key.

from applicationinsights.requests import WSGIApplication
from paste.httpserver import serve
from pyramid.response import Response
from pyramid.view import view_config

@view_config()
def hello(request):
    return Response('Hello')

if __name__ == '__main__':
    from pyramid.config import Configurator
    config = Configurator()
    config.scan()
    app = config.make_wsgi_app()

    # Enable Application Insights middleware
    app = WSGIApplication('<YOUR INSTRUMENTATION KEY GOES HERE>', app, common_properties={'service': 'hello_world_service'})

    serve(app, host='0.0.0.0')
flush()[source]

Flushes the queued up telemetry to the service.