Skip to content

Commit 6d3f044

Browse files
author
ks6088ts
committed
add configurations for OpenTelemetry
1 parent d19907d commit 6d3f044

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
## Azure Functions
88

9+
- [Azure Functions で OpenTelemetry を使用する](https://learn.microsoft.com/ja-jp/azure/azure-functions/opentelemetry-howto?tabs=app-insights&pivots=programming-language-python)
910
- [Using FastAPI Framework with Azure Functions](https://learn.microsoft.com/en-us/samples/azure-samples/fastapi-on-azure-functions/fastapi-on-azure-functions/)
1011
- [ks6088ts-labs/azure-functions-python](https://github.com/ks6088ts-labs/azure-functions-python)
1112

@@ -19,6 +20,7 @@
1920
## Application Insights
2021

2122
- [Application Insights の概要 - OpenTelemetry の可観測性](https://learn.microsoft.com/ja-jp/azure/azure-monitor/app/app-insights-overview)
23+
- [Azure Monitor OpenTelemetry を設定する](https://learn.microsoft.com/ja-jp/azure/azure-monitor/app/opentelemetry-configuration?tabs=python)
2224
- [open-telemetry/opentelemetry-python > Basic Trace](https://github.com/open-telemetry/opentelemetry-python/tree/main/docs/examples/basic_tracer)
2325
- [FastAPI のテレメトリデータを Azure Application Insights に送る](https://qiita.com/hoto17296/items/2f366dfabdbe3d1d4e97)
2426
- [【Azure Functions】 - Application Insights のログが表示されない問題](https://zenn.dev/headwaters/articles/ff19f7e1b99b44)

host.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"version": "2.0",
3+
"telemetryMode": "OpenTelemetry",
34
"extensions": {
45
"http": {
56
"routePrefix": ""

local.settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"IsEncrypted": false,
33
"Values": {
44
"APPLICATIONINSIGHTS_CONNECTION_STRING": "InstrumentationKey=YOUR_INSTRUMENTATION_KEY;IngestionEndpoint=https://japaneast-1.in.applicationinsights.azure.com/;LiveEndpoint=https://japaneast.livediagnostics.monitor.azure.com/;ApplicationId=YOUR_APPLICATION_ID",
5+
"OTEL_RESOURCE_ATTRIBUTES": "service.namespace=my-namespace,service.instance.id=my-instance",
6+
"OTEL_SERVICE_NAME": "my-helloworld-service",
7+
"OTEL_TRACES_SAMPLER_ARG": "1",
58
"FUNCTIONS_WORKER_RUNTIME": "python",
69
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
710
"AzureWebJobsStorage": ""

template_fastapi/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def server_request_hook(span: Span, scope: dict):
4040

4141
configure_azure_monitor(
4242
connection_string=AZURE_CONNECTION_STRING,
43+
# enable_live_metrics=True,
4344
server_request_hook=server_request_hook,
4445
)
4546
FastAPIInstrumentor.instrument_app(app)

0 commit comments

Comments
 (0)