Documentation ¶
Index ¶
- Variables
- func CreateRequestID(m, p string) string
- func Error(tag, err string)
- func GetApplicationMetric() *pb.ApplicationMetric
- func GetCPUUsage() (float64, error)
- func GetErrorMetric() []*pb.ApplicationMetric_Error
- func GetExpvar() map[string]string
- func GetResource() *pb.SystemMetric_Resource
- func GetRuntime() *pb.SystemMetric_Runtime
- func GetSystemMetric() *pb.SystemMetric
- func GetTransactionMetric() (*pb.ApplicationMetric_Transaction, []*pb.ApplicationMetric_Realtime, ...)
- func GetUnixTimestamp() string
- func LeaveBreadcrumb(r *http.Request, tag string)
- func Middleware(h http.HandlerFunc) http.HandlerFunc
- type Client
- type Request
- type RequestData
- type ResponseWriterWrapper
Constants ¶
This section is empty.
Variables ¶
var ExcludeMemstatKey = "BySize PauseEnd PauseNs"
ExcludeMemstatKey is a string not to be included in expvar memstats metric map. Key is separated by space.
Functions ¶
func CreateRequestID ¶
CreateRequestID returns request id (string) for request tracking
func GetApplicationMetric ¶
func GetApplicationMetric() *pb.ApplicationMetric
GetApplicationMetric returns ApplicationMetric.
func GetCPUUsage ¶
GetCPUUsage returns CPU usage(float64). If system doesn't support /proc/stat or failed to parse cpu data will return 0.0 with Error.
func GetErrorMetric ¶
func GetErrorMetric() []*pb.ApplicationMetric_Error
GetErrorMetric returns error map, and initialize error map.
func GetExpvar ¶
GetExpvar returns expvar metric map. For memstats, key specified in ExcludeMemstatKey will be excluded.
func GetSystemMetric ¶
func GetSystemMetric() *pb.SystemMetric
GetSystemMetric returns SystemMetric.
func GetTransactionMetric ¶
func GetTransactionMetric() (*pb.ApplicationMetric_Transaction, []*pb.ApplicationMetric_Realtime, []*pb.ApplicationMetric_User)
GetTransactionMetric returns http metric map.
func GetUnixTimestamp ¶
func GetUnixTimestamp() string
GetUnixTimestamp returns UnixTimestamp in string.
func LeaveBreadcrumb ¶
LeaveBreadcrumb add specified tag to array
func Middleware ¶
func Middleware(h http.HandlerFunc) http.HandlerFunc
Middleware returns net/http middleware
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for server communication
func (*Client) SetMetricURL ¶
SetMetricURL sets metric url to provided url
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request is a type that wraps request information
func StartRequestTrack ¶
StartRequestTrack starts request tracking
func (*Request) FinishRequestTrack ¶
FinishRequestTrack finishes request tracking
type RequestData ¶
type RequestData struct { Breadcrumb []string `json:"crumb,omitempty"` BreadcrumbTime []int64 `json:"crumbT,omitempty"` Panic bool `json:"panic,omitempty"` ResponseTime int64 `json:"res"` Timestamp string `json:"time"` }
RequestData is a type for keeping request tracking data
type ResponseWriterWrapper ¶
type ResponseWriterWrapper struct {
// contains filtered or unexported fields
}
ResponseWriterWrapper wrap ResponseWriter for net/http middleware support
func (*ResponseWriterWrapper) Header ¶
func (rww *ResponseWriterWrapper) Header() http.Header
Header is implementaion of net/http ResponseWriter Header()
func (*ResponseWriterWrapper) Status ¶
func (rww *ResponseWriterWrapper) Status() int
Status returns the HTTP status code
func (*ResponseWriterWrapper) Write ¶
func (rww *ResponseWriterWrapper) Write(b []byte) (int, error)
Write is implementaion of snet/http ResponseWriter Write()
func (*ResponseWriterWrapper) WriteHeader ¶
func (rww *ResponseWriterWrapper) WriteHeader(s int)
WriteHeader sets the header with status