azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

Azure Monitor OpenTelemetry - Cloud Rolename does not consider slots

Open claria opened this issue 2 months ago • 11 comments

  • 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:

  1. Setup a function app (on dedicated plan)
  2. Add a dev slot
  3. Enable OpenTelemetry Settings
  4. 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.

claria avatar Nov 20 '25 18:11 claria

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.

github-actions[bot] avatar Nov 20 '25 20:11 github-actions[bot]

@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?

rads-1996 avatar Nov 24 '25 15:11 rads-1996

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.

github-actions[bot] avatar Nov 24 '25 15:11 github-actions[bot]

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:

Image

No results found....

Image

But if i search for logs without specifying the "-dev" slot i find the logs of the dev slot:

Image

claria avatar Nov 24 '25 16:11 claria

@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?

rads-1996 avatar Nov 24 '25 19:11 rads-1996

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.

github-actions[bot] avatar Nov 24 '25 19:11 github-actions[bot]

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 avatar Nov 24 '25 20:11 claria

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.

rads-1996 avatar Nov 25 '25 20:11 rads-1996

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.

github-actions[bot] avatar Dec 01 '25 15:12 github-actions[bot]

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!

github-actions[bot] avatar Dec 08 '25 21:12 github-actions[bot]

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 avatar Dec 09 '25 05:12 claria

@claria Do you mind sharing the full repro of your code so that we can investigate further.

rads-1996 avatar Dec 18 '25 21:12 rads-1996

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:

claria avatar Dec 23 '25 08:12 claria