Help us shape the future of Go! Take the 2026 Go Developer Survey

telemetry

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package telemetry is the metrics Pando exports about itself (R-399, issue #126): pushed over OTLP to a collector the operator names, stored, graphed and alerted on there and nowhere in Pando (R-016, R-245).

Every recording goes through a function here that takes typed, bounded values — an outcome, a route pattern, a kind of principal — and no free-form attributes. That is R-400's mechanism: there is no way to hand this package a user ID, a token ID or an app ID, so no metric can carry one, and TestR400_NoMetricNamesAPersonTokenOrApp checks what comes out.

Until Install is called every function records into a no-op, which is what an install with no endpoint configured runs on.

Index

Constants

View Source
const ScopeName = "github.com/trypando/pando"

ScopeName is the instrumentation scope every Pando metric is recorded under.

Variables

View Source
var AttributeKeys = []string{
	keyOutcome, keyDecision, keyPrincipalKind, keyCategory, keyAdapter, keyKind, keyJob,
	keyMethod, keyRoute, keyStatus, keyConnState,
}

AttributeKeys is every attribute key a Pando metric may carry (R-400).

Functions

func Build

func Build(ctx context.Context, o Outcome, d time.Duration)

Build records one image build.

func Deploy

func Deploy(ctx context.Context, o Outcome, d time.Duration)

Deploy records a deploy reaching its end state.

func Detection

func Detection(ctx context.Context, o Outcome, d time.Duration)

Detection records one detection.

func HTTPRequest

func HTTPRequest(ctx context.Context, method, route string, status int, d time.Duration)

HTTPRequest records one request to Pando's own API or console. route is the router's pattern, such as /api/v1/apps/{id}, never the path: a path carries IDs (R-400). Empty means no route matched.

func Install

func Install(provider metric.MeterProvider, sources Sources) error

Install records every metric from here on into provider, and registers sources to be read at each collection. It replaces whatever was installed before, which tests rely on.

func ProxyRequest

func ProxyRequest(ctx context.Context, allowed bool, kind string)

ProxyRequest records one request to an app through the proxy. kind is the kind of principal — user, token, anonymous — never which one (R-400), and no app is named: the count is install-wide.

func Reconcile

func Reconcile(ctx context.Context, o Outcome, d time.Duration)

Reconcile records one reconcile of one app.

func Reset

func Reset()

Reset goes back to recording into a no-op.

func RetentionPass

func RetentionPass(ctx context.Context, job RetentionJob, o Outcome, d time.Duration)

RetentionPass records one pass of a retention job.

func RetentionRemoved

func RetentionRemoved(ctx context.Context, kind string, n int64)

RetentionRemoved records rows of one kind the retention job removed. kind is the kind of row, such as deployments or sessions.

func Start

func Start(ctx context.Context, cfg config.Metrics, process Process, sources Sources) (func(context.Context) error, error)

Start exports metrics over OTLP as cfg says, and returns what stops it, flushing what was recorded since the last push. With no endpoint configured it does nothing and returns a no-op.

Types

type AdapterHealth

type AdapterHealth struct {
	Category string // an adapter category, such as runtime
	ID       string // the adapter's configured ID, such as docker
	Healthy  bool
}

AdapterHealth is one adapter's last health check.

type Outcome

type Outcome string

Outcome is how a piece of work ended.

const (
	Succeeded Outcome = "succeeded"
	Failed    Outcome = "failed"
	Canceled  Outcome = "canceled"
)

func OutcomeOf

func OutcomeOf(ctx context.Context, err error) Outcome

OutcomeOf is Succeeded for a nil error, Canceled when the context was canceled, and Failed otherwise.

type Process

type Process struct {
	Version string // the build's version
	// Replica is this replica's ID, as the console's list of replicas
	// shows it: service.instance.id.
	Replica string
	// Hostname is the container's or pod's: host.name.
	Hostname string
}

Process names this Pando process to the collector. Neither field is a person, a token or an app (R-400).

type RetentionJob

type RetentionJob string

RetentionJob is which retention job passed.

const (
	// RetentionAudit archives and drops months of the audit log (R-347).
	RetentionAudit RetentionJob = "audit"
	// RetentionRows removes old rows from every other table (R-224).
	RetentionRows RetentionJob = "rows"
)

type Sources

type Sources struct {
	// Pool is the database pool's connections: in use, idle and the most
	// it may open.
	Pool func() (used, idle, max int64)

	// Detections is how many detections this replica is running now.
	Detections func() int64

	// Adapters is each adapter's health as last checked, true for healthy.
	Adapters func() []AdapterHealth
}

Sources are the readings taken when metrics are collected, rather than recorded as things happen. Any may be nil.

Directories

Path Synopsis
Package telemetrytest reads back what Pando recorded, for tests asserting that a piece of work is measured (R-399).
Package telemetrytest reads back what Pando recorded, for tests asserting that a piece of work is measured (R-399).

Jump to

Keyboard shortcuts

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