Skip to content

Commit c0b7339

Browse files
committed
Add a short section to turn on LiveMetrics
1 parent 4ad6a0d commit c0b7339

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ It's a good habit to specify a version when adding these: you can find the lates
137137

138138
Next, we configure the logging in `app.py` by adapting this sample code: <https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-opentelemetry/samples/tracing/http_flask.py>. This will log all requests to your Flask app (like every time you view the webpage) and the in-built exporter will send those logs to Application Insights.
139139

140-
> The environment variable gets picked up automatically so your code doesn't need to pass anything into `configure_azure_monitor()` call. Just make sure the application setting in Azure is the whole connection string, including `InstrumentationKey=`!
140+
> The environment variable gets picked up automatically so your code doesn't need to pass it directly into the `configure_azure_monitor()` call. Just make sure the application setting in Azure is the whole connection string, including `InstrumentationKey=`!
141141
142142
> Note that the auto-configuration relies on a strict ordering and flask needs to be _imported_ after we have run the configuration - so you may have code like:
143143
> ```python
@@ -190,6 +190,17 @@ Back in App Insights under Alerts you'll see an alert is raised.
190190
With the default settings this will take up to 5 minutes.
191191
If you set up emails above you'll start to receive these.
192192

193+
## Add Live Metrics
194+
195+
You may have noticed that even once the app is reporting logs to App Insights they lag the system slightly, e.g. searching your traces may not show logging statements from more than a minute ago. In many cases this is sufficient, but there may be times that we want lower latency on our stats - for example whilst monitoring a release.
196+
197+
Azure offers ["Live Metrics"](https://learn.microsoft.com/en-us/azure/azure-monitor/app/live-stream?tabs=otel) to help with this. Try turning that on now by adjusting your setup command to:
198+
```python
199+
configure_azure_monitor(enable_live_metrics = True)
200+
```
201+
202+
Once that's deployed, check out the "Live Metrics" tab (under the "Investigate" menu) in Application Insights. Again, it might take a few minutes to appear, but once it does you'll see that the traces on display are coming through within a second or two of being generated.
203+
193204
## Improve the queue
194205

195206
You'll now receive an email every 5 minutes until Jan 1st 3000.

0 commit comments

Comments
 (0)