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

The need for more granularity/clarity in CLIENT span conventions #1360

Closed
jkwatson opened this issue Jan 21, 2021 · 5 comments · Fixed by #1738
Closed

The need for more granularity/clarity in CLIENT span conventions #1360

jkwatson opened this issue Jan 21, 2021 · 5 comments · Fixed by #1738
Labels
area:semantic-conventions Related to semantic conventions priority:p2 Medium priority level release:allowed-for-ga Editorial changes that can still be added before GA since they don't require action by SIGs spec:trace Related to the specification/trace directory

Comments

@jkwatson
Copy link
Contributor

What are you trying to achieve?

Currently, the span specification reads, when describing span kinds:

CLIENT Indicates that the span describes a synchronous request to some remote service. This span is the parent of a remote SERVER span and waits for its response.

This seems fine on the surface, but when you get into the details of actually writing instrumentation (and auto-instrumentation in particular), things get murky very quickly. Multiple layers of an application-framework stack can (and do) consider themselves logically as CLIENTs, even if none of them is actually opening up TCP connections and writing bytes to the wire.

For example, let's take a typical java HTTP call. Here are some possible spans that might want to be created by auto-instrumentation:

  • JAX-RS HTTP client library makes a GET call
    • Apache HTTP client library makes a GET call
      • Java TCP stack opens up a socket
        • Java TCP stack requests that the OS makes a DNS lookup
        • Java TLS implementation negotiates TLS with the server

(details here might be off, but I think the idea is clear).

So, which of these operations should create a CLIENT span? If library instrumentation for JAX-RS decides it should be a CLIENT, how can the Apache HTTP client library instrumentation create spans at all, given that a CLIENT has already been created (although it can't tell that, since the parent span is write-only, and the kind is immutable after the span has been created!).

At the moment, instrumentation does not have a way to deal with this situation, with the spec as-written. We should solve this problem and provide clarity on how instrumentation should be written in order to handle scenarios like this one.

I will also note, that it becomes even more confusing and difficult when dealing with databases that implement their protocol over HTTP (elastic, for example). Now we have database CLIENT spans that really need HTTP CLIENT spans below them, with all the additional complexity of observing the underlying network stack, as decsribed above.

@jkwatson jkwatson added the spec:trace Related to the specification/trace directory label Jan 21, 2021
@jkwatson
Copy link
Contributor Author

Note: see this discussion in the java-instrumentation repository: open-telemetry/opentelemetry-java-instrumentation#1822

@Oberon00
Copy link
Member

Probably we have to live with that. It is impossible for the parent to know if there will be a child, as maybe the child is not instrumented.

This span is the parent of a remote SERVER span and waits for its response.

This is not true anyway, since the remote end might not be instrumented at all. Probably it should relaxed to say that it can also be an indirect parent.

@andrewhsu andrewhsu added priority:p2 Medium priority level release:allowed-for-ga Editorial changes that can still be added before GA since they don't require action by SIGs area:semantic-conventions Related to semantic conventions labels Jan 22, 2021
@reyang
Copy link
Member

reyang commented Jan 26, 2021

Related to #110

@blumamir
Copy link
Member

I find this attribute useful only when there is a possibility for ambiguity - the same looking span can be generated from the same instrumentation library for both incoming and outgoing operations.

For databases, I never need to look at the kind, as I know that the operation can only be outgoing request.

At least for my usage, it is most comfortable and makes the most sense to tag everything that is by nature "logical output" of the application as CLIENT/PRODUCER, and everything that is "logical input" to the application as SERVER/CONSUMER.

@jkwatson
Copy link
Contributor Author

jkwatson commented Jun 1, 2021

Unless there is strong objection, I will write up a spec change that allows nested logical CLIENT/SERVER/etc spans to unstick this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:semantic-conventions Related to semantic conventions priority:p2 Medium priority level release:allowed-for-ga Editorial changes that can still be added before GA since they don't require action by SIGs spec:trace Related to the specification/trace directory
Projects
None yet
5 participants