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#pkg-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 DefaultShouldRecord(r *http.Request) bool
- func NewHandler(f func(appengine.Context, http.ResponseWriter, *http.Request)) http.Handler
- func NewHandlerFunc(f func(appengine.Context, http.ResponseWriter, *http.Request)) http.HandlerFunc
- func WithContext(context appengine.Context, method, path string, f func(Context))
- type Context
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 DefaultShouldRecord ¶
DefaultShouldRecord will record a request based on RecordFraction.
func NewHandler ¶
NewHandler returns a new Handler that will execute f.
func NewHandlerFunc ¶
func NewHandlerFunc(f func(appengine.Context, http.ResponseWriter, *http.Request)) http.HandlerFunc
NewHandlerFunc returns a new HandlerFunc that will execute f.
Types ¶
type Context ¶
Context is a timing-aware appengine.Context.
func NewContext ¶
NewContext creates a new timing-aware context from req.
func (Context) Call ¶
func (c Context) Call(service, method string, in, out appengine_internal.ProtoMessage, opts *appengine_internal.CallOptions) error
Call times an appengine.Context Call. Internal use only.