telemetry

package
v1.36.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTelemetryConsumerURL = "aHR0cHM6Ly90ZWxlbWV0cnkud2Vhdmlh" +
		"dGUuaW8vd2VhdmlhdGUtdGVsZW1ldHJ5"
	DefaultTelemetryPushInterval = 24 * time.Hour
)

Variables

View Source
var PayloadType = struct {
	Init      string
	Update    string
	Terminate string
}{
	Init:      "INIT",
	Update:    "UPDATE",
	Terminate: "TERMINATE",
}

PayloadType is the discrete set of statuses which indicate the type of payload sent

Functions

func ClientTrackingMiddleware added in v1.36.0

func ClientTrackingMiddleware(tracker *ClientTracker) func(http.Handler) http.Handler

ClientTrackingMiddleware creates an HTTP middleware that tracks client SDK usage. It should be placed early in the middleware chain to capture all requests.

Types

type ClientInfo added in v1.36.0

type ClientInfo struct {
	Type    ClientType `json:"type"`
	Version string     `json:"version"`
}

ClientInfo represents a client SDK with its type and version

type ClientTracker added in v1.36.0

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

ClientTracker tracks client SDK usage using channel-based concurrency. A background goroutine aggregates tracking events, eliminating lock contention on the hot path (Track method).

func NewClientTracker added in v1.36.0

func NewClientTracker(logger logrus.FieldLogger) *ClientTracker

NewClientTracker creates a new client tracker and starts its background goroutine

func (*ClientTracker) Get added in v1.36.0

func (ct *ClientTracker) Get() map[ClientType]map[string]int64

Get returns the current client counts without resetting. Useful for inspection without clearing data. Returns nil if the tracker has been stopped.

func (*ClientTracker) GetAndReset added in v1.36.0

func (ct *ClientTracker) GetAndReset() map[ClientType]map[string]int64

GetAndReset returns the current client counts and resets the tracker. This is called when building telemetry payloads to get usage data for the reporting period. Returns nil if the tracker has been stopped.

func (*ClientTracker) Stop added in v1.36.0

func (ct *ClientTracker) Stop()

Stop gracefully shuts down the background goroutine. This is safe to call multiple times.

func (*ClientTracker) Track added in v1.36.0

func (ct *ClientTracker) Track(r *http.Request)

Track records a client request. This is non-blocking and safe to call from any goroutine. If the internal buffer is full, the event is dropped silently (telemetry is best-effort).

type ClientType added in v1.36.0

type ClientType string

ClientType represents the type of client SDK

const (
	ClientTypePython     ClientType = "python"
	ClientTypeJava       ClientType = "java"
	ClientTypeCSharp     ClientType = "csharp"
	ClientTypeTypeScript ClientType = "typescript"
	ClientTypeGo         ClientType = "go"
	ClientTypeUnknown    ClientType = "unknown"
)

type Payload

type Payload struct {
	MachineID        strfmt.UUID                     `json:"machineId"`
	Type             string                          `json:"type"`
	Version          string                          `json:"version"`
	ObjectsCount     int64                           `json:"objs"`
	OS               string                          `json:"os"`
	Arch             string                          `json:"arch"`
	UsedModules      []string                        `json:"usedModules,omitempty"`
	CollectionsCount int                             `json:"collectionsCount"`
	ClientUsage      map[ClientType]map[string]int64 `json:"clientUsage,omitempty"`
	CloudProvider    *string                         `json:"cloudProvider,omitempty"`
	UniqueID         *string                         `json:"uniqueID,omitempty"`
}

Payload is the object transmitted for telemetry purposes

type Telemeter

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

Telemeter is responsible for managing the transmission of telemetry data

func New

func New(nodesStatusGetter nodesStatusGetter, schemaManager schemaManager,
	logger logrus.FieldLogger, consumerURL string, pushInterval time.Duration,
) *Telemeter

New creates a new Telemeter instance. consumerURL should be base64-encoded. If empty, uses DefaultTelemetryConsumerURL. pushInterval defaults to DefaultTelemetryPushInterval if zero.

func (*Telemeter) GetClientTracker added in v1.36.0

func (tel *Telemeter) GetClientTracker() *ClientTracker

GetClientTracker returns the client tracker instance for use in middleware

func (*Telemeter) Start

func (tel *Telemeter) Start(ctx context.Context) error

Start begins telemetry for the node

func (*Telemeter) Stop

func (tel *Telemeter) Stop(ctx context.Context) error

Stop shuts down the telemeter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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