appstats: Index | Files

package appstats

import ""

Package appstats profiles the RPC performance of Google App Engine applications.


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.


This is a small example using this package.

import (



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)


Use your app, and view the appstats interface at http://localhost:8080/_ah/stats/, or your production URL.


Refer to the variables section of the documentation:


In general, your app.yaml will not need to change. In the case of conflicting routes, add the following to your app.yaml:

- url: /_ah/stats/.*
  script: _go_app


Cost calculation is experimental. Currently it only includes write ops (read and small ops are TODO).


Package Files

appstats.go bytesize.go cost.go doc.go funcs.go handler.go html.go static.go types.go


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__"

func DefaultShouldRecord Uses

func DefaultShouldRecord(r *http.Request) bool

DefaultShouldRecord will record a request based on RecordFraction.

func NewHandler Uses

func NewHandler(f func(appengine.Context, http.ResponseWriter, *http.Request)) http.Handler

NewHandler returns a new Handler that will execute f.

func NewHandlerFunc Uses

func NewHandlerFunc(f func(appengine.Context, http.ResponseWriter, *http.Request)) http.HandlerFunc

NewHandlerFunc returns a new HandlerFunc that will execute f.

func WithContext Uses

func WithContext(context appengine.Context, method, path string, f func(Context))

WithContext enables profiling of functions without a corresponding request, as in the appengine/delay package. method and path may be empty.

type Context Uses

type Context struct {
    // contains filtered or unexported fields

Context is a timing-aware appengine.Context.

func NewContext Uses

func NewContext(req *http.Request) Context

NewContext creates a new timing-aware context from req.

func (Context) Call Uses

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.

func (Context) URL Uses

func (c Context) URL() string

URL returns the appstats URL for the current request.

Package appstats imports 20 packages (graph) and is imported by 3 packages. Updated 2016-09-27. Refresh now. Tools for package owners.