-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added httpTrace logging for debugging network issues
- Loading branch information
1 parent
4458dfa
commit e8d8f88
Showing
4 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 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,42 @@ | ||
package infinity | ||
|
||
import ( | ||
"crypto/tls" | ||
"net/http" | ||
"net/http/httptrace" | ||
|
||
"github.com/grafana/grafana-plugin-sdk-go/backend/log" | ||
) | ||
|
||
func reqWithHTTPTraceContext(req *http.Request, logger log.Logger) *http.Request { | ||
trace := &httptrace.ClientTrace{ | ||
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) { | ||
logger.Debug("HTTPTrace event", "event_name", "ConnectDone") | ||
}, | ||
GetConn: func(hostPort string) { | ||
logger.Debug("HTTPTrace event", "event_name", "GetConn") | ||
}, | ||
GotConn: func(connInfo httptrace.GotConnInfo) { | ||
logger.Debug("HTTPTrace event", "event_name", "GotConn") | ||
}, | ||
TLSHandshakeStart: func() { | ||
logger.Debug("HTTPTrace event", "event_name", "TLSHandshakeStart") | ||
}, | ||
TLSHandshakeDone: func(cs tls.ConnectionState, err error) { | ||
logger.Debug("HTTPTrace event", "event_name", "TLSHandshakeDone") | ||
}, | ||
GotFirstResponseByte: func() { | ||
logger.Debug("HTTPTrace event", "event_name", "GotFirstResponseByte") | ||
}, | ||
} | ||
return req.WithContext(httptrace.WithClientTrace(req.Context(), trace)) | ||
} |
This file contains 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