Skip to content

No elegant way to get span in Kafka ErrorHandler #1501

@AntonKuzValid

Description

@AntonKuzValid

I need a way to get span in Kafka ErrorHanlder. I do the next thing in error handler -

    @Override
      public void handle(Exception ex, ConsumerRecord<?, ?> consumerRecord) {
        var curSpan = this.kafkaTracing.nextSpan(consumerRecord).name("on-message").start()
       try (Tracer.SpanInScope ws = tracer.withSpanInScope(curSpan)) {
      log.error(ex);
        } finally {
      span.finish();
    }
  }

But method in KafkaTracing nextSpan() - clear all headers before error handler do its job. And KafkaTracing if final and i can't inherit from it. I have a question - is it a bug that you don't give an opportunity not to remove headers from ConsumerRecord?

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions