-
Notifications
You must be signed in to change notification settings - Fork 118
Httptrace #1087
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
Draft
yesoreyeram
wants to merge
5
commits into
main
Choose a base branch
from
httptrace
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Httptrace #1087
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e8d8f88
added httpTrace logging for debugging network issues
yesoreyeram 17c78ae
added error logging
yesoreyeram 9e9d208
Bump supported grafana version to 10.4.8 (#1105)
ivanahuckova 41b8579
Merge remote-tracking branch 'origin' into dev-3.0.0
yesoreyeram 00dea29
Merge branch 'dev-3.0.0' into httptrace
yesoreyeram File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'grafana-infinity-datasource': minor | ||
--- | ||
|
||
Added HTTPTrace logging for debugging connection issues |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'grafana-infinity-datasource': major | ||
--- | ||
|
||
Plugin now requires Grafana 10.4.8 or newer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package infinity | ||
|
||
import ( | ||
"context" | ||
"crypto/tls" | ||
"net/http" | ||
"net/http/httptrace" | ||
|
||
"github.com/grafana/grafana-plugin-sdk-go/backend" | ||
) | ||
|
||
func ApplyHTTPTraceToRequest(_ context.Context, req *http.Request) *http.Request { | ||
ctx := req.Context() | ||
logger := backend.Logger.FromContext(ctx) | ||
trace := &httptrace.ClientTrace{ | ||
GetConn: func(hostPort string) { | ||
logger.Debug("HTTPTrace event", "event_name", "GetConn") | ||
}, | ||
DNSStart: func(di httptrace.DNSStartInfo) { | ||
logger.Debug("HTTPTrace event", "event_name", "DNSStart") | ||
}, | ||
DNSDone: func(dnsInfo httptrace.DNSDoneInfo) { | ||
logger.Debug("HTTPTrace event", "event_name", "DNSDone") | ||
}, | ||
ConnectStart: func(network, addr string) { | ||
logger.Debug("HTTPTrace event", "event_name", "ConnectStart") | ||
}, | ||
ConnectDone: func(network, addr string, err error) { | ||
if err != nil { | ||
logger.Error("HTTPTrace event", "event_name", "ConnectDone", "error", err.Error()) | ||
return | ||
} | ||
logger.Debug("HTTPTrace event", "event_name", "ConnectDone", "address", addr) | ||
}, | ||
TLSHandshakeStart: func() { | ||
logger.Debug("HTTPTrace event", "event_name", "TLSHandshakeStart") | ||
}, | ||
TLSHandshakeDone: func(cs tls.ConnectionState, err error) { | ||
if err != nil { | ||
logger.Error("HTTPTrace event", "event_name", "TLSHandshakeDone", "error", err.Error()) | ||
return | ||
} | ||
logger.Debug("HTTPTrace event", "event_name", "TLSHandshakeDone") | ||
}, | ||
GotConn: func(connInfo httptrace.GotConnInfo) { | ||
logger.Debug("HTTPTrace event", "event_name", "GotConn", "remote_address", connInfo.Conn.RemoteAddr().String()) | ||
}, | ||
GotFirstResponseByte: func() { | ||
logger.Debug("HTTPTrace event", "event_name", "GotFirstResponseByte") | ||
}, | ||
} | ||
return req.WithContext(httptrace.WithClientTrace(ctx, trace)) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 am wondering if all of these should be level
trace
because for data source services, we havedebug
level logging turned on. This would produce a lot of logs that are only sometimes needed. So we could turn it on in that case.We have
trace
log level: https://github.com/grafana/grafana-plugin-sdk-go/blob/main/backend/log/log.go#L14, but we are missinglogger.Trace()
method - all other levels have it.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 with Ivana here. Why not just even be a trace instead of log?
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.
Yea.. Happy to change to Trace ( but we need to make sure the changes done in SDK first )
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.
BTW, Any thoughts on making it to
debug
but only calling this method on healthcheck rather query. Won't that solve the problems we disucussed here. :)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 was thinking about a proper trace so these would be spans instead of logs. Like in here https://github.com/AdamKorcz/skipper/blob/d0b249a4aa8993a050b87cecc11cc6ca839195a4/proxy/proxy.go#L1464
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.
yea.. that too possible too.
I am thinking of deferring this to
3.0.0-beta.2