Azure Monitor OpenTelemetry - Cloud Rolename does not consider slots
- Package Name: azure-monitor-opentelemetry
- Package Version: 1.8.2
- Operating System: Linux
- Python Version: 3.14.0
Describe the bug We have a function app on a dedicated plan with an additional dev slot.
We set
- host.json: telemetryMode --> OpentTelemetry
- Env Settings: PYTHON_APPLICATIONINSIGHTS_ENABLE_TELEMETRY -> true
All the logs (traces/requests/dependencies) are exported as expected and automatically. However, the logs/traces/requests exported from the application in the "dev" slot do not get the cloud Rolename "functionappname-dev" but also just "functionappname".
This leads to following problems
- If you click in azure portal --> function app --> function --> invocations, there is nothing shown, as it filters for "functionappname-dev". However, if you look in the requests table manually, you can find all requests (with wrong cloud rolename)
- Its harder to differentiate between logs from production slot and dev slot
To Reproduce Steps to reproduce the behavior:
- Setup a function app (on dedicated plan)
- Add a dev slot
- Enable OpenTelemetry Settings
- Generate some logs
Expected behavior Logs exported by each slot have a distinct cloud rolename as it is the case without opentelemetry
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @gulopesd @Haiying-MSFT @jairmyree @joshfree @KarishmaGhiya @KevinBlasko @kurtzeborn @pvaneck @scottaddie @srnagar @ToddKingMSFT.
@claria Do you mind sharing the screenshots of the logs that you are seeing? Also, could you confirm if this is a recent issue or is it something that has been the case for some time?
Hi @claria. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.
Here are some screenshots. I cannot tell you if this is a recent thing, i only recently added the dev slot and then observed it:
No results found....
But if i search for logs without specifying the "-dev" slot i find the logs of the dev slot:
@claria Thanks for sharing the screenshots. Could you also provide the requirements file, list any environment variables you’ve set (no need for their values), and include a reproducible code snippet so we can debug the issue?
Hi @claria. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.
Hi @rads-1996,
i had a look at the (experimental) resource detectors and think the issue is quite trivial:
- The Azure Functions Resource Detector sets the SERVICE_NAME based on WEBSITE_SITE_NAME
- WEBSITE_SITE_NAME does not include the slot name, which is stored in WEBSITE_SLOT_NAME
- AppInsights seems to be expect a combination of both (in case of used slots)
https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/functions.py#L41
Hi @rads-1996,
i had a look at the (experimental) resource detectors and think the issue is quite trivial:
- The Azure Functions Resource Detector sets the SERVICE_NAME based on WEBSITE_SITE_NAME
- WEBSITE_SITE_NAME does not include the slot name, which is stored in WEBSITE_SLOT_NAME
- AppInsights seems to be expect a combination of both (in case of used slots)
https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/functions.py#L41
@claria Thanks for these observations. The exporter code does not pass the WEBSITE_SLOT_NAME and neither does it support that currently. Just like the azure functions resource detector, it passes the WEBSITE_SITE_NAME.
Hi @claria. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.
Hi @claria, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!
This issue should stay open since this is a basic feature which is currently not available
- azure functions worker python does not consider WEBSITE_SLOT_NAME in resource detector (but does support OTEL_SERVICE_NAME)
- azure functions host does only use WEBSITE_SITE_NAME and does not support OTEL_SERVICE_NAME
@claria Do you mind sharing the full repro of your code so that we can investigate further.
I do not have a specific repro just for this. However, it is quite easy to reproduce. Just deploy any function app to a production and dev app slot and watch the exported cloud_RoleName in the logs e.g. in the requests table: