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

fix: Handle IPv6 addresses in OTLP HTTP connection #1747

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

create2000
Copy link

Fixes #1721. This PR updates the Net::HTTP connection to handle IPv6 addresses correctly by using hostname instead of host.

@arielvalentin arielvalentin changed the title Fix ipv6 issue 1721 fix: Handle IPv6 addresses in OTLP HTTP connection Oct 14, 2024
@@ -109,7 +109,7 @@ def fetch_ssl_verify_mode
end

def http_connection(uri, ssl_verify_mode, certificate_file, client_certificate_file, client_key_file)
http = Net::HTTP.new(uri.host, uri.port)
http = Net::HTTP.new(uri.hostname, uri.port)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any unit tests that you may also include with this change would have exposed this bug?

e.g. setting the endpoint to "http://[::1]/v1/traces" and see the error goes away.

Copy link
Author

Choose a reason for hiding this comment

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

Are you proposing i create some unit tests?

Copy link
Contributor

Choose a reason for hiding this comment

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

@create2000 - It would be great to have unit tests for this change, especially if you can write some sort of regression-style test that demonstrates the bug was fixed due to your code updates.

Copy link
Author

Choose a reason for hiding this comment

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

How would you suggest I go about the regression-style test? This is my first time contributing, and I am contributing as an Outreachy Intern applicant.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the context, @create2000!

What I mean is to write a test that would fail without your change. You could undo your change, write a test that uses an IPv6 address, and watch it fail. Then, add your change back and see it pass. This means your test will protect against regressions in the code that may re-introduce the bug.

There may be an existing test you can adjust from the OTLP exporter gem to make it easier.
The file you could look at is exporter/otlp/test/opentelemetry/exporter/otlp/exporter_test.rb

@@ -0,0 +1 @@
--require spec_helper
Copy link
Contributor

Choose a reason for hiding this comment

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

This repository uses minitest, rather than RSpec as the testing framework.

Would you mind deleting the .rspec file and the spec/spec_helper.rb file?

If you're having trouble running the tests locally, you can do so by:

  1. Installing the bundle
$ bundle install
  1. Using Rake to run the tests
$ bundle exec rake tests

If this doesn't work, let us know and we can try to troubleshoot.

Copy link
Author

Choose a reason for hiding this comment

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

Alright

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.

opentelemetry-exporter-otlp: http_connection does not handle ipv6 host
3 participants