-
Notifications
You must be signed in to change notification settings - Fork 278
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
httpurlconnection create one span per io #386
Conversation
c7c41c5
to
f43c4d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, just left a thought on potential problems, could be nothing.
try { | ||
// response code field is sometimes not populated until the getResponseCode method is explicitly called. | ||
// Calling getResponseCode() here will not trigger additional instrumentation because we have not reset the depth map. | ||
Tags.HTTP_STATUS.set(span, thiz.getResponseCode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this cause a side affect to the users by calling getResponseCode prematurely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also concerned about this... getResponseCode()
has some unfortunate side-effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getResponseCode() causes the response to be parsed, caching the result in the responseCode field. Is the concern the additional work done to parse and cache the response code, or is there something else to consider?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know, thanks. I'll revert back to using the field. We'll backlog some additional work to better handle some of the doOutput=true corner cases.
@gary-huang @tylerbenson Ran into some trouble in the case where Solution for now:
|
9691529
to
907b27c
Compare
} | ||
} | ||
span(2) { | ||
operationName "http.request" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there two spans for a single request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the case where connect() is called before getInputStream(). We can change the instrumentation to only trace getInputStream(), but we won't be able to inject headers at that point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the two spans have different operation names (or some other way to distinguish them) in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I used http.request.connect
for those cases.
In the future I think we can handle this use-case without creating two spans but it will require some follow-on work.
|
5241a37
to
9d0f343
Compare
9d0f343
to
ee594f8
Compare
connected
field and helper hash map to determine if io has occurredThe way we're using
connected
is an implementation detail of HttpURLConnection. There's no way to cleanly do this at the api level (that I know of). Not great, but it works for all builtin implementations of HttpURLConnection.Note that this will also not capture additional reads of the stream after the response stream is returned.
@gary-huang @tylerbenson Let me know what you think. Any concerns or anything you can think of to break this?