tracker

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Overview

Package tracker pushes ad-hoc counter metrics to a Prometheus PushGateway and forwards event payloads to a configured webhook URL.

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