tracker

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 13 Imported by: 0

README

tracker — Prometheus push gateway + webhook

import "github.com/downsized-devs/sdk-go/tracker"

Stability: Stable — see STABILITY.md

Pushes metrics to a Prometheus push gateway for short-lived jobs, and posts arbitrary JSON to webhook endpoints.

Features

  • Push(Options) — push a metric to the push gateway.
  • PushWebhook(WebhookOptions) — POST a JSON payload to an HTTP webhook.

Installation

go get github.com/downsized-devs/sdk-go/tracker

Quick Start

t := tracker.Init(tracker.Config{
    PushGateway: "http://pgw.local:9091",
}, log)

_ = t.Push(ctx, tracker.Options{
    Job:    "nightly-rollup",
    Metric: "rollup_rows_processed",
    Value:  12345,
    Labels: map[string]string{ "env": "prod" },
})

API Reference

Symbol Signature
Init func Init(cfg Config, log logger.Interface) Interface
Interface.Push (ctx, Options) error
Interface.PushWebhook (ctx, WebhookOptions) error
Options { Job, Metric string; Value float64; Labels map[string]string }
WebhookOptions { URL string; Headers http.Header; Body any }

Configuration

Field Description
PushGateway Push-gateway URL.
Webhook defaults per-call overrides recommended.

Error Handling

Errors are wrapped with codes third-party codes.

Dependencies

  • Internal: codes, errors, logger, operator
  • External: github.com/prometheus/client_golang/prometheus, .../prometheus/push, github.com/prometheus/common/expfmt

Testing

go test ./tracker/...

Contributing

See CONTRIBUTING.md.

  • instrument — Prometheus pull (the inverse of this package).
  • slack — alternative alerting channel.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	Push(ctx context.Context, trackingName string, labels map[string]string) error
	PushWebhook(ctx context.Context, payload []byte, headers map[string]string) error
}

func Init

func Init(opt Options, log logger.Interface) Interface

type Options

type Options struct {
	Enabled bool
	URL     string
	Port    string
	JobName string
	Timeout time.Duration
	Webhook WebhookOptions
}

type WebhookOptions

type WebhookOptions struct {
	Enabled bool
	URL     string
	Timeout time.Duration
}

Jump to

Keyboard shortcuts

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