runstats

package module
v0.0.0-...-e4f994d Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: MIT Imports: 15 Imported by: 0

README

Go Metrics Simple

This is a really simple project build to track the performance of your go program. No InfluxDB BS which I am sick of configuring. The objective is to run your program and the go metrics gets saved to the JSON file and after the run the simple program generates a static HTML.

based on the repo: github.com/tevjef/go-runtime-metrics

How to use it

  1. It's as easy as
import (
	metrics "github.com/Akilan1999/Go-Metrics-Simple"
)

func main() {
   // Add this to the starting point of your go program
   err := metrics.RunCollector(metrics.DefaultConfig)
   // <Your Go program here> 
   // Add this to the end point of your go program
	 metrics.ComputeDefaultFile()
}

  1. After your program is complete just open metrics.html file (The image below is just sample metrics of the /examplecode. :

Screenshot 2022-09-02 at 22 37 27

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = &Config{}

DefaultConfig A configuration with default values.

Functions

func Compute1orMoreFiles

func Compute1orMoreFiles(files ...string)

func ComputeDefaultFile

func ComputeDefaultFile()

ComputeDefaultFile Plot based on the default file which is results1.json

func FloatArrayToIntArray

func FloatArrayToIntArray(fa []float64) []int

func RunCollector

func RunCollector(config *Config) (err error)

Types

type Config

type Config struct {
	// Measurement to write points to.
	// Default is "go.runtime.<hostname>".
	Measurement string

	// Interval at which to write batched points to InfluxDB.
	// Default is 60 seconds
	BatchInterval time.Duration

	// Interval at which to collect points.
	// Default is 10 seconds
	CollectionInterval time.Duration

	// Disable collecting CPU Statistics. cpu.*
	// Default is false
	DisableCpu bool

	// Disable collecting Memory Statistics. mem.*
	DisableMem bool

	// Disable collecting GC Statistics (requires Memory be not be disabled). mem.gc.*
	DisableGc bool

	// Default is DefaultLogger which exits when the library encounters a fatal error.
	Logger Logger
}

type DefaultLogger

type DefaultLogger struct{}

func (*DefaultLogger) Fatalln

func (*DefaultLogger) Fatalln(v ...interface{})

func (*DefaultLogger) Println

func (*DefaultLogger) Println(v ...interface{})

Println Overwritten function to save result to the result file

type Logger

type Logger interface {
	Println(v ...interface{})
	Fatalln(v ...interface{})
}

type MetricsAllSingleRun

type MetricsAllSingleRun struct {
	Metrics  []collector.Fields
	Duration []float64
}

MetricsAllSingleRun Basic struct with file information

func ReadFile

func ReadFile(File string) (*MetricsAllSingleRun, error)

func (*MetricsAllSingleRun) GenerateData

func (m *MetricsAllSingleRun) GenerateData(field string, TypePlot string) []opts.LineData

func (*MetricsAllSingleRun) GenerateFrees

func (m *MetricsAllSingleRun) GenerateFrees() []opts.LineData

GenerateFrees generate graph for frees

func (*MetricsAllSingleRun) GenerateGraphs

func (m *MetricsAllSingleRun) GenerateGraphs()

GenerateGraphs Generate graphs for run

func (*MetricsAllSingleRun) GenerateLiveobjects

func (m *MetricsAllSingleRun) GenerateLiveobjects() []opts.LineData

GenerateLiveobjects for Live objects (Mallocs - free)

func (*MetricsAllSingleRun) GenerateMallocs

func (m *MetricsAllSingleRun) GenerateMallocs() []opts.LineData

func (*MetricsAllSingleRun) Graph

func (m *MetricsAllSingleRun) Graph(description string, field string, Type ...string) components.Charter

func (*MetricsAllSingleRun) MallocsAndFreesGraph

func (m *MetricsAllSingleRun) MallocsAndFreesGraph() components.Charter

MallocsAndFreesGraph mallocs graph

type MetricsComparison

type MetricsComparison struct {
	Metrics []MetricsAllSingleRun
}

func (*MetricsComparison) GenerateGraphsLists

func (m *MetricsComparison) GenerateGraphsLists()

GenerateGraphsLists Generate graphs for run

func (*MetricsComparison) GraphArray

func (m *MetricsComparison) GraphArray(description string, field string, Type ...string) components.Charter

func (*MetricsComparison) NormalizeGraphs

func (m *MetricsComparison) NormalizeGraphs() (*NormalizedGraphs, error)

NormalizeGraphs Ensure data is available for being potable Step 1: Convert Duration to int Step 2: Ensure all points can rely on a single duration

type NormalizedGraphs

type NormalizedGraphs struct {
	Metrics  [][]collector.Fields
	Duration []int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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