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

HttpURLConnection instrumentation does not mark trace as external #387

Closed
meiao opened this issue Aug 26, 2021 · 4 comments · Fixed by #885
Closed

HttpURLConnection instrumentation does not mark trace as external #387

meiao opened this issue Aug 26, 2021 · 4 comments · Fixed by #885
Assignees
Labels
bug Something isn't working as designed/intended

Comments

@meiao
Copy link
Contributor

meiao commented Aug 26, 2021

Description

When a transaction has an HTTP call using HttpURLConnection, the distributed traces for the HTTP call do show as being in the same transaction and not as a remote call.

Expected Behavior

These HTTP calls show as remotes, like calls that use Apache's HTTP client.

Steps to Reproduce

Have 2 servers with DT enabled.
From one server, make an HTTP call using HttpURLConnection to the other.
Check DT.

Your Environment

Java 16
Agent 7.2.0-SNAPSHOT
But most likely all other versions are affected.

@meiao meiao added the bug Something isn't working as designed/intended label Aug 26, 2021
@jasonjkeller
Copy link
Contributor

jasonjkeller commented May 17, 2022

It looks like this is because the httpurlconnection instrumentation doesn't utilize the newer NewRelic.getAgent().getTracedMethod().reportAsExternal API. The httpurlconnection instrumentation is ~7 years and predates the reportAsExternal API and doesn't look like it was ever updated when the API was introduced.

I think refactoring the httpurlconnection instrumentation similar to this commit (3acebd3
) so that it takes advantage of the newer reportAsExternal API should resolve the issue.

Note: There are problems with this commit that need to be fixed and tested still.

Incorrect external with existing instrumentation:
incorrect-external

Correct external with fixed instrumentation:
correct-external

@kford-newrelic
Copy link
Contributor

Found that additional code refactoring and testing is required, will not be able to make the 7.8.0 release with a fix. Targeting the next available release instead.

@contentfree
Copy link

contentfree commented Sep 27, 2023

It seems like this is now broken in a different way.

In this screenshot, you can see that the external service is correctly recognized as such (small green sliver) but the time inside the external service call is not included in the external service span. (It reports as something like 40 microseconds though the request actually took nearly a minute; the time reported as Application Code in the next line is actually time spent inside HttpURLConnection.post):
image

Could this be related to this change?

@meiao
Copy link
Contributor Author

meiao commented Sep 28, 2023

We have other problems with this instrumentation and are currently working on improving it.
You can track progress in this ticket: #1378

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as designed/intended
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants