diff --git a/core/src/main/java/com/microsoft/applicationinsights/internal/statsbeat/AttachStatsbeat.java b/core/src/main/java/com/microsoft/applicationinsights/internal/statsbeat/AttachStatsbeat.java index bc8d09bcf9c..0bb1ec63e5d 100644 --- a/core/src/main/java/com/microsoft/applicationinsights/internal/statsbeat/AttachStatsbeat.java +++ b/core/src/main/java/com/microsoft/applicationinsights/internal/statsbeat/AttachStatsbeat.java @@ -31,9 +31,9 @@ class AttachStatsbeat extends BaseStatsbeat { private static final String UNKNOWN_RP_ID = "unknown"; - private static final String WEBSITE_SITE_NAME = "appSrv_SiteName"; - private static final String WEBSITE_HOSTNAME = "appSrv_wsHost"; - private static final String WEBSITE_HOME_STAMPNAME = "appSrv_wsStamp"; + private static final String WEBSITE_SITE_NAME = "WEBSITE_SITE_NAME"; + private static final String WEBSITE_HOSTNAME = "WEBSITE_HOSTNAME"; + private static final String WEBSITE_HOME_STAMPNAME = "WEBSITE_HOME_STAMPNAME"; private volatile String resourceProviderId; private volatile MetadataInstanceResponse metadataInstanceResponse; @@ -75,10 +75,11 @@ void updateMetadataInstance(MetadataInstanceResponse response) { static String initResourceProviderId(ResourceProvider resourceProvider, MetadataInstanceResponse response) { switch (resourceProvider) { case RP_APPSVC: - // FIXME (heya) Need to test these env vars on App Services Linux & Windows - return System.getenv(WEBSITE_SITE_NAME) + "/" + System.getenv(WEBSITE_HOME_STAMPNAME) + "/" + System.getenv(WEBSITE_HOSTNAME); + // Linux App Services doesn't have WEBSITE_HOME_STAMPNAME yet. + // TODO (heya) make a feature request for Linux App Services Team to support this. + return System.getenv(WEBSITE_SITE_NAME) + "/" + System.getenv(WEBSITE_HOME_STAMPNAME); case RP_FUNCTIONS: - return System.getenv("WEBSITE_HOSTNAME"); + return System.getenv(WEBSITE_HOSTNAME); case RP_VM: if (response != null) { return response.getVmId() + "/" + response.getSubscriptionId(); diff --git a/core/src/test/java/com/microsoft/applicationinsights/internal/statsbeat/AttachStatsbeatTest.java b/core/src/test/java/com/microsoft/applicationinsights/internal/statsbeat/AttachStatsbeatTest.java index 67a377cc20b..0a356f62f28 100644 --- a/core/src/test/java/com/microsoft/applicationinsights/internal/statsbeat/AttachStatsbeatTest.java +++ b/core/src/test/java/com/microsoft/applicationinsights/internal/statsbeat/AttachStatsbeatTest.java @@ -52,11 +52,10 @@ public void testVirtualMachineResourceProviderId() throws IOException { @Test public void testAppSvcResourceProviderId() { - envVars.set("appSrv_SiteName", "test_site_name"); - envVars.set("appSrv_wsStamp", "test_stamp_name"); - envVars.set("appSrv_wsHost", "test_hostname"); + envVars.set("WEBSITE_SITE_NAME", "test_site_name"); + envVars.set("WEBSITE_HOME_STAMPNAME", "test_stamp_name"); - assertEquals("test_site_name/test_stamp_name/test_hostname", AttachStatsbeat.initResourceProviderId(ResourceProvider.RP_APPSVC, null)); + assertEquals("test_site_name/test_stamp_name", AttachStatsbeat.initResourceProviderId(ResourceProvider.RP_APPSVC, null)); } @Test