telemetry

package
v3.30.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package telemetry contains the telemetry configuration and the hash generator that is used in other telemetry related packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DispatchTask

func DispatchTask(q TaskQueue, consumerID string) task.Func

DispatchTask returns a task that calls Dispatch with the provided consumerID.

func GenerateHash

func GenerateHash(_ context.Context, elems ...string) string

GenerateHash receives a string slice and returns a string of a UID.

func NewRedisTaskQueue

func NewRedisTaskQueue(
	ctx context.Context, cl *ttnredis.Client, maxLen int64, group string, streamBlockLimit time.Duration,
) (TaskQueue, TaskQueueCloser, error)

NewRedisTaskQueue returns new telemetry task queue.

func OSTelemetryData

func OSTelemetryData() *models.OSTelemetry

OSTelemetryData returns the OS telemetry data which is attached to telemetry messages.

func PopTask

func PopTask(q TaskQueue, consumerID string) task.Func

PopTask returns a task that calls Pop with the provided consumerID.

Types

type CLI

type CLI struct {
	Enable bool   `name:"enable" description:"Enables telemetry for CLI"`
	Target string `name:"target" description:"Target to which the information will be sent to"`
}

CLI contains information regarding the telemetry collection for the CLI.

type Config

type Config struct {
	Enable               bool                 `name:"enable" description:"Enables telemetry collection"`
	Target               string               `name:"target" description:"Target to which the information will be sent to"`                                 // nolint:lll
	UIDElements          []string             `name:"uid-elements" description:"Elements that will be used to generate the UID"`                            // nolint:lll
	NumConsumers         uint64               `name:"num-consumers" description:"Number of consumers that will be used to monitor telemetry related tasks"` // nolint:lll
	EntityCountTelemetry EntityCountTelemetry `name:"entity-count-telemetry"`
}

Config contains information regarding the telemetry collection.

type EntityCountTelemetry

type EntityCountTelemetry struct {
	Enable   bool          `name:"enable" description:"Enables entity count collection"`
	Interval time.Duration `name:"interval" description:"Interval between each run of the collection"`
}

EntityCountTelemetry contains information regarding the telemetry collection for the amount of entities.

type RedisTaskQueue

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

RedisTaskQueue is an implementation of telemetry.TaskQueue.

func (*RedisTaskQueue) Add

func (q *RedisTaskQueue) Add(ctx context.Context, id string, startAt time.Time, replace bool) error

Add telemetry task's identifier at time startAt.

func (*RedisTaskQueue) Close

func (q *RedisTaskQueue) Close(ctx context.Context) error

Close closes the TelemetryTaskQueue.

func (*RedisTaskQueue) Dispatch

func (q *RedisTaskQueue) Dispatch(ctx context.Context, consumerID string) error

Dispatch the tasks in the queue.

func (*RedisTaskQueue) Init

func (q *RedisTaskQueue) Init(ctx context.Context) error

Init initializes the TelemetryTaskQueue.

func (*RedisTaskQueue) Pop

func (q *RedisTaskQueue) Pop(ctx context.Context, consumerID string) error

Pop pops the most recent task in the schedule, for which timestamp is in range [0, time.Now()], the value of the queue goes through the registered callback and determines which one should be called.

func (*RedisTaskQueue) RegisterCallback

func (q *RedisTaskQueue) RegisterCallback(callbackID string, callback TaskCallback)

RegisterCallback registers a callback that is called when a task is popped. All callbacks should be registered before the dispatch of the tasks in the queue, otherwise they are proned to fail within the first pop call.

type TaskCallback

type TaskCallback func(context.Context) (time.Time, error)

TaskCallback is a callback that is called when a telemetry task is popped.

func CallbackWithInterval

func CallbackWithInterval(_ context.Context, interval time.Duration, callback task.Func) TaskCallback

CallbackWithInterval is a wrapper that takes a task.Func and a time.Duration and returns a TaskCallback.

type TaskQueue

type TaskQueue interface {
	// Add telemetry task identified by `id` at time t.
	// Implementations must ensure that Add returns fast.
	Add(ctx context.Context, id string, t time.Time, replace bool) error

	// RegisterCallback registers a callback that is called when a task is popped.
	// All callbacks should be registered before the dispatch of the tasks in the queue, otherwise they are proned to
	// fail within the first pop call.
	RegisterCallback(callbackID string, callback TaskCallback)

	// Dispatch the tasks in the queue.
	Dispatch(ctx context.Context, consumerID string) error

	// Pop pops the most recent task in the schedule, for which timestamp is in range [0, time.Now()], the value of
	// the queue goes through the registered callback and determines which one should be called.
	Pop(ctx context.Context, consumerID string) error
}

TaskQueue represents a queue of telemetry tasks.

type TaskQueueCloser

type TaskQueueCloser func(context.Context) error

TaskQueueCloser is a function that closes the task queue.

Directories

Path Synopsis
Package cli contains telemetry functions regarding the collection of data in the CLI.
Package cli contains telemetry functions regarding the collection of data in the CLI.
Package istelemetry contains telemetry functions regarding the collection of data in the IdentityServer.
Package istelemetry contains telemetry functions regarding the collection of data in the IdentityServer.
Package models contains telemetry models.
Package models contains telemetry models.

Jump to

Keyboard shortcuts

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