open-telemetry / opentelemetry-java-instrumentation

OpenTelemetry auto-instrumentation and instrumentation libraries for Java
https://opentelemetry.io
Apache License 2.0
1.99k stars 868 forks source link

Multiple Trace-ids are generated for Kafka sink connector #12322

Open jiten686 opened 2 months ago

jiten686 commented 2 months ago

Describe the bug

I am using mongo-kafka-connect-1.6.1-confluence sink connector. I have integrate the opentelemetry java agent with kafka-connect with following environmental variables. export JAVA_TOOL_OPTIONS=-javaagent:/otel_java_agent/opentelemetry-javaagent.jar export OTEL_TRACES_EXPORTER=otlp export OTEL_METRICS_EXPORTER=none export OTEL_LOGS_EXPORTER=none export OTEL_EXPORTER_OTLP_PROTOCOL=grpc export OTEL_PROPAGATORS=tracecontext,baggage export OTEL_EXPORTER_OTLP_ENDPOINT=http://. ..**

But I am seeing multiple traces are generated in kafka-connect.

What needs to be done so that single transaction will have same trace-id ?

Steps to reproduce

Use Opentelemetry JavaAgent 2.6.0. Integrate with kafka-connect with above environment variable

Expected behavior

Same trace-id needs to generate for single transaction.

Actual behavior

Multiple trace-ids are generated for single transaction.

Javaagent or library instrumentation version

Opentelemetry JavaAgent 2.6.0 , mongo-kafka-connect-1.6.1-confluence

Environment

JDK: OS:

Additional context

No response

laurit commented 2 months ago

@jiten686 is this duplicate of https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/12261

jiten686 commented 2 months ago

@laurit Not completely. Basically, what I am asking is, a Kafka sink connector send data from a Kafka topic to a MongoDB database. Multiple processes are performed within the connector during a single transaction. However, I am observing multiple trace IDs for each process, instead of a single trace ID being propagated across all processes for the same transaction.

laurit commented 2 months ago

Most likely this is going to require a new instrumentation. We'd welcome a contribution for this. Alternatively you may work with the authors of mongo-kafka-connect and have opentelemetry support added there. To increase the changes of anybody deciding to work on this issue consider providing a minimal application along with any necessary instructions that reproduces your issue.

vasantteja commented 1 month ago

@laurit If this is open can I take a stab at this?

vasantteja commented 1 week ago

Folks, I am working on this. I will open a pr once done.