Updating task metrics to micrometer 1.10
Changes include: * Use Observable instead of metrics * Update the setting of lowCardinalityTag to the correct events. * Update the docs * Remove EXTERNAL_EXECUTION_ID * Utilize registry provided by boot instead of globalregistry * Set the handler until Boot does this as shown on line 80 of TaskLifecycleConfiguration. * Uses Observability long task timer Updated to latest changes in Micrometer Observability Updated based on code review and api change Finished removing the metrics registry Updated based on code review Readded cloud foundry keys to observations Renamed metrics to observations where applicable Updated metric sample to be observation sample Updated to set defaults and migrate tests to infrastructure Updated based on code review Remove duplicate keyvalues from task observation Added DocumentedObservation to create the observation Migrated code to use the LowerCardinality KeyNames from the DocumentedObservation Test cleanup Updated code based on code review Exception is handled by the error in the observation vs logging it as a task metric key value Updated to use ObservationConvention Updated to handle user defined convention vs default Removed the snapshot versions of observations Removed unnecessary dependencies Checkpoint tests fail after re-adding 1.10-SNAPSHOT Replaced TimeObservationHandler with DefaultMeterObservationHandler Updated to set micrometer to latest milestone Updated to rename TaskValuesProvider variables to ObservationConvention
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
<module>task-events</module>
|
||||
<module>batch-events</module>
|
||||
<module>jpa-sample</module>
|
||||
<module>task-metrics</module>
|
||||
<module>task-observations</module>
|
||||
<module>multiple-datasources</module>
|
||||
<module>single-step-batch-job</module>
|
||||
</modules>
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
logging.level.org.springframework.cloud.task=debug
|
||||
management.metrics.tags.service=task-metrics-application
|
||||
management.metrics.tags.application=task-metrics-application-58
|
||||
spring.cloud.task.name=taskmetrics
|
||||
spring.cloud.task.observation.enabled=true
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>io.spring</groupId>
|
||||
<artifactId>task-metrics</artifactId>
|
||||
<artifactId>task-observations</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<name>task-metrics</name>
|
||||
<description>task-metrics</description>
|
||||
<name>task observation sample</name>
|
||||
<description>Displays task observations as well as commandline and application runner observations</description>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<spring-cloud.version>2022.0.0-SNAPSHOT</spring-cloud.version>
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.taskmetrics;
|
||||
package io.spring.taskobservations;
|
||||
|
||||
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MetricConfiguration {
|
||||
public class ObservationConfiguration {
|
||||
@Bean
|
||||
public SimpleMeterRegistry meterRegistry() {
|
||||
return new SimpleMeterRegistry();
|
||||
@@ -14,14 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.taskmetrics;
|
||||
package io.spring.taskobservations;
|
||||
|
||||
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@@ -33,35 +32,25 @@ import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableTask
|
||||
public class TaskMetricsApplication {
|
||||
public class TaskObservationsApplication {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(TaskMetricsApplication.class);
|
||||
private static final Log logger = LogFactory.getLog(TaskObservationsApplication.class);
|
||||
|
||||
@Autowired
|
||||
public SimpleMeterRegistry simpleMeterRegistry;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TaskMetricsApplication.class, args);
|
||||
SpringApplication.run(TaskObservationsApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ApplicationRunner applicationRunner() {
|
||||
return new ApplicationRunner() {
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
logger.info("Hello ApplicationRunner Metric's World");
|
||||
}
|
||||
};
|
||||
return args -> logger.info("Hello ApplicationRunner Metric's World");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CommandLineRunner commandLineRunner() {
|
||||
return new CommandLineRunner() {
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
logger.info("Hello CommandLineRunner Metric's World");
|
||||
}
|
||||
};
|
||||
return args -> logger.info("Hello CommandLineRunner Metric's World");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -0,0 +1,6 @@
|
||||
logging.level.org.springframework.cloud.task=debug
|
||||
management.metrics.tags.service=task-observations-application
|
||||
management.metrics.tags.application=task-observations-application-58
|
||||
spring.cloud.task.name=taskmetrics
|
||||
spring.cloud.task.observation.enabled=true
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.taskmetrics;
|
||||
package io.spring.taskobservations;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -27,14 +27,17 @@ import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
|
||||
|
||||
@SpringBootTest
|
||||
@ExtendWith(OutputCaptureExtension.class)
|
||||
class TaskMetricsApplicationTests {
|
||||
class TaskObservationsApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads(CapturedOutput output) {
|
||||
String result = output.getAll();
|
||||
assertThat(result).contains("spring.cloud.task(TIMER)[application=" +
|
||||
"'task-metrics-application-58', service='task-metrics-application', " +
|
||||
"task.exception='none', task.execution.id='");
|
||||
assertThat(result).contains("spring.cloud.task(TIMER)[application='task-observations-application-58', " +
|
||||
"error='none', service='task-observations-application', " +
|
||||
"spring.cloud.task.execution.id='1', spring.cloud.task.exit.code='0', " +
|
||||
"spring.cloud.task.external.execution.id='unknown', spring.cloud.task.name='taskmetrics', " +
|
||||
"spring.cloud.task.parent.execution.id='unknown', spring.cloud.task.status='success']; " +
|
||||
"count=1.0, total_time=");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user