Skip to content

Commit 5bddd89

Browse files
authored
Merge branch 'main' into copilot/fix-4251
2 parents a5641a5 + 4cf74ca commit 5bddd89

File tree

16 files changed

+226
-173
lines changed

16 files changed

+226
-173
lines changed

agent/agent-profiler/agent-alerting/src/test/java/com/microsoft/applicationinsights/alerting/AlertingSubsystemTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ private static AlertingSubsystem getAlertMonitor(
3030
AlertConfiguration.builder()
3131
.setType(AlertMetricType.CPU)
3232
.setEnabled(true)
33-
.setThreshold((float) 80)
33+
.setThreshold(80.0f)
3434
.setProfileDurationSeconds(30)
3535
.setCooldownSeconds(14400)
3636
.build(),
3737
AlertConfiguration.builder()
3838
.setType(AlertMetricType.MEMORY)
3939
.setEnabled(true)
40-
.setThreshold((float) 20)
40+
.setThreshold(20.0f)
4141
.setProfileDurationSeconds(120)
4242
.setCooldownSeconds(14400)
4343
.build(),
@@ -89,14 +89,14 @@ void manualAlertWorks() {
8989
AlertConfiguration.builder()
9090
.setType(AlertMetricType.CPU)
9191
.setEnabled(true)
92-
.setThreshold((float) 80)
92+
.setThreshold(80.0f)
9393
.setProfileDurationSeconds(30)
9494
.setCooldownSeconds(14400)
9595
.build(),
9696
AlertConfiguration.builder()
9797
.setType(AlertMetricType.MEMORY)
9898
.setEnabled(true)
99-
.setThreshold((float) 20)
99+
.setThreshold(20.0f)
100100
.setProfileDurationSeconds(120)
101101
.setCooldownSeconds(14400)
102102
.build(),
@@ -130,14 +130,14 @@ void manualAlertDoesNotTriggerAfterExpired() {
130130
AlertConfiguration.builder()
131131
.setType(AlertMetricType.CPU)
132132
.setEnabled(true)
133-
.setThreshold((float) 80)
133+
.setThreshold(80.0f)
134134
.setProfileDurationSeconds(30)
135135
.setCooldownSeconds(14400)
136136
.build(),
137137
AlertConfiguration.builder()
138138
.setType(AlertMetricType.MEMORY)
139139
.setEnabled(true)
140-
.setThreshold((float) 20)
140+
.setThreshold(20.0f)
141141
.setProfileDurationSeconds(120)
142142
.setCooldownSeconds(14400)
143143
.build(),

agent/agent-tooling/src/test/java/com/microsoft/applicationinsights/agent/internal/profiler/triggers/AlertConfigParserTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void saneDataIsParsed() {
4343
AlertConfiguration.builder()
4444
.setType(AlertMetricType.CPU)
4545
.setEnabled(true)
46-
.setThreshold((float) 80)
46+
.setThreshold(80.0f)
4747
.setProfileDurationSeconds(30)
4848
.setCooldownSeconds(14400)
4949
.build());
@@ -53,7 +53,7 @@ void saneDataIsParsed() {
5353
AlertConfiguration.builder()
5454
.setType(AlertMetricType.MEMORY)
5555
.setEnabled(true)
56-
.setThreshold((float) 20)
56+
.setThreshold(20.0f)
5757
.setProfileDurationSeconds(120)
5858
.setCooldownSeconds(14400)
5959
.build());

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dependencies {
3030
implementation(gradleApi())
3131

3232
// When updating, update above in plugins too
33-
implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.4")
33+
implementation("com.diffplug.spotless:spotless-plugin-gradle:7.1.0")
3434
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:6.2.1")
3535
implementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.8")
3636

buildSrc/src/main/kotlin/ai.errorprone-conventions.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ tasks {
5454

5555
// Don't support Android without desugar
5656
disable("AndroidJdkLibsChecker")
57-
disable("Java7ApiChecker")
5857
disable("StaticOrDefaultInterfaceMethod")
5958

6059
// needed temporarily while hosting azure-monitor-opentelemetry-exporter in this repo
@@ -70,6 +69,9 @@ tasks {
7069
// cognitive load is dubious.
7170
disable("YodaCondition")
7271

72+
// Requires adding compile dependency to JSpecify
73+
disable("AddNullMarkedToPackageInfo")
74+
7375
if (name.contains("Jmh")) {
7476
disable("MemberName")
7577
}

classic-sdk/core/src/main/java/com/microsoft/applicationinsights/telemetry/ExceptionTelemetry.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public void setException(Throwable throwable, int stackSize) {
5656
this.throwable = throwable;
5757
}
5858

59+
@SuppressWarnings("EnumOrdinal")
5960
public void setSeverityLevel(SeverityLevel severityLevel) {
6061
data.setSeverityLevel(
6162
severityLevel == null
@@ -65,6 +66,7 @@ public void setSeverityLevel(SeverityLevel severityLevel) {
6566
}
6667

6768
@Nullable
69+
@SuppressWarnings("EnumOrdinal")
6870
public SeverityLevel getSeverityLevel() {
6971
return data.getSeverityLevel() == null
7072
? null

classic-sdk/core/src/main/java/com/microsoft/applicationinsights/telemetry/TraceTelemetry.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public void setMessage(String message) {
4747
data.setMessage(message);
4848
}
4949

50+
@SuppressWarnings("EnumOrdinal")
5051
public void setSeverityLevel(SeverityLevel severityLevel) {
5152
data.setSeverityLevel(
5253
severityLevel == null
@@ -56,6 +57,7 @@ public void setSeverityLevel(SeverityLevel severityLevel) {
5657
}
5758

5859
@Nullable
60+
@SuppressWarnings("EnumOrdinal")
5961
public SeverityLevel getSeverityLevel() {
6062
return data.getSeverityLevel() == null
6163
? null

dependencyManagement/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ val DEPENDENCY_BOMS = listOf(
3333

3434
val autoServiceVersion = "1.1.1"
3535
val autoValueVersion = "1.11.0"
36-
val errorProneVersion = "2.36.0"
36+
val errorProneVersion = "2.38.0"
3737
val jmhVersion = "1.37"
3838
val mockitoVersion = "4.11.0"
3939
val slf4jVersion = "2.0.17"

licenses/more-licenses.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _2025-07-08 14:53:50 UTC_
3636
> - **POM Project URL**: [http://stephenc.github.com/jcip-annotations](http://stephenc.github.com/jcip-annotations)
3737
> - **POM License**: Apache License, Version 2.0 - [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)
3838
39-
**6** **Group:** `com.google.errorprone` **Name:** `error_prone_annotations` **Version:** `2.36.0`
39+
**6** **Group:** `com.google.errorprone` **Name:** `error_prone_annotations` **Version:** `2.38.0`
4040
> - **Manifest Project URL**: [https://errorprone.info/error_prone_annotations](https://errorprone.info/error_prone_annotations)
4141
> - **Manifest License**: Apache License, Version 2.0 (Not Packaged)
4242
> - **POM License**: Apache License, Version 2.0 - [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)

smoke-tests/apps/AzureSdk/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ dependencies {
77
exclude("org.springframework.boot", "spring-boot-starter-tomcat")
88
}
99
// want to test with one of the earliest version supported, and not managed version used in agent
10-
implementation(enforcedPlatform("com.azure:azure-sdk-bom:1.2.13"))
11-
implementation("com.azure:azure-core")
10+
implementation("com.azure:azure-core:1.39.0")
1211
}

smoke-tests/apps/LiveMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/LiveMetricsTest.java

Lines changed: 16 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,10 @@
1717
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8;
1818
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8_OPENJ9;
1919
import static org.assertj.core.api.Assertions.assertThat;
20+
import static org.awaitility.Awaitility.await;
2021

21-
import com.azure.json.JsonProviders;
22-
import com.azure.json.JsonReader;
23-
import com.azure.monitor.opentelemetry.autoconfigure.implementation.quickpulse.swagger.models.DocumentIngress;
24-
import com.azure.monitor.opentelemetry.autoconfigure.implementation.quickpulse.swagger.models.DocumentType;
25-
import com.azure.monitor.opentelemetry.autoconfigure.implementation.quickpulse.swagger.models.Exception;
26-
import com.azure.monitor.opentelemetry.autoconfigure.implementation.quickpulse.swagger.models.MetricPoint;
27-
import com.azure.monitor.opentelemetry.autoconfigure.implementation.quickpulse.swagger.models.MonitoringDataPoint;
28-
import com.azure.monitor.opentelemetry.autoconfigure.implementation.quickpulse.swagger.models.Trace;
29-
import java.io.IOException;
22+
import com.microsoft.applicationinsights.smoketest.fakeingestion.LiveMetricsVerifier;
3023
import java.time.Duration;
31-
import java.util.ArrayList;
32-
import java.util.List;
33-
import org.awaitility.Awaitility;
3424
import org.junit.jupiter.api.Test;
3525
import org.junit.jupiter.api.extension.RegisterExtension;
3626

@@ -41,135 +31,25 @@ abstract class LiveMetricsTest {
4131

4232
@Test
4333
@TargetUri("/test")
44-
void testTelemetryDataFlow() throws java.lang.Exception {
45-
Awaitility.await()
34+
void testTelemetryDataFlow() {
35+
await()
4636
.atMost(Duration.ofSeconds(60))
4737
.until(() -> testing.mockedIngestion.getCountForType("RequestData") == 1);
4838

49-
PostBodyVerifier postBodyVerifier = new PostBodyVerifier();
39+
await()
40+
.untilAsserted(
41+
() -> {
42+
LiveMetricsVerifier verifier = testing.mockedIngestion.getLiveMetrics();
5043

51-
assertThat(testing.mockedIngestion.isPingReceived()).isTrue();
44+
verifier.confirmDocsAreFiltered();
45+
verifier.confirmPerfCountersNonZero();
5246

53-
List<String> postBodies = testing.mockedIngestion.getPostBodies();
54-
assertThat(postBodies).hasSizeGreaterThan(0); // should post at least once
55-
56-
for (String postBody : postBodies) {
57-
postBodyVerifier.searchPostBody(postBody);
58-
}
59-
60-
assertThat(postBodyVerifier.hasExceptionDoc()).isTrue();
61-
assertThat(postBodyVerifier.hasTraceDoc()).isTrue();
62-
assertThat(postBodyVerifier.hasDependency()).isTrue();
63-
assertThat(postBodyVerifier.hasRequest()).isTrue();
64-
}
65-
66-
class PostBodyVerifier {
67-
boolean foundExceptionDoc = false;
68-
boolean foundTraceDoc = false;
69-
boolean foundDependency = false;
70-
boolean foundRequest = false;
71-
72-
public void searchPostBody(String postBody) {
73-
// Each post body is a list with a singular MonitoringDataPoint
74-
List<MonitoringDataPoint> dataPoints = new ArrayList<>();
75-
try {
76-
JsonReader reader = JsonProviders.createReader(postBody);
77-
dataPoints = reader.readArray(MonitoringDataPoint::fromJson);
78-
} catch (IOException e) {
79-
throw new IllegalStateException("Failed to parse post request body", e);
80-
}
81-
82-
// Because the mock ping/posts should succeed, we should only have one MonitoringDataPoint per
83-
// post
84-
assertThat(dataPoints).hasSize(1);
85-
MonitoringDataPoint dataPoint = dataPoints.get(0);
86-
87-
List<DocumentIngress> docs = dataPoint.getDocuments();
88-
List<MetricPoint> metrics = dataPoint.getMetrics();
89-
90-
confirmDocsAreFiltered(docs);
91-
confirmPerfCountersNonZero(metrics);
92-
foundExceptionDoc = foundExceptionDoc || hasException(docs);
93-
foundTraceDoc = foundTraceDoc || hasTrace(docs);
94-
foundDependency = foundDependency || hasDependency(metrics);
95-
foundRequest = foundRequest || hasRequest(metrics);
96-
}
97-
98-
public boolean hasExceptionDoc() {
99-
return foundExceptionDoc;
100-
}
101-
102-
public boolean hasTraceDoc() {
103-
return foundTraceDoc;
104-
}
105-
106-
public boolean hasDependency() {
107-
return foundDependency;
108-
}
109-
110-
public boolean hasRequest() {
111-
return foundRequest;
112-
}
113-
114-
private void confirmDocsAreFiltered(List<DocumentIngress> docs) {
115-
for (DocumentIngress doc : docs) {
116-
assertThat(doc.getDocumentType()).isNotEqualTo(DocumentType.REMOTE_DEPENDENCY);
117-
assertThat(doc.getDocumentType()).isNotEqualTo(DocumentType.REQUEST);
118-
}
119-
}
120-
121-
private boolean hasException(List<DocumentIngress> docs) {
122-
for (DocumentIngress doc : docs) {
123-
if (doc.getDocumentType().equals(DocumentType.EXCEPTION)
124-
&& ((Exception) doc).getExceptionMessage().equals("Fake Exception")) {
125-
return true;
126-
}
127-
}
128-
return false;
129-
}
130-
131-
private boolean hasTrace(List<DocumentIngress> docs) {
132-
for (DocumentIngress doc : docs) {
133-
if (doc.getDocumentType().equals(DocumentType.TRACE)
134-
&& ((Trace) doc).getMessage().equals("This message should generate a trace")) {
135-
return true;
136-
}
137-
}
138-
return false;
139-
}
140-
141-
private boolean hasDependency(List<MetricPoint> metrics) {
142-
for (MetricPoint metric : metrics) {
143-
String name = metric.getName();
144-
double value = metric.getValue();
145-
if (name.equals("\\ApplicationInsights\\Dependency Calls/Sec")) {
146-
return value == 1;
147-
}
148-
}
149-
return false;
150-
}
151-
152-
private boolean hasRequest(List<MetricPoint> metrics) {
153-
for (MetricPoint metric : metrics) {
154-
String name = metric.getName();
155-
double value = metric.getValue();
156-
if (name.equals("\\ApplicationInsights\\Requests/Sec")) {
157-
return value == 1;
158-
}
159-
}
160-
return false;
161-
}
162-
163-
private void confirmPerfCountersNonZero(List<MetricPoint> metrics) {
164-
for (MetricPoint metric : metrics) {
165-
String name = metric.getName();
166-
double value = metric.getValue();
167-
if (name.equals("\\Process\\Physical Bytes")
168-
|| name.equals("\\% Process\\Processor Time Normalized")) {
169-
assertThat(value).isNotEqualTo(0);
170-
}
171-
}
172-
}
47+
assertThat(verifier.getExceptionCount("Fake Exception")).isEqualTo(1);
48+
assertThat(verifier.getTraceCount("This message should generate a trace"))
49+
.isEqualTo(1);
50+
assertThat(verifier.getDependencyCountFromMetric()).isEqualTo(1);
51+
assertThat(verifier.getRequestCountFromMetric()).isEqualTo(1);
52+
});
17353
}
17454

17555
@Environment(TOMCAT_8_JAVA_8)

0 commit comments

Comments
 (0)