observability

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package observability turns a short provider form into data export destinations. Provider facts live in presets.json, this code only renders.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalid = fmt.Errorf("invalid observability export")

ErrInvalid wraps every form validation failure so callers can answer 400.

Functions

func DestinationName

func DestinationName(export, preset, signal string) string

DestinationName builds the stored name of one signal destination.

func ParseDestinationName

func ParseDestinationName(n string) (export, preset, signal string, ok bool)

ParseDestinationName splits a stored name made by DestinationName.

func ValidName

func ValidName(s string) bool

ValidName reports whether s is an allowed export name.

Types

type Choice

type Choice struct {
	Value string            `json:"value"`
	Label string            `json:"label"`
	Vars  map[string]string `json:"vars,omitempty"`
}

Choice is one allowed value of a select field. Vars are extra template variables that apply when it is picked, such as a regional host.

type Field

type Field struct {
	Key         string   `json:"key"`
	Label       string   `json:"label"`
	Type        string   `json:"type,omitempty"`
	Secret      bool     `json:"secret,omitempty"`
	Required    bool     `json:"required,omitempty"`
	Default     string   `json:"default,omitempty"`
	Placeholder string   `json:"placeholder,omitempty"`
	Help        string   `json:"help,omitempty"`
	Choices     []Choice `json:"choices,omitempty"`
}

Field is one input of a preset form. Secret fields are never echoed back.

type Preset

type Preset struct {
	ID          string            `json:"id"`
	Name        string            `json:"name"`
	Description string            `json:"description"`
	DocsAnchor  string            `json:"docs_anchor"`
	Fields      []Field           `json:"fields"`
	Signals     []SignalSpec      `json:"signals"`
	Hints       map[string]string `json:"hints"`
}

Preset is one provider entry of the catalog.

func Catalog

func Catalog() []Preset

Catalog returns every preset in display order.

func Lookup

func Lookup(id string) (Preset, bool)

Lookup finds a preset by id.

func (Preset) DefaultSignals

func (p Preset) DefaultSignals() []string

DefaultSignals lists the signals exported when the caller names none.

func (Preset) Hint

func (p Preset) Hint(err error) (int, string)

Hint maps a delivery error to the provider's remedy text. It returns the HTTP status found in the error (0 if none) and the hint, which may be empty.

func (Preset) Render

func (p Preset) Render(name string, fields map[string]string, signals []string) ([]Rendered, error)

Render builds the destinations for the chosen signals. An empty signal list means the preset defaults. name groups the destinations of one export.

func (Preset) SignalNames

func (p Preset) SignalNames() []string

SignalNames lists the signals a preset can export.

type Rendered

type Rendered struct {
	Signal      string
	Input       dataexport.Input
	Endpoint    string
	HeaderNames []string
}

Rendered is one destination ready to create. Endpoint and HeaderNames are safe to show; Input carries the credential and must not be logged.

type SignalSpec

type SignalSpec struct {
	Signal   string            `json:"signal"`
	Kind     store.ExportKind  `json:"kind"`
	Default  bool              `json:"default"`
	Endpoint string            `json:"endpoint,omitempty"`
	Headers  map[string]string `json:"headers,omitempty"`
	Options  map[string]string `json:"options,omitempty"`
	APIKey   string            `json:"api_key,omitempty"`
}

SignalSpec describes how one signal is delivered for a preset.

Jump to

Keyboard shortcuts

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