Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add App Map to App service/function view support #1868

Merged
merged 3 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public class DefaultHeartBeatPropertyProvider implements HeartBeatPayloadProvide

private static final String PROCESS_SESSION_ID = "processSessionId";

private static final String OS_TYPE = "osType";

public DefaultHeartBeatPropertyProvider() {
defaultFields = new HashSet<>();
initializeDefaultFields(defaultFields);
Expand All @@ -86,6 +88,7 @@ public Boolean call() {
hasSetValues = true;
break;
case OS_VERSION:
case OS_TYPE:
provider.addHeartBeatProperty(fieldName, getOsVersion(), true);
hasSetValues = true;
break;
Expand Down Expand Up @@ -119,6 +122,7 @@ private static void initializeDefaultFields(Set<String> defaultFields) {
defaultFields.add(SDK_VERSION);
defaultFields.add(OS_VERSION);
defaultFields.add(PROCESS_SESSION_ID);
defaultFields.add(OS_TYPE);
}

/** Returns the JDK version being used by the application. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public class WebAppsHeartbeatProvider implements HeartBeatPayloadProviderInterfa

private static final String WEBSITE_HOME_STAMPNAME = "appSrv_wsStamp";

private static final String WEBSITE_OWNER_NAME = "appSrv_wsOwner";

kryalama marked this conversation as resolved.
Show resolved Hide resolved
private static final String WEBSITE_RESOURCE_GROUP = "appSrv_ResourceGroup";

// Only populated in Azure functions
private static final String WEBSITE_SLOT_NAME = "appSrv_SlotName";

/** Constructor that initializes fields and load environment variables. */
public WebAppsHeartbeatProvider() {
defaultFields = new HashSet<>();
Expand Down Expand Up @@ -98,6 +105,30 @@ public Boolean call() {
provider.addHeartBeatProperty(fieldName, websiteHomeStampName, true);
hasSetValues = true;
break;
case WEBSITE_OWNER_NAME:
String websiteOwnerName = getWebsiteOwnerName();
if (websiteOwnerName == null) {
break;
}
provider.addHeartBeatProperty(fieldName, websiteOwnerName, true);
hasSetValues = true;
kryalama marked this conversation as resolved.
Show resolved Hide resolved
break;
case WEBSITE_RESOURCE_GROUP:
String websiteResourceGroup = getWebsiteResourceGroup();
if (websiteResourceGroup == null) {
kryalama marked this conversation as resolved.
Show resolved Hide resolved
break;
}
provider.addHeartBeatProperty(fieldName, websiteResourceGroup, true);
hasSetValues = true;
break;
case WEBSITE_SLOT_NAME:
String websiteSlotName = getWebsiteSlotName();
if (websiteSlotName == null) {
kryalama marked this conversation as resolved.
Show resolved Hide resolved
break;
}
provider.addHeartBeatProperty(fieldName, websiteSlotName, true);
hasSetValues = true;
break;
default:
logger.trace("Unknown web apps property encountered");
break;
Expand All @@ -118,6 +149,9 @@ private static void initializeDefaultFields(Set<String> defaultFields) {
defaultFields.add(WEBSITE_SITE_NAME);
defaultFields.add(WEBSITE_HOSTNAME);
defaultFields.add(WEBSITE_HOME_STAMPNAME);
defaultFields.add(WEBSITE_OWNER_NAME);
defaultFields.add(WEBSITE_RESOURCE_GROUP);
defaultFields.add(WEBSITE_SLOT_NAME);
}

/** Returns the name of the website by reading environment variable. */
Expand All @@ -135,6 +169,21 @@ private String getWebsiteHomeStampName() {
return environmentMap.get("WEBSITE_HOME_STAMPNAME");
}

/** Returns the website owner name by reading environment variable. */
private String getWebsiteOwnerName() {
return environmentMap.get("WEBSITE_OWNER_NAME");
}

/** Returns the website resource group by reading environment variable. */
private String getWebsiteResourceGroup() {
return environmentMap.get("WEBSITE_RESOURCE_GROUP");
}

/** Returns the website slot name by reading environment variable. */
private String getWebsiteSlotName() {
return environmentMap.get("WEBSITE_SLOT_NAME");
}

/**
* This method updates the environment variable at every call to add the payload, to cover hotswap
* scenarios.
Expand Down