File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 15
15
- [ FastAPI で作成した API エンドポイントをモデル コンテキスト プロトコル (MCP) ツールとして公開してみる] ( https://dev.classmethod.jp/articles/fastapi-api-mcp/ )
16
16
- [ MCP Inspector > docs] ( https://modelcontextprotocol.io/docs/tools/inspector )
17
17
- [ MCP Inspector > codes] ( https://github.com/modelcontextprotocol/inspector )
18
+
19
+ ## Application Insights
20
+
21
+ - [ Application Insights の概要 - OpenTelemetry の可観測性] ( https://learn.microsoft.com/ja-jp/azure/azure-monitor/app/app-insights-overview )
22
+ - [ FastAPI のテレメトリデータを Azure Application Insights に送る] ( https://qiita.com/hoto17296/items/2f366dfabdbe3d1d4e97 )
Original file line number Diff line number Diff line change 3
3
ref. https://github.com/tadata-org/fastapi_mcp/blob/v0.3.4/examples/shared/apps/items.py
4
4
"""
5
5
6
+ from os import getenv
7
+
8
+ from azure .monitor .opentelemetry import configure_azure_monitor
6
9
from fastapi import FastAPI , HTTPException , Query
10
+ from opentelemetry .instrumentation .fastapi import FastAPIInstrumentor
7
11
from pydantic import BaseModel
8
12
9
13
app = FastAPI ()
10
14
15
+ # If AZURE_APPLICATIONINSIGHTS_CONNECTION_STRING exists, configure Azure Monitor
16
+ AZURE_CONNECTION_STRING = getenv ("AZURE_APPLICATIONINSIGHTS_CONNECTION_STRING" )
17
+ if AZURE_CONNECTION_STRING :
18
+ configure_azure_monitor (
19
+ connection_string = AZURE_CONNECTION_STRING ,
20
+ )
21
+ FastAPIInstrumentor .instrument_app (app )
22
+
11
23
12
24
class Item (BaseModel ):
13
25
id : int
You can’t perform that action at this time.
0 commit comments