Categorygithub.com/ancientlore/kubismus
modulepackage
1.1.3
Repository: https://github.com/ancientlore/kubismus.git
Documentation: pkg.go.dev

# README

logo kubismus

Go Reference

Kubismus is a go package that makes it easy to display status metrics using Cubism.js. ("Kubismus" is the German word for "cubism".)

Checkout the sample code: ktest.go

Screen Shot

screenshot

Defining the HTTP Handler

To get started with all defaults, simply register the HTTP handler and serve HTTP:

kubismus.HandleHTTP()
go http.ListenAndServe(":8080", nil)

This creates an endpoint at http://localhost:8080/kubismus that will register information you log.

If you need a custom endpoint, use kubismus.ServeHTTP directly:

http.Handle("/", http.HandlerFunc(kubismus.ServeHTTP))

Adding Data

Kubismus shows graphs and a table of data. You can add entries to these at any time. To add an entry to the table that shows the number of goroutines:

kubismus.Note("Goroutines", fmt.Sprintf("%d", runtime.NumGoroutine()))

To add an entry to a graph:

kubismus.Metric("Metric Name", count, value)

By default, each metric has a count, average, and sum graph. To configure which graphs to show, use the Define method:

kubismus.Define("Posts", kubismus.COUNT, "HTTP Posts")
kubismus.Define("Posts", kubismus.SUM, "Bytes Posted")

Adding metrics and table entries use channels and are thread-safe. Graphs for new metrics may not appear until a browser refresh.

Customizing the Title

You can configure the status page's icon and title:

kubismus.Setup("My Cool Utility", "/web/kubismus36.png")

# Functions

Define defines a metric with a given operation and display name.
GetMetrics returns a list of values for a metric.
GetNotes returns the currently defined notes.
HandleHTTP registers an HTTP handler for kubismus on the default path.
HttpRequestMetric returns a handler that logs a metric for the incoming content length after invoking the handler h.
HttpResponseMetric returns a handler that logs a metric for the response content length after invoking the handler h.
Metric records a count and total value for a given reading.
Note logs a specific value to show in a table.
ReleaseMetrics returns the slice of values to the leaky buffer, if possible.
ReleaseNotes returns the slice to the leaky buffer, if possible.
ServeHTTP servers HTTP requests for kubismus.
Setup sets the basic parameters for the graph page.

# Constants

Op types.
Op types.
DefaultPath is the default path on the URL to get to the Kubismus display.
Op types.

# Type aliases

Op specifies the operation for the metric - count, average, or sum.