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

Merge follow-up span that carry additional attributes with its parent #81

Open
pavolloffay opened this issue Dec 2, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@pavolloffay
Copy link
Member

pavolloffay commented Dec 2, 2020

HTTP client response instrumentation in Java agent captures the body after the span has been finished. This instrumentation instruments input stream and the body is usually read after the client request is closed. We have chosen to do it this way to minimize interactions with the client app.

The body attribute is added to the newly created and immediately finished span that is a child of the HTTP client span - https://github.com/hypertrace/javaagent/blob/main/instrumentation/apache-httpclient-4.0/src/main/java/io/opentelemetry/instrumentation/hypertrace/apachehttpclient/v4_0/InputStreamUtils.java#L53.

The platform will have to deal with this either by merging the follow-up span with its parent or by dealing with the fact that some attributes are captured in the child span.

EDIT1: another example from JAX-RS client https://github.com/hypertrace/javaagent/pull/159/files#diff-bc3f663e3c15fe35183bc490b01d9680a1a0b28820b99b1473bcf50b6b301ae9R65

@mohit-a21
Copy link
Contributor

Is this going to be a framework-specific behavior?

TRACER
          .spanBuilder("additional-data")
          .setParent(Context.root().with(span))
          .setAttribute(attributeKey, value)
          .startSpan()
          .end();

Here, the name of the span seems to be additional-data, right? Will that be an identifier for such spans?

@jcchavezs
Copy link
Contributor

jcchavezs commented Dec 2, 2020 via email

@pavolloffay
Copy link
Member Author

pavolloffay commented Dec 3, 2020

Here, the name of the span seems to be additional-data, right? Will that be an identifier for such spans?

We can agree on different names.

Second, this looks like a workaround just because of the nature of java
instrumentation so I am not sure we should do these kind of specifics
because that can end up in lots of custom logic for different agents.

A workaround for what? When the response body is read the client span (span created in the HTTP client for the outbound request) is finished. This depends on the HTTP client framework, but there are such frameworks.

would point instead into the direction of update spans after reporting
rather than creating a new span. This is, reporting two versions of the
same span (same ID) with complimentary attributes. This sounds to me
something that makes more sense not only for this case but also for async
stuff.

There are a couple of issues with your proposal:

  1. this complicates SDK, none of the SDKs we use supports such functionality.
  2. the platform has to deal with the multiple flushes as well - probably in a similar way as reporting additional span with additional attributes.

@mohit-a21
Copy link
Contributor

This is, reporting two versions of the same span (same ID) with complimentary attributes.

Is versioning of span id a thing? Does any of the existing tracing platform support that? (not suggesting that if it's not there, we should not do it.)

@pavolloffay
Copy link
Member Author

Is versioning of span id a thing? Does any of the existing tracing platform support that? (not suggesting that if it's not there, we should not do it.)

No, there is no versioning of span id. I think zipkin brave or any other zipkin SDK supported multiple flushes of the same spa. I don't 'know how it is implemented but it might be done in two ways - 1. allow multiple flushes before and span finish and 2. allow flushes at any time. If the 1. applies it means that the span has to be finished once the body is read - this means wrong timing information.

Alternatively I could create a span for reading the body. That would start when the read begins and finishes when the stream is closed. it can provide some valuable timing info, but additional work on the platform will be still required.

@jcchavezs
Copy link
Contributor

jcchavezs commented Mar 8, 2021

Alternatively I could create a span for reading the body. That would start when the read begins and finishes when the stream is closed. it can provide some valuable timing info, but additional work on the platform will be still required.

I think this is a good idea. Can we do that?

No, there is no versioning of span id. I think zipkin brave or any other zipkin SDK supported multiple flushes of the same spa. I don't 'know how it is implemented but it might be done in two ways - 1. allow multiple flushes before and span finish and 2. allow flushes at any time. If the 1. applies it means that the span has to be finished once the body is read - this means wrong timing information.

Zipkin keeps both span object in storages and do the merge on UI for representation. Search does not need to know about this merge as it will just look into the two objects.

@jcchavezs
Copy link
Contributor

jcchavezs commented Mar 8, 2021

I am not sure if this is late yet or not but I have some suggestion to the proposal. I we are determined to do the merge then what if we create such span named it additional_data with attributes _hypertrace_additional_data_for=${spanID} and _hypertrace_additional_data_annotation=${operation} then we know deterministically what is the span we aim for and what is the operation about. Also we can turn the duration of that span as annotation in the target span with ${operation}_start and ${operation}_end.

@kotharironak kotharironak added the enhancement New feature or request label Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants