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

otelhttptrace: add TLS info to the "http.tls" span #5563

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

Conversation

dotwaffle
Copy link

I noticed that the http.tls span was not including any useful information for otelhttptrace, and considering httptrace is supposed to show excess debug information about an HTTP connection, I figured it would be good to add some simple attributes on that span.

When committing, I noticed that the golangci-lint checks were failing because of some deprecated semconv functions, namely semconv.NetHostName(), so I fixed them to what those values they set are to eliminate the linter failures. It looks like net.host.name has been replaced with server.address in semconv, but I didn't want to break existing code -- happy to change them to the new semconv version if requested!

@dotwaffle dotwaffle requested review from dmathieu and a team as code owners May 12, 2024 07:06
Copy link

linux-foundation-easycla bot commented May 12, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@dmathieu
Copy link
Member

Please don't change the semconv attributes, despite the deprecations. This work is happening in other PRs, as part of #5400.

@dotwaffle
Copy link
Author

Ok, noted. How would you like me to proceed for the time being? Revert to 1.20 and manually enter the attribute keys? Is there any merit in the idea proposed?

@dmathieu
Copy link
Member

I think we could add the new attributes as string for now.

@dotwaffle
Copy link
Author

Super, I'll make the changes and come back to you. Thanks!

@dotwaffle
Copy link
Author

Sorry for the delay, hopefully that's more acceptable now! Let me know if you want anything else changing!

Copy link

codecov bot commented May 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.3%. Comparing base (a91e60b) to head (4876128).

Current head 4876128 differs from pull request most recent head de7bef7

Please upload reports for the commit de7bef7 to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #5563   +/-   ##
=====================================
  Coverage   63.2%   63.3%           
=====================================
  Files        194     194           
  Lines      11983   11990    +7     
=====================================
+ Hits        7585    7592    +7     
  Misses      4181    4181           
  Partials     217     217           
Files Coverage Δ
...on/net/http/httptrace/otelhttptrace/clienttrace.go 83.1% <100.0%> (+3.3%) ⬆️

... and 2 files with indirect coverage changes

@dotwaffle dotwaffle force-pushed the otelhttptrace_tls_attributes branch from 18d1675 to 3469bf8 Compare May 21, 2024 12:42
@@ -69,16 +70,16 @@ func TestRoundtrip(t *testing.T) {
defer ts.Close()

address := ts.Listener.Addr()
hp := strings.Split(address.String(), ":")
host, port, _ := net.SplitHostPort(address.String())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
host, port, _ := net.SplitHostPort(address.String())
host, port, err := net.SplitHostPort(address.String())
if err != nil {
t.Fatalf("Address splitting failed: %s", err.Error())
}

)
defer tsHTTPS.Close()

for _, ts := range []*httptest.Server{tsHTTP, tsHTTPS} {
Copy link
Member

Choose a reason for hiding this comment

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

If we're taking the approach of subtests, I think it would be better to loop through anonymous structs with a createServer method which creates the proper (HTTP/HTTPS) server, rather than initializing them both.

panic("unexpected error in parsing httptest server URL: " + err.Error())
}
// http.tls only exists on HTTPS connections.
if u.Scheme == "https" {
Copy link
Member

Choose a reason for hiding this comment

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

There shouldn't be conditions like this in a subtest loop. These should be part of the attributes defined in the loop definition.

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.

None yet

2 participants