From a19eefa7fd1cdcd423ab3c918cdcbeb5141d0fc6 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 15 Apr 2022 11:50:38 +0200 Subject: [PATCH] Upgraded to Micrometer 1.10.0-SNAPSHOT --- pom.xml | 2 +- .../batch/core/job/AbstractJob.java | 14 ++++++------- ...er.java => BatchJobKeyValuesProvider.java} | 4 ++-- .../observability/BatchJobObservation.java | 18 ++++++++--------- .../observability/BatchStepObservation.java | 20 +++++++++---------- .../observability/BatchStepTagsProvider.java | 4 ++-- ... => DefaultBatchJobKeyValuesProvider.java} | 14 ++++++------- .../DefaultBatchStepTagsProvider.java | 10 +++++----- .../batch/core/step/AbstractStep.java | 10 +++++----- 9 files changed, 48 insertions(+), 48 deletions(-) rename spring-batch-core/src/main/java/org/springframework/batch/core/observability/{BatchJobTagsProvider.java => BatchJobKeyValuesProvider.java} (84%) rename spring-batch-core/src/main/java/org/springframework/batch/core/observability/{DefaultBatchJobTagsProvider.java => DefaultBatchJobKeyValuesProvider.java} (66%) diff --git a/pom.xml b/pom.xml index 0c395fe1f..aa16f2309 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ 6.0.0-SNAPSHOT 1.3.2 6.0.0-SNAPSHOT - 2.0.0-SNAPSHOT + 1.10.0-SNAPSHOT 2.13.2.2 diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java index 4496d7542..a7bf0008e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java @@ -44,9 +44,9 @@ import org.springframework.batch.core.launch.support.ExitCodeMapper; import org.springframework.batch.core.listener.CompositeJobExecutionListener; import org.springframework.batch.core.observability.BatchJobContext; import org.springframework.batch.core.observability.BatchJobObservation; -import org.springframework.batch.core.observability.BatchJobTagsProvider; +import org.springframework.batch.core.observability.BatchJobKeyValuesProvider; import org.springframework.batch.core.observability.BatchMetrics; -import org.springframework.batch.core.observability.DefaultBatchJobTagsProvider; +import org.springframework.batch.core.observability.DefaultBatchJobKeyValuesProvider; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.JobRestartException; import org.springframework.batch.core.scope.context.JobSynchronizationManager; @@ -69,7 +69,7 @@ import org.springframework.util.ClassUtils; * @author Mahmoud Ben Hassine */ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, -InitializingBean, Observation.TagsProviderAware { +InitializingBean, Observation.KeyValuesProviderAware { protected static final Log logger = LogFactory.getLog(AbstractJob.class); @@ -87,7 +87,7 @@ InitializingBean, Observation.TagsProviderAware { private StepHandler stepHandler; - private BatchJobTagsProvider tagsProvider = new DefaultBatchJobTagsProvider(); + private BatchJobKeyValuesProvider keyValuesProvider = new DefaultBatchJobKeyValuesProvider(); /** * Default constructor. @@ -315,7 +315,7 @@ InitializingBean, Observation.TagsProviderAware { LongTaskTimer.Sample longTaskTimerSample = longTaskTimer.start(); Observation observation = BatchMetrics.createObservation(BatchJobObservation.BATCH_JOB_OBSERVATION.getName(), new BatchJobContext(execution)) .contextualName(execution.getJobInstance().getJobName()) - .tagsProvider(this.tagsProvider) + .keyValuesProvider(this.keyValuesProvider) .start(); try (Observation.Scope scope = observation.openScope()) { @@ -465,8 +465,8 @@ InitializingBean, Observation.TagsProviderAware { } @Override - public void setTagsProvider(BatchJobTagsProvider tagsProvider) { - this.tagsProvider = tagsProvider; + public void setKeyValuesProvider(BatchJobKeyValuesProvider keyValuesProvider) { + this.keyValuesProvider = keyValuesProvider; } @Override diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchJobTagsProvider.java b/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchJobKeyValuesProvider.java similarity index 84% rename from spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchJobTagsProvider.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchJobKeyValuesProvider.java index 6fc67cbb3..2ef1f6429 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchJobTagsProvider.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchJobKeyValuesProvider.java @@ -19,12 +19,12 @@ package org.springframework.batch.core.observability; import io.micrometer.observation.Observation; /** - * {@link Observation.TagsProvider} for {@link BatchJobContext}. + * {@link Observation.KeyValuesProvider} for {@link BatchJobContext}. * * @author Marcin Grzejszczak * @since 5.0 */ -public interface BatchJobTagsProvider extends Observation.TagsProvider { +public interface BatchJobKeyValuesProvider extends Observation.KeyValuesProvider { @Override default boolean supportsContext(Observation.Context context) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchJobObservation.java b/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchJobObservation.java index 66621c2ca..81f1170e3 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchJobObservation.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchJobObservation.java @@ -16,8 +16,8 @@ package org.springframework.batch.core.observability; +import io.micrometer.common.docs.KeyName; import io.micrometer.observation.docs.DocumentedObservation; -import io.micrometer.common.docs.TagKey; /** * Observation created around a Job execution. @@ -40,12 +40,12 @@ public enum BatchJobObservation implements DocumentedObservation { } @Override - public TagKey[] getLowCardinalityTagKeys() { + public KeyName[] getLowCardinalityKeyNames() { return JobLowCardinalityTags.values(); } @Override - public TagKey[] getHighCardinalityTagKeys() { + public KeyName[] getHighCardinalityKeyNames() { return JobHighCardinalityTags.values(); } @@ -55,14 +55,14 @@ public enum BatchJobObservation implements DocumentedObservation { } }; - enum JobLowCardinalityTags implements TagKey { + enum JobLowCardinalityTags implements KeyName { /** * Name of the Spring Batch job. */ JOB_NAME { @Override - public String getKey() { + public String getKeyName() { return "spring.batch.job.name"; } }, @@ -72,21 +72,21 @@ public enum BatchJobObservation implements DocumentedObservation { */ JOB_STATUS { @Override - public String getKey() { + public String getKeyName() { return "spring.batch.job.status"; } } } - enum JobHighCardinalityTags implements TagKey { + enum JobHighCardinalityTags implements KeyName { /** * ID of the Spring Batch job instance. */ JOB_INSTANCE_ID { @Override - public String getKey() { + public String getKeyName() { return "spring.batch.job.instanceId"; } }, @@ -96,7 +96,7 @@ public enum BatchJobObservation implements DocumentedObservation { */ JOB_EXECUTION_ID { @Override - public String getKey() { + public String getKeyName() { return "spring.batch.job.executionId"; } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchStepObservation.java b/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchStepObservation.java index 51b9e963d..7a1811cc8 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchStepObservation.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchStepObservation.java @@ -16,8 +16,8 @@ package org.springframework.batch.core.observability; +import io.micrometer.common.docs.KeyName; import io.micrometer.observation.docs.DocumentedObservation; -import io.micrometer.common.docs.TagKey; /** * Observation created around a step execution. @@ -40,12 +40,12 @@ public enum BatchStepObservation implements DocumentedObservation { } @Override - public TagKey[] getLowCardinalityTagKeys() { + public KeyName[] getLowCardinalityKeyNames() { return StepLowCardinalityTags.values(); } @Override - public TagKey[] getHighCardinalityTagKeys() { + public KeyName[] getHighCardinalityKeyNames() { return StepHighCardinalityTags.values(); } @@ -55,14 +55,14 @@ public enum BatchStepObservation implements DocumentedObservation { } }; - enum StepLowCardinalityTags implements TagKey { + enum StepLowCardinalityTags implements KeyName { /** * Name of the Spring Batch step. */ STEP_NAME { @Override - public String getKey() { + public String getKeyName() { return "spring.batch.step.name"; } }, @@ -72,7 +72,7 @@ public enum BatchStepObservation implements DocumentedObservation { */ STEP_TYPE { @Override - public String getKey() { + public String getKeyName() { return "spring.batch.step.type"; } }, @@ -82,7 +82,7 @@ public enum BatchStepObservation implements DocumentedObservation { */ JOB_NAME { @Override - public String getKey() { + public String getKeyName() { return "spring.batch.step.job.name"; } }, @@ -92,21 +92,21 @@ public enum BatchStepObservation implements DocumentedObservation { */ STEP_STATUS { @Override - public String getKey() { + public String getKeyName() { return "spring.batch.step.status"; } } } - enum StepHighCardinalityTags implements TagKey { + enum StepHighCardinalityTags implements KeyName { /** * ID of the Spring Batch step execution. */ STEP_EXECUTION_ID { @Override - public String getKey() { + public String getKeyName() { return "spring.batch.step.executionId"; } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchStepTagsProvider.java b/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchStepTagsProvider.java index 81440e9bc..9ec704545 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchStepTagsProvider.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/observability/BatchStepTagsProvider.java @@ -19,12 +19,12 @@ package org.springframework.batch.core.observability; import io.micrometer.observation.Observation; /** - * {@link Observation.TagsProvider} for {@link BatchStepContext}. + * {@link Observation.KeyValuesProvider} for {@link BatchStepContext}. * * @author Marcin Grzejszczak * @since 5.0 */ -public interface BatchStepTagsProvider extends Observation.TagsProvider { +public interface BatchStepTagsProvider extends Observation.KeyValuesProvider { @Override default boolean supportsContext(Observation.Context context) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/observability/DefaultBatchJobTagsProvider.java b/spring-batch-core/src/main/java/org/springframework/batch/core/observability/DefaultBatchJobKeyValuesProvider.java similarity index 66% rename from spring-batch-core/src/main/java/org/springframework/batch/core/observability/DefaultBatchJobTagsProvider.java rename to spring-batch-core/src/main/java/org/springframework/batch/core/observability/DefaultBatchJobKeyValuesProvider.java index 15754faa4..e70244e1e 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/observability/DefaultBatchJobTagsProvider.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/observability/DefaultBatchJobKeyValuesProvider.java @@ -15,30 +15,30 @@ */ package org.springframework.batch.core.observability; -import io.micrometer.common.Tags; +import io.micrometer.common.KeyValues; import org.springframework.batch.core.JobExecution; /** - * Default {@link BatchJobTagsProvider} implementation. + * Default {@link BatchJobKeyValuesProvider} implementation. * * @author Marcin Grzejszczak * @author Mahmoud Ben Hassine * @since 5.0 */ -public class DefaultBatchJobTagsProvider implements BatchJobTagsProvider { +public class DefaultBatchJobKeyValuesProvider implements BatchJobKeyValuesProvider { @Override - public Tags getLowCardinalityTags(BatchJobContext context) { + public KeyValues getLowCardinalityKeyValues(BatchJobContext context) { JobExecution execution = context.getJobExecution(); - return Tags.of(BatchJobObservation.JobLowCardinalityTags.JOB_NAME.of(execution.getJobInstance().getJobName()), + return KeyValues.of(BatchJobObservation.JobLowCardinalityTags.JOB_NAME.of(execution.getJobInstance().getJobName()), BatchJobObservation.JobLowCardinalityTags.JOB_STATUS.of(execution.getExitStatus().getExitCode())); } @Override - public Tags getHighCardinalityTags(BatchJobContext context) { + public KeyValues getHighCardinalityKeyValues(BatchJobContext context) { JobExecution execution = context.getJobExecution(); - return Tags.of(BatchJobObservation.JobHighCardinalityTags.JOB_INSTANCE_ID.of(String.valueOf(execution.getJobInstance().getInstanceId())), + return KeyValues.of(BatchJobObservation.JobHighCardinalityTags.JOB_INSTANCE_ID.of(String.valueOf(execution.getJobInstance().getInstanceId())), BatchJobObservation.JobHighCardinalityTags.JOB_EXECUTION_ID.of(String.valueOf(execution.getId()))); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/observability/DefaultBatchStepTagsProvider.java b/spring-batch-core/src/main/java/org/springframework/batch/core/observability/DefaultBatchStepTagsProvider.java index 4f6e83600..c5039f631 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/observability/DefaultBatchStepTagsProvider.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/observability/DefaultBatchStepTagsProvider.java @@ -15,7 +15,7 @@ */ package org.springframework.batch.core.observability; -import io.micrometer.common.Tags; +import io.micrometer.common.KeyValues; import org.springframework.batch.core.StepExecution; @@ -29,17 +29,17 @@ import org.springframework.batch.core.StepExecution; public class DefaultBatchStepTagsProvider implements BatchStepTagsProvider { @Override - public Tags getLowCardinalityTags(BatchStepContext context) { + public KeyValues getLowCardinalityKeyValues(BatchStepContext context) { StepExecution execution = context.getStepExecution(); - return Tags.of(BatchStepObservation.StepLowCardinalityTags.STEP_NAME.of(execution.getStepName()), + return KeyValues.of(BatchStepObservation.StepLowCardinalityTags.STEP_NAME.of(execution.getStepName()), BatchStepObservation.StepLowCardinalityTags.JOB_NAME.of(execution.getJobExecution().getJobInstance().getJobName()), BatchStepObservation.StepLowCardinalityTags.STEP_STATUS.of(execution.getExitStatus().getExitCode())); } @Override - public Tags getHighCardinalityTags(BatchStepContext context) { + public KeyValues getHighCardinalityKeyValues(BatchStepContext context) { StepExecution execution = context.getStepExecution(); - return Tags.of(BatchStepObservation.StepHighCardinalityTags.STEP_EXECUTION_ID.of(String.valueOf(execution.getId()))); + return KeyValues.of(BatchStepObservation.StepHighCardinalityTags.STEP_EXECUTION_ID.of(String.valueOf(execution.getId()))); } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java index 29405d53b..b4bdd031f 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java @@ -60,7 +60,7 @@ import org.springframework.util.ClassUtils; * @author Chris Schaefer * @author Mahmoud Ben Hassine */ -public abstract class AbstractStep implements Step, InitializingBean, BeanNameAware, Observation.TagsProviderAware { +public abstract class AbstractStep implements Step, InitializingBean, BeanNameAware, Observation.KeyValuesProviderAware { private static final Log logger = LogFactory.getLog(AbstractStep.class); @@ -74,7 +74,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw private JobRepository jobRepository; - private BatchStepTagsProvider tagsProvider = new DefaultBatchStepTagsProvider(); + private BatchStepTagsProvider keyValuesProvider = new DefaultBatchStepTagsProvider(); /** * Default constructor. @@ -202,7 +202,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw stepExecution.setStatus(BatchStatus.STARTED); Observation observation = BatchMetrics.createObservation(BatchStepObservation.BATCH_STEP_OBSERVATION.getName(), new BatchStepContext(stepExecution)) .contextualName(stepExecution.getStepName()) - .tagsProvider(this.tagsProvider) + .keyValuesProvider(this.keyValuesProvider) .start(); getJobRepository().update(stepExecution); @@ -414,7 +414,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw } @Override - public void setTagsProvider(BatchStepTagsProvider tagsProvider) { - this.tagsProvider = tagsProvider; + public void setKeyValuesProvider(BatchStepTagsProvider keyValuesProvider) { + this.keyValuesProvider = keyValuesProvider; } }