httpstats

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BodyPlaceHolder = []byte("<BODY>")

BodyPlaceHolder returns a dummy body placeholder

Functions

This section is empty.

Types

type APIStatsSys

type APIStatsSys struct {
	Db         objmetadb.ObjStoreMetaDBAPI
	HttpStats  *HTTPStats
	ObjectInfo *ObjectInfo
}

func NewHttpStatsSys

func NewHttpStatsSys(db objmetadb.ObjStoreMetaDBAPI) *APIStatsSys

NewHttpStatsSys - new an HttpStats system

func (*APIStatsSys) GetCurrentStats

func (st *APIStatsSys) GetCurrentStats(ctx context.Context) (StatsResp, error)

func (*APIStatsSys) RecordAPIHandler

func (st *APIStatsSys) RecordAPIHandler(api string, f http.HandlerFunc) http.HandlerFunc

func (*APIStatsSys) StoreApiLog

func (st *APIStatsSys) StoreApiLog(ctx context.Context)

type ApiStats

type ApiStats struct {
	Filetype string `json:"filetype"`
	Value    uint64 `json:"value"`
}

ApiStats ApiStats resp

type HTTPAPIStats

type HTTPAPIStats struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

HTTPAPIStats holds statistics information about a given API in the requests.

type HTTPStats

type HTTPStats struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

HTTPStats holds statistics information about HTTP requests made by all clients

type ObjectInfo

type ObjectInfo struct {
	PutObjCount    map[string]uint64
	GetObjCount    map[string]uint64
	PutObjBytes    map[string]uint64
	GetObjBytes    map[string]uint64
	PutObjBytesAll uint64
	GetObjBytesAll uint64
	sync.RWMutex
}

type ResponseRecorder

type ResponseRecorder struct {
	http.ResponseWriter
	StatusCode int
	// Log body of 4xx or 5xx responses
	LogErrBody bool
	// Log body of all responses
	LogAllBody bool

	TimeToFirstByte time.Duration
	StartTime       time.Time
	// contains filtered or unexported fields
}

ResponseRecorder - is a wrapper to trap the http response status code and to record the response body

func NewResponseRecorder

func NewResponseRecorder(w http.ResponseWriter) *ResponseRecorder

NewResponseRecorder - returns a wrapped response writer to trap http status codes for auditing purposes.

func (*ResponseRecorder) Body

func (lrw *ResponseRecorder) Body() []byte

Body - Return response body.

func (*ResponseRecorder) Flush

func (lrw *ResponseRecorder) Flush()

Flush - Calls the underlying Flush.

func (*ResponseRecorder) HeaderSize

func (lrw *ResponseRecorder) HeaderSize() int

HeaderSize - returns the number of bytes of response headers written

func (*ResponseRecorder) Size

func (lrw *ResponseRecorder) Size() int

Size - returns the number of bytes written

func (*ResponseRecorder) Write

func (lrw *ResponseRecorder) Write(p []byte) (int, error)

func (*ResponseRecorder) WriteHeader

func (lrw *ResponseRecorder) WriteHeader(code int)

WriteHeader - writes http status code

type StatsResp

type StatsResp struct {
	//CurrentS3Requests  ApiStats          `json:"current_s3_requests"`
	//CurrentIamRequests ApiStats          `json:"current_iam_requests"`
	//TotalIamRequests   ApiStats          `json:"total_iam_requests"`
	//TotalIamErrors     ApiStats          `json:"total_iam_errors"`
	//TotalIam4xxErrors  ApiStats          `json:"total_iam_4xx_errors"`
	//TotalIam5xxErrors  ApiStats          `json:"total_iam_5xx_errors"`
	//TotalIamCanceled   ApiStats          `json:"total_iam_canceled"`
	//TotalS3Requests    ApiStats          `json:"total_s3_requests"`
	//TotalS3Errors      ApiStats          `json:"total_s3_errors"`
	//TotalS34xxErrors   ApiStats          `json:"total_s3_4xx_errors"`
	//TotalS35xxErrors   ApiStats          `json:"total_s3_5xx_errors"`
	//TotalS3Canceled    ApiStats          `json:"total_s3_canceled"`
	PutObjCount    []ApiStats `json:"put_obj_count"`
	GetObjCount    []ApiStats `json:"get_obj_count"`
	PutObjBytes    []ApiStats `json:"put_obj_bytes"`
	GetObjBytes    []ApiStats `json:"get_obj_bytes"`
	PutObjBytesAll uint64     `json:"put_obj_bytes_all"`
	GetObjBytesAll uint64     `json:"get_obj_bytes_all"`
}

StatsResp holds statistics information about HTTP requests made by all clients

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL