Documentation
¶
Overview ¶
Package appstats profiles the RPC performance of Google App Engine applications.
Reference: https://developers.google.com/appengine/docs/python/tools/appstats
To use this package, change your HTTP handler functions to use this signature:
func(appengine.Context, http.ResponseWriter, *http.Request)
Register them in the usual way, wrapping them with NewHandler.
Example ¶
This is a small example using this package.
import (
"net/http"
"appengine"
"github.com/mjibson/appstats"
)
func init() {
http.Handle("/", appstats.NewHandler(Main))
}
func Main(c appengine.Context, w http.ResponseWriter, r *http.Request) {
// do stuff with c: datastore.Get(c, key, entity)
w.Write([]byte("success"))
}
Usage ¶
Use your app, and view the appstats interface at http://localhost:8080/_ah/stats/, or your production URL.
Configuration ¶
Refer to the variables section of the documentation: http://godoc.org/github.com/mjibson/appstats#_variables.
Routing ¶
In general, your app.yaml will not need to change. In the case of conflicting routes, add the following to your app.yaml:
handlers: - url: /_ah/stats/.* script: _go_app
TODO ¶
Cost calculation is experimental. Currently it only includes write ops (read and small ops are TODO).
Index ¶
- Variables
- func AppstatsHandler(w http.ResponseWriter, r *http.Request)
- func DefaultShouldRecord(r *http.Request) bool
- func Details(w http.ResponseWriter, r *http.Request)
- func File(w http.ResponseWriter, r *http.Request)
- func GetCost(p proto.Message) int64
- func Index(w http.ResponseWriter, r *http.Request)
- func Static(w http.ResponseWriter, r *http.Request)
- type AllRequestStats
- type ByteSize
- type Context
- type Frame
- type Handler
- type RPCStat
- type RequestStats
- type SKey
- type Stack
- type StatByName
- type StatsByName
Constants ¶
This section is empty.
Variables ¶
var ( // RecordFraction is the fraction of requests to record. // Set to a number between 0.0 (none) and 1.0 (all). RecordFraction float64 = 1.0 // ShouldRecord is the function used to determine if recording will occur // for a given request. The default is to use RecordFraction. ShouldRecord = DefaultShouldRecord // ProtoMaxBytes is the amount of protobuf data to record. // Data after this is truncated. ProtoMaxBytes = 150 // Namespace is the memcache namespace under which to store appstats data. Namespace = "__appstats__" )
Functions ¶
func AppstatsHandler ¶
func AppstatsHandler(w http.ResponseWriter, r *http.Request)
func DefaultShouldRecord ¶
Types ¶
type AllRequestStats ¶
type AllRequestStats []*RequestStats
func (AllRequestStats) Len ¶
func (s AllRequestStats) Len() int
func (AllRequestStats) Less ¶
func (s AllRequestStats) Less(i, j int) bool
func (AllRequestStats) Swap ¶
func (s AllRequestStats) Swap(i, j int)
type Context ¶
type Context struct {
appengine.Context
Stats *RequestStats
// contains filtered or unexported fields
}
func NewContext ¶
func (Context) Call ¶
func (c Context) Call(service, method string, in, out appengine_internal.ProtoMessage, opts *appengine_internal.CallOptions) error
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is an http.Handler that records RPC statistics.
func NewHandler ¶
NewHandler returns a new Handler that will execute f.
type RPCStat ¶
type RequestStats ¶
type RequestStats struct {
User string
Admin bool
Method string
Path, Query string
Status int
Cost int64
Start time.Time
Duration time.Duration
RPCStats []RPCStat
// contains filtered or unexported fields
}
func (RequestStats) FullKey ¶
func (r RequestStats) FullKey() string
func (RequestStats) PartKey ¶
func (r RequestStats) PartKey() string
type StatByName ¶
type StatByName struct {
Name string
Count int
Cost int64
SubStats []*StatByName
Requests int
RecentReqs []int
RequestStats *RequestStats
Duration time.Duration
}
type StatsByName ¶
type StatsByName []*StatByName
func (StatsByName) Len ¶
func (s StatsByName) Len() int
func (StatsByName) Less ¶
func (s StatsByName) Less(i, j int) bool
func (StatsByName) Swap ¶
func (s StatsByName) Swap(i, j int)