appstats

package
v0.0.0-...-d539043 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2015 License: ISC Imports: 20 Imported by: 0

README

appstats

A port of the python appstats implementation to the Go runtime on Google App Engine.

For installation and usage, see the docs: http://godoc.org/github.com/mjibson/appstats.

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

Constants

This section is empty.

Variables

View Source
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

func DefaultShouldRecord(r *http.Request) bool

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.

func WithContext

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.

Types

type Context

type Context struct {
	appengine.Context
	// contains filtered or unexported fields
}

Context is a timing-aware appengine.Context.

func NewContext

func NewContext(req *http.Request) Context

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.

func (Context) URL

func (c Context) URL() string

URL returns the appstats URL for the current request.

Jump to

Keyboard shortcuts

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