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

Ethon instrumentation #2260

Merged
merged 19 commits into from
Oct 20, 2023
Merged

Ethon instrumentation #2260

merged 19 commits into from
Oct 20, 2023

Conversation

fallwith
Copy link
Contributor

add instrumentation for Ethon

resolves #2187

add instrumentation for Ethon

resolves #2187
- add Ethon instrumentation to default source
- regenerate `newrelic.yml`
have the Ethon suite included in the http clients 2 list
2 of the shared HTTP client tests that Ethon was failing on have been
  re-enabled.

The tests were failing because of a stray typo made in the shared tests
file that had since been corrected.
- headers: seeing as we don't operate directly on the libcurl object, we
  need to propagate any added headers down to that object via
  `Ethon::Easy#headers=`
- errors: use the `Tracer` wrapper around `yield` to automatically
  notice any errors

With those changes, the 2 temporarily skipped tests are now enabled
- Define a response wrapper. It makes sense to have all
  HTTP client instrumentation follow this pattern.
- Enable Ethon instrumentation while using Typhoeus. When Typhoeus
  engages with Ethon, the child nodes will show up where expected
- Restore testing of the majority of cross HTTP client tests with Ethon
Response wrapper headers are different from request wrapper headers.
Parse the response headers string to set the response wrapper headers
properly
When `Ethon::Multi#perform` is invoked, create a parent segment for the
`Ethon::Multi` instance and a child segment for each `Ethon::Easy`
instance that exists in the `Ethon::Multi#easy_handles` array.
entry for Ethon instrumentation
Accommodate for both the Typhoeus and Ethon instrumentation being active
at the same time (the default)
@fallwith fallwith marked this pull request as ready for review October 18, 2023 01:31
For an instance of `Ethon::Easy`, consider a `#return_code` result not
equal to `:ok` to be the indicator of an error instead of the
`#response_code` being equal to `0`. With direct Ethon usage, these
equality checks seem interchangeable but with Typhoeus the underyling
easy object is left with a 0 for its response code on success.
- pass 'Ethon::Easy' as a string to `prepend_instrument` to ensure that
  the gem's class name is referred to with the `::` bit intact
- given that `Ethon::Easy` doesn't bother setting an HTTP action/verb in
  many cases and defers to Curl, let's just use `'GET'` as a default
  value
- convert 'unknownhost' to 'UNKNOWN_HOST' to fit our naming standards

executes do
if use_prepend?
# NOTE: to prevent a string like 'Ethon::Easy' from being converted into
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice comment I didn't know prepend_instrument supported a 3rd arg

The shared http client tests will cover gleaning the host from the
request headers. Tests have been added to test the other two branches
for obtaining a host - the URI instance, and a default string value.
hannahramadan
hannahramadan previously approved these changes Oct 19, 2023
Copy link
Contributor

@hannahramadan hannahramadan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing live ✨

kaylareopelle
kaylareopelle previously approved these changes Oct 19, 2023
After some extensive testing (thanks, @kaylareopelle) we've decided to
disable Ethon instrumentation in the presence of Typhoeus. We already
create `Typhoeus/GET` segments for each instance of `Typhoeus::Request`
and seeing an additional `Ethon::Easy/GET` segment really just seems
to duplicate the number of HTTP requests the app performed. Given that
all of the information from an `Ethon::Easy/GET` segment is already
contained in the `Typhoeus/GET` segment, it's better to prevent the
duplication.
@fallwith fallwith dismissed stale reviews from kaylareopelle and hannahramadan via bbf0a2f October 19, 2023 22:52
We've decided to disable Ethon instrumentation when Typhoeus is used and
to allow the higher level segments to exist without confusion of
seemingly duplicate lower level ones. Fix the shared test cases
accordingly.
kaylareopelle
kaylareopelle previously approved these changes Oct 20, 2023
Copy link
Contributor

@kaylareopelle kaylareopelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good to merge. I saw two small cleanup things.

lib/new_relic/agent/instrumentation/ethon.rb Outdated Show resolved Hide resolved
test/new_relic/http_client_test_cases.rb Outdated Show resolved Hide resolved
- correct `prepend_instrumentation` comment
- revert `typhoeus?` helper now that only a lone caller remains
@fallwith
Copy link
Contributor Author

This is good to merge. I saw two small cleanup things.

Thanks very much! Cleanup addressed with 285de8a

@github-actions
Copy link
Contributor

SimpleCov Report

Coverage Threshold
Line 94.16% 94%
Branch 85.72% 85%

Copy link
Contributor

@kaylareopelle kaylareopelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦅

@fallwith fallwith merged commit 0b486ca into dev Oct 20, 2023
25 checks passed
@fallwith fallwith deleted the ethon branch October 20, 2023 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add Instrumentation for Ethon
3 participants