Documentation
¶
Index ¶
- type Data
- type Label
- type Option
- type Options
- type ResponseWriter
- type Stats
- func (mw *Stats) Begin(w http.ResponseWriter) (time.Time, ResponseWriter)
- func (mw *Stats) Close()
- func (mw *Stats) Data() *Data
- func (mw *Stats) End(start time.Time, opts ...Option)
- func (mw *Stats) Handler(h http.Handler) http.Handler
- func (mw *Stats) MeasureSince(key string, start time.Time)
- func (mw *Stats) MeasureSinceWithLabels(key string, start time.Time, labels []Label)
- func (mw *Stats) ResetResponseCounts()
- func (mw *Stats) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct {
Pid int `json:"pid"`
Hostname string `json:"hostname"`
UpTime string `json:"uptime"`
UpTimeSec float64 `json:"uptime_sec"`
Time string `json:"time"`
TimeUnix int64 `json:"unixtime"`
StatusCodeCount map[string]int `json:"status_code_count"`
TotalStatusCodeCount map[string]int `json:"total_status_code_count"`
Count int `json:"count"`
TotalCount int `json:"total_count"`
TotalResponseTime string `json:"total_response_time"`
TotalResponseTimeSec float64 `json:"total_response_time_sec"`
TotalResponseSize int64 `json:"total_response_size"`
AverageResponseSize int64 `json:"average_response_size"`
AverageResponseTime string `json:"average_response_time"`
AverageResponseTimeSec float64 `json:"average_response_time_sec"`
TotalMetricsCounts map[string]int `json:"total_metrics_counts"`
AverageMetricsTimers map[string]float64 `json:"average_metrics_timers"`
}
Data serializable structure
type Option ¶
type Option func(*Options)
Option represents a stats option.
func WithRecorder ¶
func WithRecorder(recorder ResponseWriter) Option
WithRecorder sets the recorder to use in stats.
func WithStatusCode ¶
WithStatusCode sets the status code to use in stats.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options are stats options.
func (Options) StatusCode ¶
StatusCode returns the response status code.
type ResponseWriter ¶
type ResponseWriter interface {
http.ResponseWriter
http.Flusher
// Status returns the status code of the response or 0 if the response has not been written.
Status() int
// Written returns whether or not the ResponseWriter has been written.
Written() bool
// Size returns the size of the response body.
Size() int
// Before allows for a function to be called before the ResponseWriter has been written to. This is
// useful for setting headers or any other operations that must happen before a response has been written.
Before(func(ResponseWriter))
}
func NewRecorderResponseWriter ¶
func NewRecorderResponseWriter(w http.ResponseWriter, statusCode int) ResponseWriter
type Stats ¶
type Stats struct {
Hostname string
Uptime time.Time
Pid int
ResponseCounts map[string]int
TotalResponseCounts map[string]int
TotalResponseTime time.Time
TotalResponseSize int64
MetricsCounts map[string]int
MetricsTimers map[string]time.Time
// contains filtered or unexported fields
}
Stats data structure
func (*Stats) Begin ¶
func (mw *Stats) Begin(w http.ResponseWriter) (time.Time, ResponseWriter)
Begin starts a recorder
func (*Stats) MeasureSince ¶
MeasureSince method for execution time recording
func (*Stats) MeasureSinceWithLabels ¶
MeasureSinceWithLabels method for execution time recording with custom labels
func (*Stats) ResetResponseCounts ¶
func (mw *Stats) ResetResponseCounts()
ResetResponseCounts reset the response counts
func (*Stats) ServeHTTP ¶
func (mw *Stats) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ServeHTTP: Negroni compatible interface
Click to show internal directories.
Click to hide internal directories.