Skip to main content

Azure's Application insights for Starlette

This is a small module to use Azure's Application insights on a Starlette application.

How to use:

from starlette.applications import Starlette
from starlette.middleware.base import BaseHTTPMiddleware

app = Starlette()

from .appinsight import AppInsights
insights = AppInsights('<instrumentation_key>')

app.add_exception_handler(Exception, insights.exception_handler)

app.add_middleware(BaseHTTPMiddleware, dispatch=insights.request_middleware)
app.add_middleware(BaseHTTPMiddleware, dispatch=insights.flush_middleware)

# or any variation of how you log in your app
logging.getLogger(__name__).addHandler(insights.log_handler)


@app.route('/')
async def homepage(request):
    return JSONResponse({'hello': 'world'})

if __name__ == '__main__':
    uvicorn.run(app, host='0.0.0.0', port=8000)

At this point, any request, log message or exception will be pushed to Azure's application insights.

Metadata

Release files for applicationinsights-starlette 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for applicationinsights-starlette 0.1.0
File Size Uploaded Provenance Actions
applicationinsights-starlette-0.1.0.tar.gz 1.9 kB Without provenance Details for applicationinsights-starlette-0.1.0.tar.gz

Release files / applicationinsights-starlette-0.1.0.tar.gz

Download URL applicationinsights-starlette-0.1.0.tar.gz
Size 1.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c762e264d9c01760c82328b5cf5b04251208007943d601e371417b1b74c4d0d7
BLAKE2b-256 checksum
How to use checksums
adbf492518cec828292639d58fa0f982bca1fab223551ce95d73c96812f69ade
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Security for applicationinsights-starlette 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page