-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Heartbeat] Add tls fields when connecting through proxy #22190
Conversation
This updates Heartbeat to enrich an event with TLS information when the connection has been established via an HTTP proxy. Closes elastic#15797
Thanks for the contribution! Out of curiosity (since setting up a forward proxy is such a pain), did you confirm that this records the TLS info for the site being tested and not the proxy itself? It'd be great if we could write a test around this, we do have some existing tests that setup forward proxies using go itself. |
Yes, it always records the TLS info for the target site, not the HTTPS proxy, and it also works when the connection to the proxy is HTTP. I'll see if I can add a test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added those tests. @andrewvc please have a look
// When connecting through a proxy, the following fields are missing. | ||
if _, isProxy := reqExtraConfig["proxy_url"]; isProxy { | ||
missing := map[string]interface{}{ | ||
"http.rtt.response_header.us": time.Duration(0), | ||
"http.rtt.content.us": time.Duration(0), | ||
"monitor.ip": "127.0.0.1", | ||
"tcp.rtt.connect.us": time.Duration(0), | ||
"http.rtt.validate.us": time.Duration(0), | ||
"http.rtt.write_request.us": time.Duration(0), | ||
"tls.rtt.handshake.us": time.Duration(0), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why these fields are missing when proxy_url
is defined. monitor.ip
worries me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC we intentionally drop monitor.ip
because the IP we've connected to is masked by the proxy. There may be ways to pull that out of special HTTP headers however.
I haven't looked at that code in a while TBH, and it's never been a concern from users (maybe till now). IIRC there were issues with the timings being relevant.
TCP connection time is not really as relevant either as that would measure TCP connection time to the proxy, for instance. If this is an area where you'd like to go deep and add relevant test cases we'd be glad to accept a patch, however, as far as I'm aware there isn't huge demand.
💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
Pinging @elastic/uptime (Team:Uptime) |
@andrewvc are you OK with merging this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Apologies for the delayed review . This is a fantastic improvement
This updates Heartbeat to enrich an event with TLS information when the connection has been established via an HTTP proxy. Closes elastic#15797 (cherry picked from commit cd16ca0)
What does this PR do?
This updates Heartbeat to enrich an event with TLS information when the connection has been established via an HTTP proxy.
Why is it important?
Because tls fields are missing from events when an HTTPS connection is performed through a proxy.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Tested with tinyproxy (HTTP) and stunnel+tinyproxy (HTTPS)
Related issues
Closes #15797