Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -5,6 +5,7 @@

import static java.util.concurrent.TimeUnit.SECONDS;

import com.azure.monitor.opentelemetry.autoconfigure.implementation.AzureMonitorExporterProviderKeys;
import com.microsoft.applicationinsights.agent.internal.configuration.Configuration;
import com.microsoft.applicationinsights.agent.internal.legacyheaders.DelegatingPropagatorProvider;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
Expand Down Expand Up @@ -115,9 +116,25 @@ public Map<String, String> apply(ConfigProperties otelConfig) {
}

String metricsExporter = otelConfig.getString("otel.metrics.exporter");
if (metricsExporter == null) {
// this overrides the default "otlp" so the exporter can be configured later
properties.put("otel.metrics.exporter", "none");
String azureMonitorName = AzureMonitorExporterProviderKeys.EXPORTER_NAME;
boolean metricsToLogAnalyticsEnabled =
otelConfig.getBoolean("applicationinsights.metrics.to.loganalytics.enabled", false);
Comment thread
xiang17 marked this conversation as resolved.
Outdated

if (metricsToLogAnalyticsEnabled) {
if (metricsExporter == null
|| metricsExporter.isEmpty()
|| metricsExporter.equalsIgnoreCase("none")) {
// enable Azure Monitor metrics exporter by default when flag is enabled
properties.put("otel.metrics.exporter", azureMonitorName);
} else if (!metricsExporter.contains(azureMonitorName)) {
// ensure Azure Monitor exporter is included when flag is enabled
properties.put("otel.metrics.exporter", metricsExporter + "," + azureMonitorName);
}
} else {
if (metricsExporter == null) {
// preserve previous behavior: override default "otlp" so exporter can be configured later
properties.put("otel.metrics.exporter", "none");
}
}

String logsExporter = otelConfig.getString("otel.logs.exporter");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ public class SmokeTestExtension
private final boolean useOtlpEndpoint;

public static SmokeTestExtension create() {
return builder().build();
SmokeTestExtensionBuilder b = builder();
String metricsToLogAnalytics =
System.getenv("APPLICATIONINSIGHTS_METRICS_TO_LOGANALYTICS_ENABLED");
if (metricsToLogAnalytics != null && metricsToLogAnalytics.equalsIgnoreCase("true")) {
b.setEnvVar("APPLICATIONINSIGHTS_METRICS_TO_LOGANALYTICS_ENABLED", "true");
}
return b.build();
}

public static SmokeTestExtensionBuilder builder() {
Expand Down