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

feat(excon)! Add a connect span to excon and add more span attributes to the tracer middleware #712

Merged
merged 27 commits into from
Nov 28, 2023

Conversation

misalcedo
Copy link
Contributor

@misalcedo misalcedo commented Nov 6, 2023

Added a span for TLS and TCP socket connections that matches the one in net_http. Also, I switched to using semantic convention constants over hard-coded strings where applicable. Lastly, I added a few more attributes to the request span.

The untraced_hosts option was added to mirror net_http and allow for selective exclusion of instrumentation.

The attributes before were: http.host, http.method, http.scheme, http.target and peer.service. I added peer name and port as those were also included in net_http.

Testing

The tests are based off the ones found in the net_http instrumentation for the connect span. In writing the tests I found 2 things worth calling out:

  • When disabling mocking, WebMock creates an extra span because it creates a new connection with a non-mocked middleware chain.
  • Excon does not handle TLS proxies properly in that is still uses plaintext TCP on a TLS proxy because the scheme is based purely on the end host.

Copy link

linux-foundation-easycla bot commented Nov 6, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@kaylareopelle
Copy link
Contributor

Hi @misalcedo, the excon suite is raising some rubocop offenses:

Offenses:

lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb:50:1: C: [Correctable] Layout/TrailingWhitespace: Trailing whitespace detected.
lib/opentelemetry/instrumentation/excon/patches/socket.rb:16:13: C: [Correctable] Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
            if untraced?
            ^^
test/opentelemetry/instrumentation/excon/instrumentation_test.rb:277:33: C: [Correctable] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
      assert_http_spans(scheme: "https")
                                ^^^^^^^

@arielvalentin
Copy link
Collaborator

@misalcedo check out this PR which has identified another use case where untraced? should be taken into consideration: https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/722/files

@misalcedo
Copy link
Contributor Author

@kaylareopelle thanks for the tip, I addressed the rubocop lints.

Copy link
Collaborator

@arielvalentin arielvalentin 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 this contribution 🎉

I have a few nits in there but otherwise LGTM!

misalcedo and others added 3 commits November 22, 2023 13:52
@arielvalentin
Copy link
Collaborator

@misalcedo we added the rubcop-performance linters on main and now there is a conflict sorry 😿

@misalcedo
Copy link
Contributor Author

@arielvalentin I addressed the merge conflict. Seems like I just needed to change .include? to .cover? for the status range chack.

@arielvalentin arielvalentin merged commit aedc42c into open-telemetry:main Nov 28, 2023
47 checks passed
@misalcedo misalcedo deleted the misalcedo/excon branch November 28, 2023 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants