An all-in-one obversvability kit
Go to file
2022-11-03 08:42:02 -05:00
cmd got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00
examples got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00
http got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00
legal got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00
pb got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00
tools/gen-tags got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00
.gitignore initial implementation 2022-11-01 16:15:22 -05:00
api_impl.go got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00
api.go got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00
AUTHORS got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00
client.go got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00
go.mod initial implementation 2022-11-01 16:15:22 -05:00
go.sum initial implementation 2022-11-01 16:15:22 -05:00
go.work got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00
LICENSE got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00
Makefile got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00
README.md got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00
tags.ext.go got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00
tags.go got things to work with HTTP and stdout 2022-11-03 08:42:02 -05:00

okit

Short for "observability kit", okit aims to provide an all-in-one solution to application observability.

Why

Traditional approaches to observability treat logging, application metrics, and tracing as independent operations, with independent data streams. In practice, these elements are more or less all the same, with some minor differences between them. Developers often have to choose between logging a message, emitting a metric, or expanding a trace.

Logging

  • Used by developers and operators to determine what issues an application may be facing.
  • High cardinality data (errors, stack traces, user id / signature).
  • Often sent to stdout/stderr and can optionally be captured by traditional logging solutions.

Tracing

  • Used by developers and operators to troubleshoot performance issues across a set of distributed systems.
  • Medium cardinality data (consistent structure, high variability in tag values)
  • Typically available in real-time to assess product performance.

Metrics

  • Used by developers and product managers to determine details about how their product is doing.
  • Medium/High cardinality data (user id / signature, other metadata fields).
  • Typically available in real-time to assess user experience / feature performance.

Usage

Basic

package main

import (
	"context"

	"go.pitz.tech/okit"
)

func main() {
	var tags []okit.Tag

	// Metric emission
	okit.Observe("temperature_c", 20.9, tags...)

	// Multi-dimensional events
	okit.Emit("user_signup", tags...)

	// Tracing
	ctx, done := okit.Trace(context.Background(), tags...)
	defer done()
	_ = ctx.Err() // not needed, removes unused error

	// Logging
	okit.Debug("a message used for debugging", tags...)
	okit.Info("an informational message for the user", tags...)
	okit.Warn("a warning indicating an issue with the system", tags...)
	okit.Error("the system encountered an error", tags...)
}

HTTP

okit comes with built-in functionality to make it easy to trace HTTP operations.

package main

import (
	"net/http"

	okithttp "go.pitz.tech/okit/http"
)

func main() {
	// Instrument HTTP Clients
	okithttp.InstrumentClient(http.DefaultClient)

	// Add reporting endpoints
	mux := http.NewServeMux()
	okithttp.RouteEndpoint(mux, okithttp.NewEndpoint())

	// Instrument HTTP Handlers
	handler := okithttp.InstrumentHandler(mux)
	err := http.ListenAndServe("0.0.0.0:8080", handler)
	if err != nil {
		panic(err)
	}
}