Skip to content

Upgraded to Micrometer 1.10.0-SNAPSHOT #4098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
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;
Expand All @@ -69,7 +69,7 @@
* @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);

Expand All @@ -87,7 +87,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware,

private StepHandler stepHandler;

private BatchJobTagsProvider tagsProvider = new DefaultBatchJobTagsProvider();
private BatchJobKeyValuesProvider keyValuesProvider = new DefaultBatchJobKeyValuesProvider();

/**
* Default constructor.
Expand Down Expand Up @@ -315,7 +315,7 @@ public final void execute(JobExecution execution) {
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()) {

Expand Down Expand Up @@ -465,8 +465,8 @@ private void updateStatus(JobExecution jobExecution, BatchStatus status) {
}

@Override
public void setTagsProvider(BatchJobTagsProvider tagsProvider) {
this.tagsProvider = tagsProvider;
public void setKeyValuesProvider(BatchJobKeyValuesProvider keyValuesProvider) {
this.keyValuesProvider = keyValuesProvider;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -40,12 +40,12 @@ public String getContextualName() {
}

@Override
public TagKey[] getLowCardinalityTagKeys() {
public KeyName[] getLowCardinalityKeyNames() {
return JobLowCardinalityTags.values();
}

@Override
public TagKey[] getHighCardinalityTagKeys() {
public KeyName[] getHighCardinalityKeyNames() {
return JobHighCardinalityTags.values();
}

Expand All @@ -55,14 +55,14 @@ public String getPrefix() {
}
};

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";
}
},
Expand All @@ -72,21 +72,21 @@ public String getKey() {
*/
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";
}
},
Expand All @@ -96,7 +96,7 @@ public String getKey() {
*/
JOB_EXECUTION_ID {
@Override
public String getKey() {
public String getKeyName() {
return "spring.batch.job.executionId";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -40,12 +40,12 @@ public String getContextualName() {
}

@Override
public TagKey[] getLowCardinalityTagKeys() {
public KeyName[] getLowCardinalityKeyNames() {
return StepLowCardinalityTags.values();
}

@Override
public TagKey[] getHighCardinalityTagKeys() {
public KeyName[] getHighCardinalityKeyNames() {
return StepHighCardinalityTags.values();
}

Expand All @@ -55,14 +55,14 @@ public String getPrefix() {
}
};

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";
}
},
Expand All @@ -72,7 +72,7 @@ public String getKey() {
*/
STEP_TYPE {
@Override
public String getKey() {
public String getKeyName() {
return "spring.batch.step.type";
}
},
Expand All @@ -82,7 +82,7 @@ public String getKey() {
*/
JOB_NAME {
@Override
public String getKey() {
public String getKeyName() {
return "spring.batch.step.job.name";
}
},
Expand All @@ -92,21 +92,21 @@ public String getKey() {
*/
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";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -29,17 +29,17 @@
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())));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* @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);

Expand All @@ -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.
Expand Down Expand Up @@ -202,7 +202,7 @@ public final void execute(StepExecution stepExecution) throws JobInterruptedExce
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);

Expand Down Expand Up @@ -414,7 +414,7 @@ else if (ex instanceof NoSuchJobException || ex.getCause() instanceof NoSuchJobE
}

@Override
public void setTagsProvider(BatchStepTagsProvider tagsProvider) {
this.tagsProvider = tagsProvider;
public void setKeyValuesProvider(BatchStepTagsProvider keyValuesProvider) {
this.keyValuesProvider = keyValuesProvider;
}
}