Skip to content

Pulsar publish span can't continue traceID from parent span when using transaction producer send message #12729

@coderzc

Description

@coderzc

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:
image

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

image image image

Javaagent or library instrumentation version

v1.32.1

Environment

JDK: 17
OS:

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageNew issue that requires triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions