question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question - Creating custom spans in functions

See original GitHub issue

I have just started to explore distributed tracing and have a question regarding this. I want to create a Span inside the parseDonutInfo() to trace the time taken to complete the function call. https://github.com/opentracing-contrib/java-opentracing-walkthrough/blob/master/microdonuts/src/main/java/com/otsample/api/ApiContextHandler.java#L85

In order to do that, I create a span -

try (Span parseDonutsInfoSpan =
                GlobalTracer.get().buildSpan("parseDonutsInfo_span")start()) {}

However, this span doesn’t get included along with the parent Span. It is present as a separate trace in Zipkin UI. How do I ensure that doPost function is the parentSpan of parseDonutsInfo().

Thanks, Let me know if you need any more details.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jorgheymanscommented, Jul 27, 2017

AFAIU since the parent span was put as an attribute on the request in doPost (just before the call to parseDonutsInfo), you could just do this:

        static DonutRequest[] parseDonutsInfo(HttpServletRequest request)
            throws IOException
        {
            Span parentSpan = (Span) request.getAttribute("span");
            Span parseDonutsInfoSpan = GlobalTracer.get().buildSpan("parseDonutsInfo_span").asChildOf(parentSpan)
                .start();
          ... 
          parseDonutsInfoSpan.finish();
0reactions
iamsurya-devcommented, Aug 2, 2017

Thanks for the comment @bhs ! It looks like https://github.com/opentracing-contrib/java-opentracing-walkthrough/pull/3 is using activeSpan(). I’ll also try it out from my end.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Two Quick Ways to Create Spans with Kamon Telemetry
Learn how to create Spans programmatically using Kamon Telemetry's helper functions and annotations.
Read more >
adding custom data to the spring cloud spans - Stack Overflow
I would like to add a custom id that will be propagated from the initial incoming span (at zuul entry) on through all...
Read more >
Creating custom traces with the OpenTelemetry SDK for Java
This video shows how to use the OpenTelemetry SDK for Java to instrument a microservice to produce custom spans. It shows the difference ......
Read more >
Custom spans | APM Node.js Agent Reference [3.x] - Elastic
This is an example of how to use custom spans. For general information about the Elastic APM Node.js Span API, see the Span...
Read more >
Spancat: a new approach for span labeling - Explosion AI
The suggester is a custom function that extracts possible span ... ner and spancat led to vastly different approaches to the same problem....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found