Fix breaking changes in micrometer APIs

Related to https://github.com/micrometer-metrics/micrometer/pull/3310
This commit is contained in:
Mahmoud Ben Hassine
2022-07-27 15:30:30 +02:00
parent 932e93428e
commit 4cb15ca837
4 changed files with 21 additions and 18 deletions

View File

@@ -62,7 +62,7 @@ public enum BatchJobObservation implements DocumentedObservation {
*/
JOB_NAME {
@Override
public String getKeyName() {
public String asString() {
return "spring.batch.job.name";
}
},
@@ -72,7 +72,7 @@ public enum BatchJobObservation implements DocumentedObservation {
*/
JOB_STATUS {
@Override
public String getKeyName() {
public String asString() {
return "spring.batch.job.status";
}
}
@@ -86,7 +86,7 @@ public enum BatchJobObservation implements DocumentedObservation {
*/
JOB_INSTANCE_ID {
@Override
public String getKeyName() {
public String asString() {
return "spring.batch.job.instanceId";
}
},
@@ -96,7 +96,7 @@ public enum BatchJobObservation implements DocumentedObservation {
*/
JOB_EXECUTION_ID {
@Override
public String getKeyName() {
public String asString() {
return "spring.batch.job.executionId";
}
}

View File

@@ -62,7 +62,7 @@ public enum BatchStepObservation implements DocumentedObservation {
*/
STEP_NAME {
@Override
public String getKeyName() {
public String asString() {
return "spring.batch.step.name";
}
},
@@ -72,7 +72,7 @@ public enum BatchStepObservation implements DocumentedObservation {
*/
STEP_TYPE {
@Override
public String getKeyName() {
public String asString() {
return "spring.batch.step.type";
}
},
@@ -82,7 +82,7 @@ public enum BatchStepObservation implements DocumentedObservation {
*/
JOB_NAME {
@Override
public String getKeyName() {
public String asString() {
return "spring.batch.step.job.name";
}
},
@@ -92,7 +92,7 @@ public enum BatchStepObservation implements DocumentedObservation {
*/
STEP_STATUS {
@Override
public String getKeyName() {
public String asString() {
return "spring.batch.step.status";
}
}
@@ -106,7 +106,7 @@ public enum BatchStepObservation implements DocumentedObservation {
*/
STEP_EXECUTION_ID {
@Override
public String getKeyName() {
public String asString() {
return "spring.batch.step.executionId";
}
}

View File

@@ -32,8 +32,9 @@ public class DefaultBatchJobObservationConvention implements BatchJobObservation
public KeyValues getLowCardinalityKeyValues(BatchJobContext context) {
JobExecution execution = context.getJobExecution();
return KeyValues.of(
BatchJobObservation.JobLowCardinalityTags.JOB_NAME.of(execution.getJobInstance().getJobName()),
BatchJobObservation.JobLowCardinalityTags.JOB_STATUS.of(execution.getExitStatus().getExitCode()));
BatchJobObservation.JobLowCardinalityTags.JOB_NAME.withValue(execution.getJobInstance().getJobName()),
BatchJobObservation.JobLowCardinalityTags.JOB_STATUS
.withValue(execution.getExitStatus().getExitCode()));
}
@Override
@@ -41,8 +42,9 @@ public class DefaultBatchJobObservationConvention implements BatchJobObservation
JobExecution execution = context.getJobExecution();
return KeyValues.of(
BatchJobObservation.JobHighCardinalityTags.JOB_INSTANCE_ID
.of(String.valueOf(execution.getJobInstance().getInstanceId())),
BatchJobObservation.JobHighCardinalityTags.JOB_EXECUTION_ID.of(String.valueOf(execution.getId())));
.withValue(String.valueOf(execution.getJobInstance().getInstanceId())),
BatchJobObservation.JobHighCardinalityTags.JOB_EXECUTION_ID
.withValue(String.valueOf(execution.getId())));
}
}

View File

@@ -31,17 +31,18 @@ public class DefaultBatchStepObservationConvention implements BatchStepObservati
@Override
public KeyValues getLowCardinalityKeyValues(BatchStepContext context) {
StepExecution execution = context.getStepExecution();
return KeyValues.of(BatchStepObservation.StepLowCardinalityTags.STEP_NAME.of(execution.getStepName()),
return KeyValues.of(BatchStepObservation.StepLowCardinalityTags.STEP_NAME.withValue(execution.getStepName()),
BatchStepObservation.StepLowCardinalityTags.JOB_NAME
.of(execution.getJobExecution().getJobInstance().getJobName()),
BatchStepObservation.StepLowCardinalityTags.STEP_STATUS.of(execution.getExitStatus().getExitCode()));
.withValue(execution.getJobExecution().getJobInstance().getJobName()),
BatchStepObservation.StepLowCardinalityTags.STEP_STATUS
.withValue(execution.getExitStatus().getExitCode()));
}
@Override
public KeyValues getHighCardinalityKeyValues(BatchStepContext context) {
StepExecution execution = context.getStepExecution();
return KeyValues.of(
BatchStepObservation.StepHighCardinalityTags.STEP_EXECUTION_ID.of(String.valueOf(execution.getId())));
return KeyValues.of(BatchStepObservation.StepHighCardinalityTags.STEP_EXECUTION_ID
.withValue(String.valueOf(execution.getId())));
}
}