Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
coderzc opened this issue Nov 14, 2024 · 2 comments · May be fixed by #12731
Labels
bug Something isn't working needs triage New issue that requires triage

Comments

@coderzc
Copy link

coderzc commented Nov 14, 2024

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

@coderzc coderzc added bug Something isn't working needs triage New issue that requires triage labels Nov 14, 2024
@coderzc coderzc changed the title Pulsar publish span can't continue traceID from parent span when using transaction producer send message Pulsar publish span can't continue traceID from parent span when using transaction producer send message Nov 14, 2024
@coderzc
Copy link
Author

coderzc commented Nov 14, 2024

@dao-jun can you take a look?

@dao-jun
Copy link
Member

dao-jun commented Nov 14, 2024

TransactionImpl.registerProducedTopic will switch the thread, so it will break the trace. I'll try to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage New issue that requires triage
Projects
None yet
2 participants