open-telemetry / open-telemetry/opentelemetry-java-instrumentation

Trace/span lost during stateful processing in Kafka streams

Open
#6,569 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

repro provided
Dominant language
Java
Stars
2.6k
Forks
1.2k
Avg merge
2d 18h
Merged PRs (30d)
228

Description

Discussed in https://github.com/open-telemetry/opentelemetry-java-instrumentation/discussions/6407

Originally posted by paulklos August 2, 2022
Hi,

We have an application that consumes messages from a Kafka topic. It's configured with Kafka bindings using Spring Cloud Stream.

One of our processes uses does an aggregation on a KStream, which results in a KTable, which is then converted back into a KStream and picked up by the next processor.

The whole process consists of 4 processors.

The application is instrumented with opentelemetry-javaagent.jar, the latest version.

Up until the aggregation we get the same trace id in our log messages, and a different span id in each processor, which is very nice, and exactly what we would expect.

But after the aggregation the span and trace ids disappear. Inspection in the debugger of the current span shows only zeros.

Is this a known limitation, or is there something we can configure to have proper propagation?

I created a demo project to illustrate the issue. It can be found here.

The README describes the steps to take.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked streams-instrumentation demo project and follow the reproduction steps in its README. Trace the KStream aggregation into the KTable, back to the KStream, and through the next processor using the opentelemetry-javaagent.jar setup. Done means determining whether trace and span context can be preserved after aggregation, or clearly documenting the limitation and configuration needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kafka
Domain
observability, stream-processing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.