Skip to content

Commit

Permalink
Add actuator metrics support
Browse files Browse the repository at this point in the history
  • Loading branch information
trask committed Apr 20, 2020
1 parent 697f57f commit 43341a3
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 1 deletion.
2 changes: 1 addition & 1 deletion opentelemetry-auto-instr-java
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ include ':test:smoke:testApps:JMS'
include ':test:smoke:testApps:Kafka'
include ':test:smoke:testApps:SpringCloudStream'
include ':test:smoke:testApps:Micrometer'
include ':test:smoke:testApps:ActuatorMetrics'
include ':test:smoke:testApps:SystemExit'
include ':test:smoke:testApps:VerifyShading'
include ':test:smoke:testApps:VerifyJava7'
Expand Down
19 changes: 19 additions & 0 deletions test/smoke/testApps/ActuatorMetrics/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id 'java'
id 'org.springframework.boot' version '2.1.7.RELEASE'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8
compileSmokeTestJava.sourceCompatibility = 1.8
compileSmokeTestJava.targetCompatibility = 1.8

ext.testAppArtifactDir = jar.destinationDirectory
ext.testAppArtifactFilename = jar.archiveFileName.get()

dependencies {
compileOnly aiAgentJar // this is just to force building the agent first

compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.1.7.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.1.7.RELEASE'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.microsoft.ajl.simple;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringBootApp {

public static void main(String[] args) {

SpringApplication.run(SpringBootApp.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.microsoft.ajl.simple;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

@GetMapping("/")
public String root() {
return "OK";
}

@GetMapping("/test")
public String test() {
return "OK!";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
management.metrics.export.azuremonitor.instrumentation-key=00000000-0000-0000-0000-000000000000
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.microsoft.applicationinsights.smoketest;

import java.util.List;

import com.microsoft.applicationinsights.internal.schemav2.DataPoint;
import com.microsoft.applicationinsights.internal.schemav2.DataPointType;
import com.microsoft.applicationinsights.internal.schemav2.MetricData;
import org.junit.*;

import static org.junit.Assert.*;

@UseAgent("Micrometer")
public class MicrometerTest extends AiSmokeTest {

@Test
@TargetUri("/test")
public void doMostBasicTest() throws Exception {
mockedIngestion.waitForItems("RequestData", 1);

mockedIngestion.waitForItems("MetricData", 1);

List<MetricData> metrics = mockedIngestion.getTelemetryDataByType("MetricData");

assertEquals(1, metrics.size());

List<DataPoint> points = metrics.get(0).getMetrics();

assertEquals(1, points.size());

DataPoint point = points.get(0);

assertEquals(DataPointType.Measurement, point.getKind());
assertEquals(1, point.getValue(), 0);
assertEquals("test_counter", point.getName());
assertNull("getCount was non-null", point.getCount());
assertNull("getMin was non-null", point.getMin());
assertNull("getMax was non-null", point.getMax());
assertNull("getStdDev was non-null", point.getStdDev());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`jre.excludes.txt` is needed because Spring Boot 2 and Micrometer do not support Java 7
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
javase
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
azul/zulu-openjdk:7
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration>
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="warn">
<appender-ref ref="CONSOLE" />
</root>
</configuration>

0 comments on commit 43341a3

Please sign in to comment.