gosd

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

README

gosd

gosd is a Go Runtime stats exporter into Stackdriver.

gosd can monitor these stats to better understand the overall health and performance of Go programs.

Monitored Stats

Setting up authentication

To run the library, you must first set up authentication by creating a service account and setting an environment variable.

Create service account with write acccess for Monitoring, download the key and set this environment variable:

export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"

Note: you may skip this step if you are running your Go application on GCP and it has access to Stackdriver Monitoring API.

Usage

import "github.com/plutov/gosd"

func main() {
    // This goroutine will send stats on your behalf
	go gosd.Run(gosd.Config{
		ProjectID: "PROJECT_ID",
		Logger:    os.Stdout,
		Labels:    map[string]string{"app": "my-web-app"},
	})
}
Stackdriver Metrics

In Stackdriver go to Resources -> Metrics Explorer and find these metrics:

  • custom.googleapis.com/gosd/goroutines
  • custom.googleapis.com/gosd/cgocalls
  • custom.googleapis.com/gosd/mstats/*
Memory Consumption

gosd adds around 5Mi to your program memory usage.

Stackdriver Dashboard

dashboard.png

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(config Config)

Run starts a goroutine which will automatically send Go runtime stats to stackdriver. config.ProjectID is only one mandatory value in config

Types

type Config

type Config struct {
	ProjectID string
	Logger    io.Writer
	Labels    map[string]string
}

Config type

Jump to

Keyboard shortcuts

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