memstats

package module
v0.0.0-...-3f4151c Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2014 License: BSD-2-Clause Imports: 7 Imported by: 2

README

Installation

go get github.com/gbbr/memstats/...
go install github.com/gbbr/memstats/...

Basic usage

To monitor your application:

  • Import the package and add the line go memstats.Serve() into your code.
  • Run your application. Profiling information should now be available via websockets.
  • In the terminal or command line, run the memstats command to get a visual on http://localhost:8080

For more configuration options and API, see the documentation.

--

Dummy program

Write this program, and save it as main.go:

// filename: main.go
package main

import "github.com/gbbr/memstats"

func main() {
	memstats.Serve()
}

Run go run main.go to start the program.
Run memstats to start the web viewer on http://localhost:8080.

Documentation

Overview

Package memstats helps you monitor a running server's memory usage, visualize Garbage Collector information, run stack traces and memory profiles. To run the server, place this command at the top of your application:

go memstats.Serve()

The next time you run your application, profiling is available via websockets on port 6061, and once a client is connected it will send updates every 2 seconds. Defaults can be changed by passing one or more of the APIs options as params to Serve. See the examples for each option.

To use the provided webserver, run the command "memstat" once your applications starts and has profiling enabled. To change HTTP port or connected to other sockets than default, see:

memstats --help

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAddr

func ListenAddr(addr string) func(*server)

ListenAddr sets the address that the server will listen on for HTTP and WebSockets connections. ListenAddr is one of the options that can be provided to Serve.

Example
package main

import (
	"github.com/gbbr/memstats"
)

func main() {
	// Start a goroutine that runs the memstat
	// server at the passed in address.
	go memstats.Serve(memstats.ListenAddr(":7777"))
}
Output:

func Serve

func Serve(opts ...func(*server))

Serve starts a memory monitoring server. By default it listens on :6061

Example
package main

import (
	"github.com/gbbr/memstats"
)

func main() {
	// Place this line at the top of your application to
	// start a live web visualization of memory profiling.
	go memstats.Serve()
}
Output:

func Tick

func Tick(d time.Duration) func(*server)

Tick sets the frequency at which the websockets will send updates. Tick is one of the options that can be provided to Serve.

Example
package main

import (
	"time"

	"github.com/gbbr/memstats"
)

func main() {
	// Starts a server on default port :6061 that
	// refreshes every minute.
	go memstats.Serve(memstats.Tick(time.Minute))
}
Output:

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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