Upgraded to Micrometer 1.10.0-SNAPSHOT
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
0b49e082a2
commit
a19eefa7fd
2
pom.xml
2
pom.xml
@@ -54,7 +54,7 @@
|
||||
<spring-framework.version>6.0.0-SNAPSHOT</spring-framework.version>
|
||||
<spring-retry.version>1.3.2</spring-retry.version>
|
||||
<spring-integration.version>6.0.0-SNAPSHOT</spring-integration.version>
|
||||
<micrometer.version>2.0.0-SNAPSHOT</micrometer.version>
|
||||
<micrometer.version>1.10.0-SNAPSHOT</micrometer.version>
|
||||
<jackson.version>2.13.2.2</jackson.version>
|
||||
|
||||
<!-- optional production dependencies -->
|
||||
|
||||
@@ -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<BatchJobTagsProvider> {
|
||||
InitializingBean, Observation.KeyValuesProviderAware<BatchJobKeyValuesProvider> {
|
||||
|
||||
protected static final Log logger = LogFactory.getLog(AbstractJob.class);
|
||||
|
||||
@@ -87,7 +87,7 @@ InitializingBean, Observation.TagsProviderAware<BatchJobTagsProvider> {
|
||||
|
||||
private StepHandler stepHandler;
|
||||
|
||||
private BatchJobTagsProvider tagsProvider = new DefaultBatchJobTagsProvider();
|
||||
private BatchJobKeyValuesProvider keyValuesProvider = new DefaultBatchJobKeyValuesProvider();
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
@@ -315,7 +315,7 @@ InitializingBean, Observation.TagsProviderAware<BatchJobTagsProvider> {
|
||||
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<BatchJobTagsProvider> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTagsProvider(BatchJobTagsProvider tagsProvider) {
|
||||
this.tagsProvider = tagsProvider;
|
||||
public void setKeyValuesProvider(BatchJobKeyValuesProvider keyValuesProvider) {
|
||||
this.keyValuesProvider = keyValuesProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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<BatchJobContext> {
|
||||
public interface BatchJobKeyValuesProvider extends Observation.KeyValuesProvider<BatchJobContext> {
|
||||
|
||||
@Override
|
||||
default boolean supportsContext(Observation.Context context) {
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<BatchStepContext> {
|
||||
public interface BatchStepTagsProvider extends Observation.KeyValuesProvider<BatchStepContext> {
|
||||
|
||||
@Override
|
||||
default boolean supportsContext(Observation.Context context) {
|
||||
|
||||
@@ -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())));
|
||||
}
|
||||
|
||||
@@ -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())));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<BatchStepTagsProvider> {
|
||||
public abstract class AbstractStep implements Step, InitializingBean, BeanNameAware, Observation.KeyValuesProviderAware<BatchStepTagsProvider> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user