exporter

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package exporter provides the alpha public contracts for reporting passive Tailscale runtime observations to Tailpath.

Index

Constants

View Source
const (
	FeatureMultiObserver      = "multi-observer"
	FeatureObserverWithdrawal = "observer-withdrawal"
)
View Source
const (
	RelayOff              RelayCapability = "off"
	RelayUnsupported      RelayCapability = "unsupported"
	RelayDisabled         RelayCapability = "disabled"
	RelayEnabled          RelayCapability = "enabled"
	RelayTransientFailure RelayCapability = "transient_failure"

	RelayIdentityAvailable RelayIdentityEvidence = "available"
	RelayIdentityDegraded  RelayIdentityEvidence = "degraded"
)
View Source
const ProtocolVersion = 1

Variables

View Source
var (
	ErrDuplicateRegistration = errors.New("exporter registration key already exists")
	ErrSnapshotSinkRunning   = errors.New("snapshot sink is already running")
	ErrSnapshotSinkStopped   = errors.New("snapshot sink is not running")
)

Functions

This section is empty.

Types

type Capabilities

type Capabilities struct {
	ObserverProtocolVersions []int    `json:"observerProtocolVersions"`
	Features                 []string `json:"features"`
}

func (Capabilities) SupportsFeature

func (c Capabilities) SupportsFeature(feature string) bool

func (Capabilities) SupportsProtocol

func (c Capabilities) SupportsProtocol(version int) bool

type HTTPReporter

type HTTPReporter struct {
	// contains filtered or unexported fields
}

func NewHTTPReporter

func NewHTTPReporter(serverURL string, client *http.Client) (*HTTPReporter, error)

func (*HTTPReporter) Capabilities

func (r *HTTPReporter) Capabilities(ctx context.Context) (Capabilities, error)

func (*HTTPReporter) RequireCapabilities

func (r *HTTPReporter) RequireCapabilities(ctx context.Context, features ...string) error

func (*HTTPReporter) Send

type HTTPStatusError

type HTTPStatusError struct {
	StatusCode int
	Status     string
	Message    string
}

func (*HTTPStatusError) Error

func (e *HTTPStatusError) Error() string

type IncompatibleServerError

type IncompatibleServerError struct {
	Reason string
}

func (*IncompatibleServerError) Error

func (e *IncompatibleServerError) Error() string

type NodeIdentity

type NodeIdentity struct {
	StableNodeID string   `json:"stableNodeId"`
	NodeID       string   `json:"nodeId,omitempty"`
	NodeKey      string   `json:"nodeKey,omitempty"`
	DiscoKey     string   `json:"discoKey,omitempty"`
	Hostname     string   `json:"hostname"`
	DNSName      string   `json:"dnsName,omitempty"`
	OS           string   `json:"os,omitempty"`
	TailscaleIPs []string `json:"tailscaleIps,omitempty"`
}

func (NodeIdentity) CanonicalID

func (n NodeIdentity) CanonicalID() string

func (NodeIdentity) DisplayName

func (n NodeIdentity) DisplayName() string

func (NodeIdentity) HasIdentity

func (n NodeIdentity) HasIdentity() bool

func (NodeIdentity) IdentityKey

func (n NodeIdentity) IdentityKey() string

type ObserverReport

type ObserverReport struct {
	Observer            NodeIdentity      `json:"observer"`
	InventoryGeneration string            `json:"inventoryGeneration"`
	CollectedAt         *time.Time        `json:"collectedAt,omitempty"`
	Peers               []PeerObservation `json:"peers,omitempty"`
}

type Path

type Path struct {
	Kind                  PathKind `json:"kind"`
	DirectEndpoint        string   `json:"directEndpoint,omitempty"`
	DERPRegion            string   `json:"derpRegion,omitempty"`
	PeerRelayStableNodeID string   `json:"peerRelayStableNodeId,omitempty"`
	PeerRelayVNI          *int64   `json:"peerRelayVni,omitempty"`
}

func (Path) Equal

func (p Path) Equal(other Path) bool

type PathKind

type PathKind string
const (
	PathDirect    PathKind = "direct"
	PathDERP      PathKind = "derp"
	PathPeerRelay PathKind = "peer_relay"
	PathUnknown   PathKind = "unknown"
)

type PeerObservation

type PeerObservation struct {
	Peer             NodeIdentity `json:"peer"`
	RxBytes          int64        `json:"rxBytes"`
	TxBytes          int64        `json:"txBytes"`
	RxDelta          int64        `json:"rxDelta"`
	TxDelta          int64        `json:"txDelta"`
	SampleDurationMS int64        `json:"sampleDurationMs"`
	Path             Path         `json:"path"`
	LastActive       time.Time    `json:"lastActive"`
}

type PeerSnapshot

type PeerSnapshot struct {
	Identity NodeIdentity
	RxBytes  int64
	TxBytes  int64
	Path     Path
}

type Registration

type Registration struct {
	// contains filtered or unexported fields
}

func (*Registration) Key

func (r *Registration) Key() string

func (*Registration) Withdraw

func (r *Registration) Withdraw(ctx context.Context) error

type RelayCapability

type RelayCapability string

type RelayClientSnapshot

type RelayClientSnapshot struct {
	SessionClientID string
	Identity        *NodeIdentity
	DiscoShort      string
	Endpoint        string
	PacketsSent     uint64
	BytesSent       uint64
}

type RelayIdentityEvidence

type RelayIdentityEvidence string

type RelaySessionClient

type RelaySessionClient struct {
	SessionClientID string        `json:"sessionClientId"`
	Identity        *NodeIdentity `json:"identity,omitempty"`
	DiscoShort      string        `json:"discoShort,omitempty"`
	Endpoint        string        `json:"endpoint,omitempty"`
}

type RelaySessionObservation

type RelaySessionObservation struct {
	Relay               NodeIdentity       `json:"relay"`
	Source              RelaySessionClient `json:"source"`
	Target              RelaySessionClient `json:"target"`
	SessionID           string             `json:"sessionId"`
	VNI                 int64              `json:"vni"`
	SourceToTargetBytes int64              `json:"sourceToTargetBytes"`
	TargetToSourceBytes int64              `json:"targetToSourceBytes"`
	SourceToTargetDelta int64              `json:"sourceToTargetDelta"`
	TargetToSourceDelta int64              `json:"targetToSourceDelta"`
	SampleDurationMS    int64              `json:"sampleDurationMs"`
	LastActive          time.Time          `json:"lastActive"`
}

type RelaySessionSnapshot

type RelaySessionSnapshot struct {
	SessionID string
	VNI       int64
	Source    RelayClientSnapshot
	Target    RelayClientSnapshot
}

type RelaySnapshot

type RelaySnapshot struct {
	CollectedAt      time.Time
	Capability       RelayCapability
	IdentityEvidence RelayIdentityEvidence
	Sessions         []RelaySessionSnapshot
}

type RelaySource

type RelaySource interface {
	PeerRelaySnapshot(context.Context) (RelaySnapshot, error)
}

RelaySource is an optional capability implemented by sources that can passively observe Peer Relay sessions in addition to ordinary peer state. SnapshotSink samples this capability independently so relay failures cannot delay ordinary observations. Implementations have the same cancellation and shutdown obligations as Source.

type ReportEnvelope

type ReportEnvelope struct {
	Version            int                       `json:"version"`
	ReportID           string                    `json:"reportId"`
	ReporterInstanceID string                    `json:"reporterInstanceId"`
	Sequence           int64                     `json:"sequence"`
	CollectedAt        time.Time                 `json:"collectedAt"`
	Kind               ReportKind                `json:"kind"`
	Observers          []ObserverReport          `json:"observers,omitempty"`
	RelaySessions      []RelaySessionObservation `json:"relaySessions,omitempty"`
}

type ReportKind

type ReportKind string
const (
	ReportObserverHello      ReportKind = "observer_hello"
	ReportInventoryUpdate    ReportKind = "inventory_update"
	ReportTrafficSample      ReportKind = "traffic_sample"
	ReportObserverHeartbeat  ReportKind = "observer_heartbeat"
	ReportObserverWithdrawal ReportKind = "observer_withdrawal"
	ReportRelaySessionUpdate ReportKind = "relay_session_update"
)

type ReportReceipt

type ReportReceipt struct {
	Accepted             bool     `json:"accepted"`
	ResyncRequired       bool     `json:"resyncRequired"`
	ControlStableNodeIDs []string `json:"controlStableNodeIds"`
	HeartbeatIntervalMS  int64    `json:"heartbeatIntervalMs"`
}

type Reporter

type Reporter interface {
	Capabilities(context.Context) (Capabilities, error)
	Send(context.Context, ReportEnvelope) (ReportReceipt, error)
}

type Snapshot

type Snapshot struct {
	CollectedAt time.Time
	Observer    NodeIdentity
	Peers       []PeerSnapshot
}

type SnapshotSink

type SnapshotSink struct {
	// contains filtered or unexported fields
}

func NewSnapshotSink

func NewSnapshotSink(reporter Reporter, options SnapshotSinkOptions) *SnapshotSink

func (*SnapshotSink) Register

func (s *SnapshotSink) Register(key string, source Source) (*Registration, error)

func (*SnapshotSink) Run

func (s *SnapshotSink) Run(ctx context.Context) error

type SnapshotSinkOptions

type SnapshotSinkOptions struct {
	ReporterInstanceID string
	Logger             *slog.Logger
}

type Source

type Source interface {
	Snapshot(context.Context) (Snapshot, error)
}

Source provides passive snapshots for one Tailscale runtime. Implementations must return promptly when the context is canceled or its deadline expires. SnapshotSink does not overlap Snapshot calls for one source, and Run waits for an in-flight call to return during shutdown.

Directories

Path Synopsis
Package tsnet adapts embedded Tailscale runtimes to Tailpath exporter snapshots.
Package tsnet adapts embedded Tailscale runtimes to Tailpath exporter snapshots.

Jump to

Keyboard shortcuts

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