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

Emit stable OpenTelemetry HTTP metrics #3676

Merged
merged 20 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 19 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
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-exporter:1.0.0-beta.21")
implementation("com.azure:azure-monitor-opentelemetry-exporter:1.0.0-beta.22")
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-bootstrap")
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling")
compileOnly("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-servlet-common-bootstrap")
Expand Down
2 changes: 1 addition & 1 deletion agent/agent-tooling/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ com.azure:azure-core-http-netty:1.14.2=runtimeClasspath
com.azure:azure-core:1.48.0=runtimeClasspath
com.azure:azure-identity:1.12.1=runtimeClasspath
com.azure:azure-json:1.1.0=runtimeClasspath
com.azure:azure-monitor-opentelemetry-exporter:1.0.0-beta.21=runtimeClasspath
com.azure:azure-monitor-opentelemetry-exporter:1.0.0-beta.22=runtimeClasspath
com.azure:azure-sdk-bom:1.2.23=runtimeClasspath
com.azure:azure-storage-blob:12.25.4=runtimeClasspath
com.azure:azure-storage-common:12.24.4=runtimeClasspath
Expand Down
Binary file not shown.
238 changes: 238 additions & 0 deletions azure-monitor-opentelemetry-exporter-1.0.0-beta.22.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
<!-- Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License. -->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.azure</groupId>
<artifactId>azure-client-sdk-parent</artifactId>
<version>1.7.0</version> <!-- {x-version-update;com.azure:azure-client-sdk-parent;current} -->
<relativePath>../../parents/azure-client-sdk-parent</relativePath>
</parent>

<groupId>com.azure</groupId>
<artifactId>azure-monitor-opentelemetry-exporter</artifactId>
<version>1.0.0-beta.22</version> <!-- {x-version-update;com.azure:azure-monitor-opentelemetry-exporter;current} -->

<name>Microsoft Azure SDK for OpenTelemetry Azure Monitor Exporter</name>
<description>This package contains Microsoft Azure SDK for OpenTelemetry Azure Monitor Exporter.</description>

<distributionManagement>
<site>
<id>azure-java-build-docs</id>
<url>${site.url}/site/${project.artifactId}</url>
</site>
</distributionManagement>

<scm>
<url>https://github.com/Azure/azure-sdk-for-java</url>
</scm>

<properties>
<jacoco.min.linecoverage>0.30</jacoco.min.linecoverage>
<jacoco.min.branchcoverage>0.20</jacoco.min.branchcoverage>
<!-- Configures the Java 9+ run to perform the required module exports, opens, and reads that are necessary for testing but shouldn't be part of the module-info. -->
<javaModulesSurefireArgLine>
--add-opens com.azure.monitor.opentelemetry.exporter/com.azure.monitor.opentelemetry.exporter=ALL-UNNAMED
</javaModulesSurefireArgLine>
<checkstyle.excludes>**/implementation/**/*.java</checkstyle.excludes>
</properties>

<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.48.0</version> <!-- {x-version-update;com.azure:azure-core;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-http-netty</artifactId>
<version>1.14.2</version> <!-- {x-version-update;com.azure:azure-core-http-netty;dependency} -->
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
<version>1.37.0</version> <!-- {x-version-update;io.opentelemetry:opentelemetry-api;external_dependency} -->
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
<version>1.37.0</version> <!-- {x-version-update;io.opentelemetry:opentelemetry-sdk;external_dependency} -->
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-metrics</artifactId>
<version>1.37.0</version> <!-- {x-version-update;io.opentelemetry:opentelemetry-sdk-metrics;external_dependency} -->
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-logs</artifactId>
<version>1.37.0</version> <!-- {x-version-update;io.opentelemetry:opentelemetry-sdk-logs;external_dependency} -->
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-extension-autoconfigure-spi</artifactId>
<version>1.37.0</version> <!-- {x-version-update;io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi;external_dependency} -->
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId>
<version>1.37.0</version> <!-- {x-version-update;io.opentelemetry:opentelemetry-sdk-extension-autoconfigure;external_dependency} -->
</dependency>

<!-- Added this dependency to include necessary annotations used by reactor core.
Without this dependency, javadoc throws a warning as it cannot find enum When.MAYBE
which is used in @Nullable annotation in reactor core classes -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version> <!-- {x-version-update;com.google.code.findbugs:jsr305;external_dependency} -->
<scope>provided</scope>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version> <!-- {x-version-update;org.slf4j:slf4j-simple;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.3</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-api;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.3</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-engine;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.9.3</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-params;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.22.0</version> <!-- {x-version-update;org.assertj:assertj-core;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.11.0</version> <!-- {x-version-update;org.mockito:mockito-core;external_dependency} -->
<scope>test</scope>
</dependency>
<!-- bytebuddy dependencies are required for mockito 4.11.0 to work with Java 21. Mockito 4.11.0 is the last release -->
<!-- of Mockito supporting Java 8 as a baseline. -->
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.14.12</version> <!-- {x-version-update;testdep_net.bytebuddy:byte-buddy;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<version>1.14.12</version> <!-- {x-version-update;testdep_net.bytebuddy:byte-buddy-agent;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-testing</artifactId>
<version>1.37.0</version> <!-- {x-version-update;io.opentelemetry:opentelemetry-sdk-testing;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-data-appconfiguration</artifactId>
<version>1.6.0</version> <!-- {x-version-update;com.azure:azure-data-appconfiguration;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-messaging-eventhubs</artifactId>
<version>5.18.3</version> <!-- {x-version-update;com.azure:azure-messaging-eventhubs;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-tracing-opentelemetry</artifactId>
<version>1.0.0-beta.45</version> <!-- {x-version-update;com.azure:azure-core-tracing-opentelemetry;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-test</artifactId>
<version>1.24.2</version> <!-- {x-version-update;com.azure:azure-core-test;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-messaging-eventhubs-checkpointstore-blob</artifactId>
<version>1.19.3</version> <!-- {x-version-update;com.azure:azure-messaging-eventhubs-checkpointstore-blob;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.12.0</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.2.0</version> <!-- {x-version-update;org.awaitility:awaitility;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.hakky54</groupId>
<artifactId>logcaptor</artifactId>
<version>2.9.0</version> <!-- {x-version-update;io.github.hakky54:logcaptor;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>3.9.0</version> <!-- {x-version-update;com.squareup.okio:okio;external_dependency} -->
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.4.1</version> <!-- {x-version-update;org.apache.maven.plugins:maven-enforcer-plugin;external_dependency} -->
<configuration>
<rules>
<bannedDependencies>
<includes>
<include>io.opentelemetry:opentelemetry-api:[1.37.0]</include> <!-- {x-include-update;io.opentelemetry:opentelemetry-api;external_dependency} -->
<include>io.opentelemetry:opentelemetry-sdk:[1.37.0]</include> <!-- {x-include-update;io.opentelemetry:opentelemetry-sdk;external_dependency} -->
<include>io.opentelemetry:opentelemetry-sdk-metrics:[1.37.0]</include> <!-- {x-include-update;io.opentelemetry:opentelemetry-sdk-metrics;external_dependency} -->
<include>io.opentelemetry:opentelemetry-sdk-logs:[1.37.0]</include> <!-- {x-include-update;io.opentelemetry:opentelemetry-sdk-logs;external_dependency} -->
<include>io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:[1.37.0]</include> <!-- {x-include-update;io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi;external_dependency} -->
<include>io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:[1.37.0]</include> <!-- {x-include-update;io.opentelemetry:opentelemetry-sdk-extension-autoconfigure;external_dependency} -->
<include>com.squareup.okio:okio:[3.9.0]</include> <!-- {x-include-update;com.squareup.okio:okio;external_dependency} -->
</includes>
</bannedDependencies>
</rules>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version> <!-- {x-version-update;org.apache.maven.plugins:maven-surefire-plugin;external_dependency} -->
</plugin>
</plugins>
</build>
</project>
4 changes: 2 additions & 2 deletions licenses/more-licenses.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# agent
## Dependency License Report
_2024-05-06 19:10:34 UTC_
_2024-05-06 12:02:06 PDT_
## Apache License, Version 2.0

**1** **Group:** `com.fasterxml.jackson.core` **Name:** `jackson-annotations` **Version:** `2.17.1`
Expand Down Expand Up @@ -350,7 +350,7 @@ _2024-05-06 19:10:34 UTC_
> - **POM Project URL**: [https://github.com/Azure/azure-sdk-for-java](https://github.com/Azure/azure-sdk-for-java)
> - **POM License**: MIT License - [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT)

**67** **Group:** `com.azure` **Name:** `azure-monitor-opentelemetry-exporter` **Version:** `1.0.0-beta.21`
**67** **Group:** `com.azure` **Name:** `azure-monitor-opentelemetry-exporter` **Version:** `1.0.0-beta.22`
> - **POM License**: MIT License - [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT)

**68** **Group:** `com.azure` **Name:** `azure-storage-blob` **Version:** `12.25.4`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ private static void testApp(String iKey) throws Exception {
// and metrics too

List<Envelope> clientMetrics =
testing.mockedIngestion.waitForMetricItems("http.client.request.duration", 1);
testing.mockedIngestion.waitForStandardMetricItems("dependencies/duration", 1);
List<Envelope> serverMetrics =
testing.mockedIngestion.waitForMetricItems("http.server.request.duration", 1);
testing.mockedIngestion.waitForStandardMetricItems("requests/duration", 1);

verifyHttpClientPreAggregatedMetrics(clientMetrics, iKey);
verifyHttpServerPreAggregatedMetrics(serverMetrics, iKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import com.microsoft.applicationinsights.smoketest.schemav2.Data;
import com.microsoft.applicationinsights.smoketest.schemav2.Envelope;
import com.microsoft.applicationinsights.smoketest.schemav2.MetricData;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Predicate;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

Expand All @@ -47,6 +43,8 @@ abstract class DetectUnexpectedOtelMetricsTest {
EXPECTED_METRIC_NAMES.add("% Of Max Heap Memory Used");
EXPECTED_METRIC_NAMES.add("GC Total Count");
EXPECTED_METRIC_NAMES.add("GC Total Time");
EXPECTED_METRIC_NAMES.add("http.server.request.duration");
EXPECTED_METRIC_NAMES.add("http.client.request.duration");
}

@Test
Expand All @@ -66,29 +64,6 @@ void testApp() throws Exception {
.isInstanceOf(TimeoutException.class);
}

// wait for at least one unexpected otel metrics for failure case or timeout for success
public List<Envelope> waitForItemsUnexpectedOtelMetric(String type, Predicate<Envelope> condition)
throws InterruptedException, ExecutionException, TimeoutException {
return testing.mockedIngestion.waitForItems(
new Predicate<Envelope>() {
@Override
public boolean test(Envelope input) {
if (!input.getData().getBaseType().equals(type)) {
return false;
}
MetricData md = (MetricData) ((Data<?>) input.getData()).getBaseData();
if ("_OTELRESOURCE_".equals(md.getMetrics().get(0).getName())
|| md.getProperties().containsKey("_MS.MetricId")) {
return false;
}
return condition.test(input);
}
},
1,
10,
TimeUnit.SECONDS);
}

@Environment(TOMCAT_8_JAVA_8)
static class Tomcat8Java8Test extends DetectUnexpectedOtelMetricsTest {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ private void testHttpUrlConnectionAndSynthetic(boolean synthetic) throws Excepti
verifyHttpclientRequestsAndDependencies("https://mock.codes/200?q=spaces%20test");

List<Envelope> clientMetrics =
testing.mockedIngestion.waitForMetricItems("http.client.request.duration", 3);
testing.mockedIngestion.waitForStandardMetricItems("dependencies/duration", 3);
List<Envelope> serverMetrics =
testing.mockedIngestion.waitForMetricItems("http.server.request.duration", 1);
testing.mockedIngestion.waitForStandardMetricItems("requests/duration", 1);

verifyHttpClientPreAggregatedMetrics(clientMetrics);
verifyHttpServerPreAggregatedMetrics(serverMetrics, synthetic);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ private static void testApp(String iKey) throws Exception {
// and metrics too

List<Envelope> clientMetrics =
testing.mockedIngestion.waitForMetricItems("http.client.request.duration", 1);
testing.mockedIngestion.waitForStandardMetricItems("dependencies/duration", 1);
List<Envelope> serverMetrics =
testing.mockedIngestion.waitForMetricItems("http.server.request.duration", 1);
testing.mockedIngestion.waitForStandardMetricItems("requests/duration", 1);

verifyHttpClientPreAggregatedMetrics(clientMetrics, iKey);
verifyHttpServerPreAggregatedMetrics(serverMetrics, iKey);
Expand Down
Loading
Loading