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

Report if agent was installed via Azure site extension #2094

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -205,6 +205,8 @@ public class MetricNames {

public static final String TIMEOUT_ASYNC = "Java/Timeout/asyncActivityNotStarted";

public static final String SUPPORTABILITY_AZURE_SITE_EXT_INSTALL_TYPE = "Supportability/Java/InstallType";

public static final String SUPPORTABILITY_JAVA_AGENTVERSION = "Supportability/Java/AgentVersion/{0}";

public static final String SUPPORTABILITY_HARVEST_SERVICE_RESPONSE_TIME = "Supportability/Harvest";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@

import com.google.common.annotations.VisibleForTesting;
import com.newrelic.agent.Agent;
import com.newrelic.agent.MetricNames;
import com.newrelic.agent.config.AgentConfig;
import com.newrelic.agent.samplers.MemorySampler;
import com.newrelic.api.agent.NewRelic;
import org.apache.commons.lang3.StringUtils;
import org.json.simple.JSONArray;
import org.json.simple.JSONStreamAware;

Expand Down Expand Up @@ -38,6 +41,7 @@ public class Environment implements JSONStreamAware, Cloneable {
private static final String LOGICAL_CORE_KEY = "Logical Processors";
private static final String TOTAL_MEMORY_MB = "Total Physical Memory (MB)";
private static final String SOLR_VERSION_KEY = "Solr Version";
private static final String AZURE_SITE_EXT_INSTALL_TYPE = "AzureSiteExtension";
private static final Pattern JSON_WORKAROUND = Pattern.compile("\\\\+$");

private final List<EnvironmentChangeListener> listeners = new CopyOnWriteArrayList<>();
Expand Down Expand Up @@ -122,6 +126,13 @@ public Environment(AgentConfig config, String logFilePath) {

addVariable("Framework", "java");

if (isAzureSiteExtenstionInstall()) {
// Yes this is intentional, since we only have a single installation type for the site extension
addVariable(AZURE_SITE_EXT_INSTALL_TYPE, AZURE_SITE_EXT_INSTALL_TYPE);
NewRelic.getAgent().getMetricAggregator().incrementCounter(MetricNames.SUPPORTABILITY_AZURE_SITE_EXT_INSTALL_TYPE + "/" +
AZURE_SITE_EXT_INSTALL_TYPE);
}

Number appServerPort = config.getProperty("appserver_port");
Integer serverPort = null;
if (appServerPort != null) {
Expand Down Expand Up @@ -274,4 +285,11 @@ public void setServerInfo(String serverInfo) {
setServerInfo(info[0], info[1]);
}
}

private boolean isAzureSiteExtenstionInstall() {
// Currently, the only "install type" we support is the Azure site extension, which is detected
// by the presence of a specific environment variable with a non-null/non-empty value
final String AZURE_SITE_EXT_VAR = "NEW_RELIC_METADATA_AZURE_APP_SERVICE_NAME";
return StringUtils.isNotBlank(System.getenv(AZURE_SITE_EXT_VAR));
}
}
Loading