File tree Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change
1
+ # Azure Application Insights
2
+ APPLICATIONINSIGHTS_CONNECTION_STRING = " InstrumentationKey=xxx;IngestionEndpoint=https://xxx.in.applicationinsights.azure.com/;LiveEndpoint=https://xxx.livediagnostics.monitor.azure.com/;ApplicationId=xxx"
3
+ OTEL_RESOURCE_ATTRIBUTES = " service.namespace=local-template-fastapi-namespace,service.instance.id=local-template-fastapi-instance"
4
+ OTEL_SERVICE_NAME = " local-template-fastapi-service"
5
+ OTEL_TRACES_SAMPLER_ARG = " 1"
6
+
1
7
# Azure OpenAI Service
2
8
AZURE_OPENAI_ENDPOINT = " https://<YOUR_AOAI_NAME>.openai.azure.com/"
3
9
AZURE_OPENAI_API_KEY = " <YOUR_API_KEY>"
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ def server_request_hook(span: Span, scope: dict):
38
38
39
39
configure_azure_monitor (
40
40
connection_string = AZURE_CONNECTION_STRING ,
41
- # enable_live_metrics=True,
41
+ enable_live_metrics = True ,
42
42
server_request_hook = server_request_hook ,
43
43
)
44
44
FastAPIInstrumentor .instrument_app (app )
Original file line number Diff line number Diff line change
1
+ import asyncio
1
2
import random
2
- import time
3
3
4
4
from fastapi import APIRouter , HTTPException
5
5
@@ -73,9 +73,10 @@ async def heavy_sync_with_sleep(sleep_ms: int):
73
73
74
74
with tracer .start_as_current_span ("parent" ):
75
75
logger .debug (f"Starting sleep for { sleep_ms } milliseconds" )
76
- time .sleep (sleep_ms / 1000.0 )
76
+ await asyncio .sleep (sleep_ms / 1000.0 ) # Convert milliseconds to seconds
77
77
with tracer .start_as_current_span ("child" ):
78
78
logger .debug ("Child span execution" )
79
+ await asyncio .sleep (sleep_ms / 1000.0 ) # Simulate additional processing
79
80
80
81
logger .info (f"Completed sleep operation for { sleep_ms } ms" )
81
82
return {
You can’t perform that action at this time.
0 commit comments