appstats

package
v0.0.0-...-3b0f2d1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2013 License: BSD-2-Clause, BSD-3-Clause 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#_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 AppstatsHandler

func AppstatsHandler(w http.ResponseWriter, r *http.Request)

func DefaultShouldRecord

func DefaultShouldRecord(r *http.Request) bool

func Details

func Details(w http.ResponseWriter, r *http.Request)

func File

func File(w http.ResponseWriter, r *http.Request)

func GetCost

func GetCost(p proto.Message) int64

func Index

func Index(w http.ResponseWriter, r *http.Request)

func Static

func Static(w http.ResponseWriter, r *http.Request)

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 ByteSize

type ByteSize float64
const (
	KB ByteSize = 1 << (10 * iota)
	MB
	GB
	TB
	PB
	EB
	ZB
	YB
)

func (ByteSize) String

func (b ByteSize) String() string

type Context

type Context struct {
	appengine.Context

	Stats *RequestStats
	// contains filtered or unexported fields
}

func NewContext

func NewContext(req *http.Request) Context

func (Context) Call

func (c Context) Call(service, method string, in, out appengine_internal.ProtoMessage, opts *appengine_internal.CallOptions) error

func (Context) FromContext

func (c Context) FromContext(ctx appengine.Context) Context

func (Context) Save

func (c Context) Save()

func (Context) URL

func (c Context) URL() string

type Frame

type Frame struct {
	Location string
	Call     string
	Lineno   int
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is an http.Handler that records RPC statistics.

func NewHandler

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

NewHandler returns a new Handler that will execute f.

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type RPCStat

type RPCStat struct {
	Service, Method string
	Start           time.Time
	Offset          time.Duration
	Duration        time.Duration
	StackData       string
	In, Out         string
	Cost            int64
}

func (RPCStat) Name

func (r RPCStat) Name() string

func (RPCStat) Request

func (r RPCStat) Request() string

func (RPCStat) Response

func (r RPCStat) Response() string

func (RPCStat) Stack

func (r RPCStat) Stack() Stack

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 SKey

type SKey struct {
	// contains filtered or unexported fields
}

type Stack

type Stack []*Frame

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)

Jump to

Keyboard shortcuts

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