opentelemetry-dotnet-contrib
opentelemetry-dotnet-contrib copied to clipboard
AppService resource when slot swap occurs
Is this a feature request or a bug?
Both!
What is the expected behavior?
Slot swaps may not be handled correctly as env variables won't change when slot swaps. https://github.com/microsoft/ApplicationInsights-dotnet/issues/1368 This was resolved in ApplicationInsights, but not sure if we can borrow that approach either, given Resource is static in OTel!
Additional Context
If this is not feasible to be fixed, it'd be good to call this out in the documentation.
The WEBSITE_SITE_NAME environment variable is a read-only field and does get updated correctly during a slot swap. This means that when swapping between two slots, such as from staging to production, the WEBSITE_SITE_NAME for each slot is updated to reflect its new state. As we rely on WEBSITE_SITE_NAME, we should not be impacted by this issue. Will get a confirmation from App Service and provide further update here.
The issue is most subtle. The service starts as Staging, and WEBSITE_SITE_NAME will fetch "Staging". Then the service flips to PROD without restart, so the updated value of WEBSITE_SITE_NAME is not going to be read again. ApplicationInsights relied on incoming header to detect this, but such a solution is not easy with OTel as Resource is fixed at app startup itself.