Align observations of @Scheduled with OTel conventions
This commit updates the `ScheduledTaskObservationDocumentation` to better align the contributed KeyValues with OpenTelemetry conventions for observations of code executions. Instead of a "target.type" key with the bean class simple name, this is now contributing the canonical class name of the bean under the "code.namespace" key. The "method.name" key is renamed to "code.function" and its values remain unchanged. Closes gh-30721
This commit is contained in:
@@ -53,7 +53,15 @@ public class DefaultScheduledTaskObservationConvention implements ScheduledTaskO
|
||||
|
||||
@Override
|
||||
public KeyValues getLowCardinalityKeyValues(ScheduledTaskObservationContext context) {
|
||||
return KeyValues.of(exception(context), methodName(context), outcome(context), targetType(context));
|
||||
return KeyValues.of(codeFunction(context), codeNamespace(context), exception(context), outcome(context));
|
||||
}
|
||||
|
||||
protected KeyValue codeFunction(ScheduledTaskObservationContext context) {
|
||||
return KeyValue.of(LowCardinalityKeyNames.CODE_FUNCTION, context.getMethod().getName());
|
||||
}
|
||||
|
||||
protected KeyValue codeNamespace(ScheduledTaskObservationContext context) {
|
||||
return KeyValue.of(LowCardinalityKeyNames.CODE_NAMESPACE, context.getTargetClass().getCanonicalName());
|
||||
}
|
||||
|
||||
protected KeyValue exception(ScheduledTaskObservationContext context) {
|
||||
@@ -63,10 +71,6 @@ public class DefaultScheduledTaskObservationConvention implements ScheduledTaskO
|
||||
return EXCEPTION_NONE;
|
||||
}
|
||||
|
||||
protected KeyValue methodName(ScheduledTaskObservationContext context) {
|
||||
return KeyValue.of(LowCardinalityKeyNames.METHOD_NAME, context.getMethod().getName());
|
||||
}
|
||||
|
||||
protected KeyValue outcome(ScheduledTaskObservationContext context) {
|
||||
if (context.getError() != null) {
|
||||
return OUTCOME_ERROR;
|
||||
@@ -77,8 +81,4 @@ public class DefaultScheduledTaskObservationConvention implements ScheduledTaskO
|
||||
return OUTCOME_SUCCESS;
|
||||
}
|
||||
|
||||
protected KeyValue targetType(ScheduledTaskObservationContext context) {
|
||||
return KeyValue.of(LowCardinalityKeyNames.TARGET_TYPE, context.getTargetClass().getSimpleName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,22 +56,22 @@ public enum ScheduledTaskObservationDocumentation implements ObservationDocument
|
||||
public enum LowCardinalityKeyNames implements KeyName {
|
||||
|
||||
/**
|
||||
* {@link Class#getSimpleName() Simple name} of the target type that owns the scheduled method.
|
||||
* Name of the method that is executed for the scheduled task.
|
||||
*/
|
||||
TARGET_TYPE {
|
||||
CODE_FUNCTION {
|
||||
@Override
|
||||
public String asString() {
|
||||
return "target.type";
|
||||
return "code.function";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Name of the method that is executed for the scheduled task.
|
||||
* {@link Class#getCanonicalName() Canonical name} of the target type that owns the scheduled method.
|
||||
*/
|
||||
METHOD_NAME {
|
||||
CODE_NAMESPACE {
|
||||
@Override
|
||||
public String asString() {
|
||||
return "method.name";
|
||||
return "code.namespace";
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user