Documentation
¶
Index ¶
- func GetMyIp() string
- func HostNoPort(addr string) string
- func LocationFromEnv() string
- func LocationOrIp(loc *string) string
- func Msec(d time.Duration) float64
- func ParseURL(uri string) *url.URL
- func PingTimesHeader() string
- func SafeStrPtr(sp *string, ifnil string) string
- func TextHeader(file *os.File)
- type PingTimes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMyIp ¶
func GetMyIp() string
GetMyIp returns your primary local IP address (as from `ifconfig`). Note that a docker container has a different primary local IP address (172.something) than your base host.
func HostNoPort ¶
func LocationFromEnv ¶
func LocationFromEnv() string
LocationFromEnv returns the current location from environment variables: REP_LOCATION, if defined; otherwise REP_CITY "," REP_COUNTRY, if defined; otherwise "" (empty string)
func LocationOrIp ¶
LocationOrIp returns the loc string, if it has a value, or else the IP address as determined by GetMyIp().
func PingTimesHeader ¶
func PingTimesHeader() string
PingTimesHeader returns a column header string with field names corresponding to the values onto the PingTimes structure, in the same order as the string returned by MsecTsv().
func SafeStrPtr ¶
I don't know why golang string doesn't already have this feature.
func TextHeader ¶
TextHeader dumps a column header corresponding to the values onto the file handle provided. (Included for backwards compatibility.)
Types ¶
type PingTimes ¶
type PingTimes struct { Start time.Time // time we started the ping DnsLk time.Duration // DNS Lookup TcpHs time.Duration // TCP Handshake TlsHs time.Duration // TLS Handshake Reply time.Duration // HTTP Reply (first byte) Close time.Duration // HTTP Reply (last byte / closed) Total time.Duration // (Calculated) Total response time (see RespTime() below) DestUrl *string // URL that received the request Location *string // Client location, City,Country Remote string // Server IP from DNS resolution RespCode int // HTTP response code or -1 (for network failure) Size int64 // total response bytes }
PingTimes holds the components of an HTTP ping request for reporting performance (to cloudwatch, or whatever). See the receiver methods below.
func FetchURL ¶
FetchURL makes an HTTP request to the given URL, reads and discards the response body, and returns a PingTimes object with detailed timing information from the fetch. The caller should pass in a valid location string, for example "City,Country" where the client is running.
func (*PingTimes) DumpJson ¶
DumpJson writes ping times as JSON using native (nanosecond) timestamp values into the given open file.
func (*PingTimes) DumpText ¶
DumpText writes ping times as tab-separated milliseconds into the file.
func (*PingTimes) MsecTsv ¶
MsecTsv returns a tab separated values string with the (Unix epoch) timestamp of the start of the test followed by the msec time deltas for each of the time component fields as msec.uuu (three digits of microseconds), and then the other values of PingTimes.