-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Expected Behavior
The current tags for tracing spans are very limited and contain only a few relevant information. Opentelemetry defines all the recommended and required attributes a single message span should include. It would be nice to have them predefined by spring-kafka automatically instead of using the customizer explicitly. Even though customizing might work, we lack a few information on the customizer to follow otel standardization properly (used broker, consumergroup, partition for producer, etc.).
Current Behavior
The only tags currently included are spring related tags (e.g. spring.kafka.template) and do not follow any standard. There are other spring projects that already have proper otel tags defined (e.g. spring-data-mongodb).
I think it would be beneficial to have consistent standard support over different spring projects.
Context
To workaround this one can implement their own KafkaTemplateObservationConvention and define the necessary tags:
public class KafkaTemplateObservationConvention extends KafkaTemplateObservation.DefaultKafkaTemplateObservationConvention {
public static final KafkaTemplateObservation.DefaultKafkaTemplateObservationConvention INSTANCE =
new KafkaTemplateObservationConvention();
@Override
public KeyValues getLowCardinalityKeyValues(KafkaRecordSenderContext context) {
context.setRemoteServiceName(context.getBroker()); //peer.service -> should be the broker which is not available here
return KeyValues.of(KafkaTemplateObservation.TemplateLowCardinalityTags.BEAN_NAME.asString(),
context.getBeanName())
.and("messaging.system", "kafka")
.and("messaging.destination.kind", "topic")
//.and("messaging.kafka.partition", context.getCarrier().partition().toString()) //Partition is always null
//.and("messaging.kafka.message.offset", context.getCarrier().offset()) //Offset is not exposed
.and("messaging.destination.name", context.getDestination());
}
@Override
public String getContextualName(KafkaRecordSenderContext context) {
return context.getDestination() + " publish";
}
}As you can see some required/recommended information is missing on the customizer.