跳转到主要内容

未提供项目描述

项目描述

Azure的Application insights for Starlette

这是一个用于在Starlette应用程序上使用Azure的Application insights的小模块。

如何使用

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)

在此阶段,任何请求、日志消息或异常都将推送到Azure的应用 insights。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

applicationinsights-starlette-0.1.0.tar.gz (1.9 kB 查看哈希)

上传时间:

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页