OpenLiberty / open-liberty

Open Liberty is a highly composable, fast to start, dynamic application server runtime environment
https://openliberty.io
Eclipse Public License 2.0
1.14k stars 587 forks source link

Updte documentation for Telemetry WithSpan #29635

Open yasmin-aumeeruddy opened 1 week ago

yasmin-aumeeruddy commented 1 week ago

This doc ought to have some sort of note to explain that internal methods cannot be annoted with @WithSpan

For example, a child span would not be created by doing this but users may expect it to do so:

@GET
@Path("/{id}")
@WithSpan("Parent")
public void parentSan(@PathParam("id") @SpanAttribute("Id") Long id) {
    // Call the child span method
    childSpan(url);
}

@WithSpan("Child Find By Id")
public void childSpan(URL url) {
    // Print the current span ID within the child span
    Span.current().setAttribute("Child Span ID", Span.current().getSpanContext().getSpanId());
    System.out.println("Child Span ID after parent scope: " + Span.current().getSpanContext().getSpanId());
    System.out.println("Child Trace ID after parent scope: " + Span.current().toString());
}
yasmin-aumeeruddy commented 6 days ago

Docs issue: https://github.com/OpenLiberty/docs/issues/7568