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

[otlpexporter] support validation for dns:https:// and dns:https:/// #10450

Merged

Conversation

codeboten
Copy link
Contributor

This allows users to continue using the recommended dns:https://authority/host:port notation when needing to specify a custom authority.

Fixes #10449

This allows users to continue using the recommended dns:https://authority/host:port notation
when needing to specify a custom authority.

Fixes open-telemetry#10449

Signed-off-by: Alex Boten <[email protected]>
Signed-off-by: Alex Boten <[email protected]>
@codeboten codeboten requested a review from a team as a code owner June 20, 2024 20:37
Copy link

codecov bot commented Jun 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.34%. Comparing base (e60ea2a) to head (28f7432).
Report is 16 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10450      +/-   ##
==========================================
- Coverage   92.35%   92.34%   -0.01%     
==========================================
  Files         386      393       +7     
  Lines       18408    18621     +213     
==========================================
+ Hits        17001    17196     +195     
- Misses       1053     1068      +15     
- Partials      354      357       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -134,6 +134,17 @@ func TestUnmarshalInvalidConfig(t *testing.T) {
func TestValidDNSEndpoint(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig().(*Config)
cfg.Endpoint = "dns:https:///backend.example.com:4317"
cfg.Endpoint = "dns:https://backend.example.com:4317"
Copy link
Member

Choose a reason for hiding this comment

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

Is this a valid dns endpoint? I though it would need either /// in a row or another / somewhere to separate the authority and the path

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's a good point, according to the grpc docs, the following is valid:

dns:[//authority/]host[:port] -- DNS (default)

I don't know how much more validation we should be introducing here

Copy link
Member

Choose a reason for hiding this comment

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

The new string looks invalid to me, I'm surprised an error is not returned. I'm interpreting the regex as "if // is present, there must be a third /". What am I missing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let me add a test for this case. i agree that it should return an error

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see how this test works now. Currently the validation only checks that there is a port and that it is a valid integer, nothing else. We should add full dns endpoint validation, but since the current functionality breaks users ability to use authorities in their dns endpoint I think we should add that later and merge this now.

For the sake of having a proper endpoint:

Suggested change
cfg.Endpoint = "dns:https://backend.example.com:4317"
cfg.Endpoint = "dns:https://authority/backend.example.com:4317"

Copy link
Member

Choose a reason for hiding this comment

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

created #10488

exporter/otlpexporter/config_test.go Show resolved Hide resolved
Signed-off-by: Alex Boten <[email protected]>
@codeboten codeboten changed the title [configgrpc] support validation for dns:https:// and dns:https:/// [otlpexporter] support validation for dns:https:// and dns:https:/// Jun 20, 2024
@TylerHelmuth TylerHelmuth added the ready-to-merge Code review completed; ready to merge by maintainers label Jul 1, 2024
@dmitryax dmitryax merged commit fd36d05 into open-telemetry:main Jul 1, 2024
50 of 66 checks passed
@github-actions github-actions bot added this to the next release milestone Jul 1, 2024
@codeboten codeboten deleted the codeboten/remove-additional-slash branch July 2, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[configgrpc] endpoint validation causes failures in dns resolution
6 participants