Skip to content

Commit dbc8941

Browse files
authored
Add APPLICATIONINSIGHTS_SELF_DIAGNOSTICS_LEVEL (#1433)
1 parent 6356b76 commit dbc8941

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

agent/agent-bootstrap/src/main/java/com/microsoft/applicationinsights/agent/bootstrap/configuration/ConfigurationBuilder.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public class ConfigurationBuilder {
6060

6161
private static final String APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL = "APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL";
6262

63+
private static final String APPLICATIONINSIGHTS_SELF_DIAGNOSTICS_LEVEL = "APPLICATIONINSIGHTS_SELF_DIAGNOSTICS_LEVEL";
64+
6365
private static final String WEBSITE_SITE_NAME = "WEBSITE_SITE_NAME";
6466
private static final String WEBSITE_INSTANCE_ID = "WEBSITE_INSTANCE_ID";
6567

@@ -86,7 +88,7 @@ private static void loadLogCaptureEnvVar(Configuration config) {
8688
}
8789
}
8890

89-
private static void loadJmxMetrics(Configuration config) throws IOException {
91+
private static void loadJmxMetricsEnvVar(Configuration config) throws IOException {
9092
String jmxMetricsEnvVarJson = overlayWithEnvVar(APPLICATIONINSIGHTS_JMX_METRICS, (String)null);
9193

9294
// JmxMetrics env variable has higher precedence over jmxMetrics config from applicationinsights.json
@@ -98,6 +100,9 @@ private static void loadJmxMetrics(Configuration config) throws IOException {
98100
JsonAdapter<List<JmxMetric>> jsonAdapter = moshi.adapter(listOfJmxMetrics);
99101
config.jmxMetrics = jsonAdapter.fromJson(reader);
100102
}
103+
}
104+
105+
private static void addDefaultJmxMetricsIfNotPresent(Configuration config) {
101106
if (!jmxMetricExisted(config.jmxMetrics, "java.lang:type=Threading", "ThreadCount")) {
102107
JmxMetric threadCountJmxMetric = new JmxMetric();
103108
threadCountJmxMetric.name = "Current Thread Count";
@@ -187,8 +192,12 @@ static void overlayEnvVars(Configuration config) throws IOException {
187192

188193
config.sampling.percentage = overlayWithEnvVar(APPLICATIONINSIGHTS_SAMPLING_PERCENTAGE, config.sampling.percentage);
189194

195+
config.selfDiagnostics.level = overlayWithEnvVar(APPLICATIONINSIGHTS_SELF_DIAGNOSTICS_LEVEL, config.selfDiagnostics.level);
196+
190197
loadLogCaptureEnvVar(config);
191-
loadJmxMetrics(config);
198+
loadJmxMetricsEnvVar(config);
199+
200+
addDefaultJmxMetricsIfNotPresent(config);
192201
}
193202

194203
// visible for testing

0 commit comments

Comments
 (0)