Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8d5ea3c
enduser.id and enduser.pseudo.id
trask Aug 29, 2025
8e06ec7
session.id
trask Aug 28, 2025
54db0e9
Remove dependency on autoconfigure SemanticAttributes copy
trask Aug 29, 2025
b86ed3e
Update to Azure SDK latest snapshot
trask Aug 29, 2025
18c760b
test
trask Sep 20, 2025
b4110a5
check for exporter env vars and pass to metricdatamapper
harsimar Sep 11, 2025
69ddfda
still need to test these changes & build upon update sdk pr
harsimar Sep 12, 2025
a262c54
fixing some existing tests (not done yet), merge in sdk update change…
harsimar Sep 16, 2025
18253f6
add one test, it is currently failing
harsimar Sep 16, 2025
b5a3e27
add one more test, will debug later
harsimar Sep 16, 2025
f1e6088
remove setting env var and pass parameter instead
xiang17 Sep 19, 2025
82c52a9
fix code style errors
xiang17 Sep 19, 2025
4bf35ed
Fix compile errors
xiang17 Sep 19, 2025
27083d7
Fix style error
xiang17 Sep 19, 2025
e793ce5
Fix test assert to False because env vars are not set
xiang17 Sep 19, 2025
3e3b0f7
Fix
trask Sep 19, 2025
b55551e
Fix
trask Sep 19, 2025
f14de7e
Make script run locally better
trask Sep 19, 2025
154539b
Fix
trask Sep 19, 2025
7a053fb
SNAPSHOT
trask Sep 19, 2025
0f009a6
Fix
trask Sep 20, 2025
9aec7b3
Fix OpenTelemetryMetricTestToAmw and GrpcTest
xiang17 Sep 20, 2025
e549eb4
Fix
trask Sep 20, 2025
6933c4f
Fix sporadically failing JmxMetricTest
trask Sep 20, 2025
1a15a6f
Merge branch 'trask/update-to-azure-sdk-latest' into harskaur/aksMetrics
xiang17 Sep 20, 2025
ed8003b
remove unused variable
xiang17 Sep 20, 2025
dabe368
Remove useOtlpViaEnvVars and use useOtlpEndpoint
xiang17 Sep 22, 2025
1cef19f
Attempt to fix OtlpTest
xiang17 Sep 22, 2025
c80af29
./gradlew :smoke-tests:apps:HttpPreaggregatedMetrics:spotlessApply
xiang17 Sep 22, 2025
0ebf627
./gradlew :smoke-tests:apps:OpenTelemetryMetric:spotlessApply
xiang17 Sep 24, 2025
62fb98c
Change branch to main
xiang17 Sep 24, 2025
0e4ddbf
Remove inst/azure-monitor-opentelemetry-autoconfigure.properties. Rem…
xiang17 Sep 25, 2025
bf6140c
Merge branch 'main' into harskaur/aksMetrics
xiang17 Sep 26, 2025
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
13 changes: 8 additions & 5 deletions .github/scripts/build-azure-monitor-dependency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ echo "Installed version: $INSTALLED_VERSION"
# Clean up
echo "Cleaning up..."
cd ..
rm -rf azure-sdk-temp
if [ -n "$CI" ]; then
rm -rf azure-sdk-temp
fi

# Update dependency versions in the current project
echo "Updating dependency versions in project files..."
Expand All @@ -52,10 +54,11 @@ fi
./gradlew resolveAndLockAll --write-locks
./gradlew generateLicenseReport --no-build-cache

# this is needed to make license report pass
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git commit -a -m "update azure-monitor-opentelemetry-autoconfigure dependency to $INSTALLED_VERSION"
if [ -n "$CI" ]; then
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git commit -a -m "update azure-monitor-opentelemetry-autoconfigure dependency to $INSTALLED_VERSION"
fi

echo "azure-monitor-opentelemetry-autoconfigure dependency build completed successfully"
echo "All project files updated to use version: $INSTALLED_VERSION"
2 changes: 1 addition & 1 deletion agent/agent-tooling/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {
implementation(project(":agent:agent-profiler:agent-diagnostics"))
implementation(project(":etw:java"))

implementation("com.azure:azure-monitor-opentelemetry-autoconfigure:1.3.0")
implementation("com.azure:azure-monitor-opentelemetry-autoconfigure:1.4.0")
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-bootstrap")
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling")
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling-java9")
Expand Down
17 changes: 8 additions & 9 deletions agent/agent-tooling/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ ch.qos.logback.contrib:logback-json-classic:0.1.5=runtimeClasspath
ch.qos.logback.contrib:logback-json-core:0.1.5=runtimeClasspath
ch.qos.logback:logback-classic:1.3.15=runtimeClasspath
ch.qos.logback:logback-core:1.3.15=runtimeClasspath
com.azure:azure-core-http-netty:1.16.0=runtimeClasspath
com.azure:azure-core:1.56.0=runtimeClasspath
com.azure:azure-core-http-netty:1.16.1=runtimeClasspath
com.azure:azure-core:1.56.1=runtimeClasspath
com.azure:azure-identity:1.17.0=runtimeClasspath
com.azure:azure-json:1.5.0=runtimeClasspath
com.azure:azure-monitor-opentelemetry-autoconfigure:1.3.0=runtimeClasspath
com.azure:azure-monitor-opentelemetry-autoconfigure:1.4.0=runtimeClasspath
com.azure:azure-sdk-bom:1.2.38=runtimeClasspath
com.azure:azure-storage-blob:12.31.2=runtimeClasspath
com.azure:azure-storage-common:12.30.2=runtimeClasspath
Expand Down Expand Up @@ -48,8 +48,8 @@ io.netty:netty-resolver-dns-classes-macos:4.2.4.Final=runtimeClasspath
io.netty:netty-resolver-dns-native-macos:4.2.4.Final=runtimeClasspath
io.netty:netty-resolver-dns:4.2.4.Final=runtimeClasspath
io.netty:netty-resolver:4.2.4.Final=runtimeClasspath
io.netty:netty-tcnative-boringssl-static:2.0.72.Final=runtimeClasspath
io.netty:netty-tcnative-classes:2.0.72.Final=runtimeClasspath
io.netty:netty-tcnative-boringssl-static:2.0.73.Final=runtimeClasspath
io.netty:netty-tcnative-classes:2.0.73.Final=runtimeClasspath
io.netty:netty-transport-classes-epoll:4.2.4.Final=runtimeClasspath
io.netty:netty-transport-classes-kqueue:4.2.4.Final=runtimeClasspath
io.netty:netty-transport-native-epoll:4.2.4.Final=runtimeClasspath
Expand All @@ -71,10 +71,9 @@ io.opentelemetry:opentelemetry-sdk-logs:1.53.0=runtimeClasspath
io.opentelemetry:opentelemetry-sdk-metrics:1.53.0=runtimeClasspath
io.opentelemetry:opentelemetry-sdk-trace:1.53.0=runtimeClasspath
io.opentelemetry:opentelemetry-sdk:1.53.0=runtimeClasspath
io.opentelemetry:opentelemetry-semconv:0.14.1=runtimeClasspath
io.projectreactor.netty:reactor-netty-core:1.2.8=runtimeClasspath
io.projectreactor.netty:reactor-netty-http:1.2.8=runtimeClasspath
io.projectreactor:reactor-core:3.7.8=runtimeClasspath
io.projectreactor.netty:reactor-netty-core:1.2.9=runtimeClasspath
io.projectreactor.netty:reactor-netty-http:1.2.9=runtimeClasspath
io.projectreactor:reactor-core:3.7.9=runtimeClasspath
net.java.dev.jna:jna-platform:5.17.0=runtimeClasspath
net.java.dev.jna:jna:5.17.0=runtimeClasspath
net.minidev:accessors-smart:2.5.2=runtimeClasspath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

package com.microsoft.applicationinsights.agent.internal.configuration;

import com.azure.monitor.opentelemetry.autoconfigure.implementation.SemanticAttributes;
import com.azure.monitor.opentelemetry.autoconfigure.implementation.statsbeat.RpAttachType;
import com.azure.monitor.opentelemetry.autoconfigure.implementation.utils.HostName;
import com.azure.monitor.opentelemetry.autoconfigure.implementation.utils.Strings;
Expand All @@ -22,6 +21,13 @@
import com.microsoft.applicationinsights.agent.internal.configuration.Configuration.SamplingOverride;
import com.microsoft.applicationinsights.agent.internal.diagnostics.DiagnosticsHelper;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.semconv.ClientAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;
import io.opentelemetry.semconv.incubating.NetIncubatingAttributes;
import java.io.IOException;
import java.net.URL;
import java.net.URLDecoder;
Expand Down Expand Up @@ -359,44 +365,44 @@ private static void supportTelemetryProcessorsOldSemConv(Configuration config) {
private static String mapAttributeKey(String oldAttributeKey) {
String result = null;
// Common attributes across HTTP client and server spans
if (oldAttributeKey.equals(SemanticAttributes.HTTP_METHOD.getKey())) {
result = SemanticAttributes.HTTP_REQUEST_METHOD.getKey();
} else if (oldAttributeKey.equals(SemanticAttributes.HTTP_STATUS_CODE.getKey())) {
result = SemanticAttributes.HTTP_RESPONSE_STATUS_CODE.getKey();
if (oldAttributeKey.equals(HttpIncubatingAttributes.HTTP_METHOD.getKey())) {
result = HttpAttributes.HTTP_REQUEST_METHOD.getKey();
} else if (oldAttributeKey.equals(HttpIncubatingAttributes.HTTP_STATUS_CODE.getKey())) {
result = HttpAttributes.HTTP_RESPONSE_STATUS_CODE.getKey();
} else if (oldAttributeKey.startsWith("http.request.header.")
|| oldAttributeKey.startsWith("http.response.header.")) {
result = oldAttributeKey.replace('_', '-');
} else if (oldAttributeKey.equals(SemanticAttributes.NET_PROTOCOL_NAME.getKey())) {
result = SemanticAttributes.NETWORK_PROTOCOL_NAME.getKey();
} else if (oldAttributeKey.equals(SemanticAttributes.NET_PROTOCOL_VERSION.getKey())) {
result = SemanticAttributes.NETWORK_PROTOCOL_VERSION.getKey();
} else if (oldAttributeKey.equals(SemanticAttributes.NET_SOCK_PEER_ADDR.getKey())) {
result = SemanticAttributes.NETWORK_PEER_ADDRESS.getKey();
} else if (oldAttributeKey.equals(SemanticAttributes.NET_SOCK_PEER_PORT.getKey())) {
result = SemanticAttributes.NETWORK_PEER_PORT.getKey();
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_PROTOCOL_NAME.getKey())) {
result = NetworkAttributes.NETWORK_PROTOCOL_NAME.getKey();
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_PROTOCOL_VERSION.getKey())) {
result = NetworkAttributes.NETWORK_PROTOCOL_VERSION.getKey();
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_SOCK_PEER_ADDR.getKey())) {
result = NetworkAttributes.NETWORK_PEER_ADDRESS.getKey();
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_SOCK_PEER_PORT.getKey())) {
result = NetworkAttributes.NETWORK_PEER_PORT.getKey();
}

// HTTP client span attributes
// http.url is handled via LazyHttpUrl
if (oldAttributeKey.equals(SemanticAttributes.HTTP_RESEND_COUNT.getKey())) {
result = SemanticAttributes.HTTP_REQUEST_RESEND_COUNT.getKey();
if (oldAttributeKey.equals("http.resend_count")) {
result = HttpAttributes.HTTP_REQUEST_RESEND_COUNT.getKey();
// becomes available.
} else if (oldAttributeKey.equals(SemanticAttributes.NET_PEER_NAME.getKey())) {
result = SemanticAttributes.SERVER_ADDRESS.getKey();
} else if (oldAttributeKey.equals(SemanticAttributes.NET_PEER_PORT.getKey())) {
result = SemanticAttributes.SERVER_PORT.getKey();
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_PEER_NAME.getKey())) {
result = ServerAttributes.SERVER_ADDRESS.getKey();
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_PEER_PORT.getKey())) {
result = ServerAttributes.SERVER_PORT.getKey();
}

// HTTP server span attributes
// http.target is handled via LazyHttpTarget
if (oldAttributeKey.equals(SemanticAttributes.HTTP_SCHEME.getKey())) {
result = SemanticAttributes.URL_SCHEME.getKey();
} else if (oldAttributeKey.equals(SemanticAttributes.HTTP_CLIENT_IP.getKey())) {
result = SemanticAttributes.CLIENT_ADDRESS.getKey();
} else if (oldAttributeKey.equals(SemanticAttributes.NET_HOST_NAME.getKey())) {
result = SemanticAttributes.SERVER_ADDRESS.getKey();
} else if (oldAttributeKey.equals(SemanticAttributes.NET_HOST_PORT.getKey())) {
result = SemanticAttributes.SERVER_PORT.getKey();
if (oldAttributeKey.equals(HttpIncubatingAttributes.HTTP_SCHEME.getKey())) {
result = UrlAttributes.URL_SCHEME.getKey();
} else if (oldAttributeKey.equals(HttpIncubatingAttributes.HTTP_CLIENT_IP.getKey())) {
result = ClientAttributes.CLIENT_ADDRESS.getKey();
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_HOST_NAME.getKey())) {
result = ServerAttributes.SERVER_ADDRESS.getKey();
} else if (oldAttributeKey.equals(NetIncubatingAttributes.NET_HOST_PORT.getKey())) {
result = ServerAttributes.SERVER_PORT.getKey();
}

if (result == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.internal.AutoConfigureListener;
import io.opentelemetry.sdk.common.CompletableResultCode;
import io.opentelemetry.sdk.logs.LogRecordProcessor;
Expand Down Expand Up @@ -274,7 +275,8 @@ public void customize(AutoConfigurationCustomizer autoConfiguration) {
(metricExporter, configProperties) -> {
if (metricExporter
instanceof AzureMonitorMetricExporterProvider.MarkerMetricExporter) {
return buildMetricExporter(configuration, telemetryClient, metricFilters);
return buildMetricExporter(
configuration, telemetryClient, metricFilters, configProperties);
} else {
return metricExporter;
}
Expand Down Expand Up @@ -365,10 +367,20 @@ private static SpanExporter buildTraceExporter(
private static MetricExporter buildMetricExporter(
Configuration configuration,
TelemetryClient telemetryClient,
List<MetricFilter> metricFilters) {
List<MetricFilter> metricFilters,
ConfigProperties configProperties) {

String otelMetricsEndpoint = configProperties.getString("otel.exporter.otlp.metrics.endpoint");
String otelMetricsExporter = configProperties.getString("otel.metrics.exporter");
Boolean otlpEnabled =
(otelMetricsExporter != null && !otelMetricsExporter.isEmpty())
&& (otelMetricsEndpoint != null && !otelMetricsEndpoint.isEmpty());

MetricDataMapper mapper =
new MetricDataMapper(
telemetryClient::populateDefaults, configuration.preview.captureHttpServer4xxAsError);
telemetryClient::populateDefaults,
configuration.preview.captureHttpServer4xxAsError,
otlpEnabled);
return new AgentMetricExporter(
metricFilters, mapper, telemetryClient.getMetricsBatchItemProcessor());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void generateHttpClientMetrics() {
MetricTelemetryBuilder builder = MetricTelemetryBuilder.create();
MetricData metricData = metricDataCollection.iterator().next();
MetricDataMapper.updateMetricPointBuilder(
builder, metricData, metricData.getData().getPoints().iterator().next(), true, true);
builder, metricData, metricData.getData().getPoints().iterator().next(), true, true, null);
TelemetryItem telemetryItem = builder.build();
MetricsData metricsData = (MetricsData) telemetryItem.getData().getBaseData();

Expand Down Expand Up @@ -211,7 +211,7 @@ void generateRpcClientMetrics() {
MetricTelemetryBuilder builder = MetricTelemetryBuilder.create();
MetricData metricData = metricDataCollection.iterator().next();
MetricDataMapper.updateMetricPointBuilder(
builder, metricData, metricData.getData().getPoints().iterator().next(), true, true);
builder, metricData, metricData.getData().getPoints().iterator().next(), true, true, null);
TelemetryItem telemetryItem = builder.build();
MetricsData metricsData = (MetricsData) telemetryItem.getData().getBaseData();

Expand Down Expand Up @@ -291,7 +291,7 @@ void generateHttpServerMetrics() {
MetricTelemetryBuilder builder = MetricTelemetryBuilder.create();
MetricData metricData = target;
MetricDataMapper.updateMetricPointBuilder(
builder, metricData, metricData.getData().getPoints().iterator().next(), true, true);
builder, metricData, metricData.getData().getPoints().iterator().next(), true, true, null);
TelemetryItem telemetryItem = builder.build();
MetricsData metricsData = (MetricsData) telemetryItem.getData().getBaseData();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void methodEnter(
@Advice.This UserContext userContext, @Advice.Argument(0) String name) {
Span span = VirtualField.find(UserContext.class, Span.class).get(userContext);
if (span != null) {
span.setAttribute("enduser.id", name);
span.setAttribute("enduser.pseudo.id", name);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void setRequestUser() {
.hasAttributesSatisfyingExactly(
equalTo(CodeIncubatingAttributes.CODE_NAMESPACE, "Code"),
equalTo(CodeIncubatingAttributes.CODE_FUNCTION, "setUser"),
equalTo(EnduserIncubatingAttributes.ENDUSER_ID, "myuser")),
equalTo(EnduserIncubatingAttributes.ENDUSER_PSEUDO_ID, "myuser")),
span ->
span.hasName("Code.internalSetUser")
.hasKind(INTERNAL)
Expand Down
Loading