Skip to content

Commit

Permalink
Statsbeat: rpId is not sent corectly for AppSvc Linux and Windows (#1739
Browse files Browse the repository at this point in the history
)

* Fix appsvc rpId

* Fix unit tests
  • Loading branch information
heyams authored Jun 11, 2021
1 parent cea5fd9 commit d9e064e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d9e064e

Please sign in to comment.