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

Update ClientRequest HTTPS determination #3577

Merged
merged 5 commits into from
Jan 13, 2023

Conversation

MrAlias
Copy link
Contributor

@MrAlias MrAlias commented Jan 6, 2023

The ClientRequest function will only report a peer port attribute if that peer port differs from the standard 80 for HTTP and 443 for HTTPS. In determining if the request is for HTTPS use the request URL scheme. This is not perfect. If a user doesn't provide a scheme this will not be correctly detected. However, the current approach of checking if the TLS field is non-nil will always be wrong, requests made by client ignore this field and it is always nil. Therefore, switching to using the URL field is the best we can do without having already made the request.

Closes #3528

The ClientRequest function will only report a peer port attribute if
that peer port differs from the standard 80 for HTTP and 443 for HTTPS.
In determining if the request is for HTTPS use the request URL scheme.
This is not perfect. If a user doesn't provide a scheme this will not be
correctly detected. However, the current approach of checking if the
`TLS` field is non-nil will always be wrong, requests made by client
ignore this field and it is always nil. Therefore, switching to using
the URL field is the best we can do without having already made the
request.
@codecov
Copy link

codecov bot commented Jan 6, 2023

Codecov Report

Merging #3577 (1858a9a) into main (640a0cd) will decrease coverage by 0.0%.
The diff coverage is 100.0%.

❗ Current head 1858a9a differs from pull request most recent head e09d53c. Consider uploading reports for the commit e09d53c to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #3577     +/-   ##
=======================================
- Coverage   78.9%   78.8%   -0.1%     
=======================================
  Files        170     169      -1     
  Lines      12460   12437     -23     
=======================================
- Hits        9834    9811     -23     
  Misses      2417    2417             
  Partials     209     209             
Impacted Files Coverage Δ
semconv/internal/v2/http.go 100.0% <100.0%> (ø)
bridge/opentracing/wrapper.go 100.0% <0.0%> (ø)
bridge/opentracing/provider.go

@MrAlias MrAlias added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Jan 6, 2023
@dmathieu
Copy link
Member

dmathieu commented Jan 7, 2023

Shouldn't there be tests?

@MrAlias MrAlias added this to the Release v1.12.0 milestone Jan 12, 2023
@MrAlias MrAlias merged commit 4286352 into open-telemetry:main Jan 13, 2023
@MrAlias MrAlias deleted the semconv-client-https-port branch January 13, 2023 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTPClientAttributesFromHTTPRequest always sets http.scheme to http
5 participants