Description
Please describe the problem you are having with the documentation. Is information missing, inaccurate, or unclear? Tell us about the context where you encountered the problem so we can understand how to address it.
There is missing information for MicroProfile Telemetry (versions 1.0, 1.1 and 2.0). Specifically, in the manual instrumentation section.
We currently show:
@ApplicationScoped
class SpanBean {
@WithSpan("name")
void spanName() {
...
}
@WithSpan
void spanArgs(@SpanAttribute(value = "arg") String arg) {
...
}
}
It would be helpful for users to know that@WithSpan
adds a CDI interceptor and CDI interceptors are only called when you call the method directly on an object which was injected or looked up from CDI. They don't get called when you call a public method within the same class. Therefore in the above example, if there was code in spanName() that called the spanArgs(arg) method, a child span would not be created for spanArgs(arg). If a child span is desired when spanArgs(args) is called internally, the @WithSpan annotation should not be used. Instead, a Tracer and spanBuilder should be used like the folliowing example that is already in the docs:
@Inject private Tracer tracer;
@GET
public String myMethod() {
...
Span newSpan = tracer.spanBuilder("QueryDatabase").startSpan();
try (Scope s = newSpan.makeCurrent()) {
queryDatabase();
} finally {
newSpan.end();
}
...
}