Pulsar `publish` span can't continue traceID from parent span when using `transaction` producer send message
coderzc opened this issue · 2 comments
coderzc commented
Describe the bug
Pulsar publish
span can't continue traceID from parent span when using transaction producer send message
Steps to reproduce
public static void main(String[] args) throws PulsarClientException {
String serviceUrl = "pulsar://localhost:6650";
String topic = "my-topic";
PulsarClient client = PulsarClient.builder()
.serviceUrl(serviceUrl)
.enableTransaction(true)
.build();
Producer<String> producer = client.newProducer(Schema.STRING)
.enableBatching(false)
.topic(topic)
.create();
Transaction txn = null;
Tracer tracer = GlobalOpenTelemetry.getTracer("myapp");
Span span = tracer.spanBuilder("root span").startSpan();
try (Scope __ = span.makeCurrent()) {
txn = client.newTransaction().withTransactionTimeout(10, TimeUnit.SECONDS).build().get();
producer.newMessage(txn).value("msg1").send();
txn.commit().get();
} catch (Exception e) {
txn.abort().join();
throw new RuntimeException(e);
} finally {
span.end();
}
producer.close();
client.close();
}
Expected behavior
Pulsar publish
span can continue traceID from parent span when using transaction producer send message
The following is the trace of don't use transactions to send data:
Actual behavior
Pulsar publish
span can't continue traceID from parent span when using transaction producer send message
When sending data using transactions, the thread ID changed, not sure if it is related to it
Javaagent or library instrumentation version
v1.32.1
Environment
JDK: 17
OS:
Additional context
dao-jun commented
TransactionImpl.registerProducedTopic
will switch the thread, so it will break the trace. I'll try to fix it.