How to add custom span tag in couchbase spans in opentelemetry in spring3 micrometer tracing?

Hi ,
I am using spring boot with couchbase with below dependencies.

    <dependency>
        <groupId>com.couchbase.client</groupId>
        <artifactId>java-client</artifactId>
        <version>3.4.8</version>
    </dependency>

    <dependency>
        <groupId>com.couchbase.client</groupId>
        <artifactId>tracing-opentelemetry</artifactId>
        <version>1.2.8</version>
    </dependency>

I am able to see the spans for couchbase transaction and want to add some custom spans tag in existing span instead of creating new one.

The main requirement is, add result of query as span tag(db.result) in existing span. pls see the uploaded image.

Hi @singh25anuj
I’m sorry but that is not possible to achieve. Please create a ‘wrapper’ span in the application with any attributes you choose, and then pass it down in the options.

1 Like

Hi @graham.pople

if it is not possible, then can we create a child span of Query span and put the result of query in that child span?

OR

Some how can achieve this using AOP concept(aspectJ)?

And , As you mentioned about wrapper span and put it in options, Can you please elaborate this.

I can create span but how to use it in options.?
Span span = tracer.nextSpan().tag(“test”,“test”).name(“custom_span”);

Thanks!!

options for all operation methods have a parentSpan()

options.parentSpan(span)

https://docs.couchbase.com/sdk-api/couchbase-java-client/com/couchbase/client/java/CommonOptions.html#parentSpan(com.couchbase.client.core.cnc.RequestSpan)

Sorry, the former isn’t supported. As for the latter, I’m not experienced enough with AOP to say for sure, but I don’t think so.
However - if you use the technique above to provide your own span, for which our query span willl become a child. Then you can attach whatever attributes and events to that span you want - including the result of the query.

1 Like

Thanks ! @graham.pople for your response.

But I want immediate child span of Query Span and put the query result in that child Span.

Could you please suggest any work around for this requirement?

Thanks.!!

Hi @singh25anuj
Apologies, but that is not supported.