telemetry

package
v0.24.3 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TelemetryCommand     string = "shuttle.command"
	TelemetryCommandArgs string = "shuttle.command.args"
)

Variables

This section is empty.

Functions

func ContextIDFrom

func ContextIDFrom(ctx context.Context) string

func RunIDFrom

func RunIDFrom(ctx context.Context) string

func Setup

func Setup()

Initializes the telemetry setup, if not called, NoopTelemetryClient will be used

func Trace

func Trace(ctx context.Context, label string, options ...TelemetryOption)

func TraceError

func TraceError(ctx context.Context, label string, err error, options ...TelemetryOption)

func WithContextID

func WithContextID(ctx context.Context) context.Context

func WithContextValue

func WithContextValue(ctx context.Context, key, value string) context.Context

func WithRunID

func WithRunID(ctx context.Context) context.Context

Types

type AvailabilityCheckFunc

type AvailabilityCheckFunc = func(ctx context.Context) (bool, error)

AvailabilityCheckFunc gets whether the telemetry uploader is available for upload

type GetTelemetryFileFunc

type GetTelemetryFileFunc = func(ctx context.Context, telemetryFilePath string) ([]UploadTraceEvent, func(ctx context.Context) error, error)

GetTelemetryFileFunc reads the trace event files and returns a set of tracevents and the option to delete the file after upload is finished

type GetTelemetryFilesFunc

type GetTelemetryFilesFunc = func(ctx context.Context, location string) ([]string, error)

GetTelemetryFilesFunc fetches trace event file name from a certain location. Each read is delegated to GetTelemetryFileFunc

type JsonLinesTelemetryClient

type JsonLinesTelemetryClient struct {
	*http.Client
	// contains filtered or unexported fields
}

func (*JsonLinesTelemetryClient) Trace

func (t *JsonLinesTelemetryClient) Trace(
	ctx context.Context,
	properties map[string]string,
)

type LockFunc

type LockFunc = func(ctx context.Context) (UnlockFunc, bool, error)

LockFunc makes sure only a single upload process is run pr storage location

type LoggingTelemetryClient

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

func (*LoggingTelemetryClient) Trace

func (t *LoggingTelemetryClient) Trace(
	ctx context.Context,
	properties map[string]string,
)

type NoopTelemetryClient

type NoopTelemetryClient struct{}

func (*NoopTelemetryClient) Trace

func (*NoopTelemetryClient) Trace(ctx context.Context, properties map[string]string)

type TelemetryClient

type TelemetryClient interface {
	Trace(ctx context.Context, properties map[string]string)
}

type TelemetryOption

type TelemetryOption func(properties map[string]string)

func WithEntry

func WithEntry(key, value string) TelemetryOption

func WithGoInfo

func WithGoInfo() TelemetryOption

func WithLabel

func WithLabel(label string) TelemetryOption

func WithPhase

func WithPhase(phase string) TelemetryOption

type TelemetryUploader

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

func NewTelemetryUploader

func NewTelemetryUploader(url string, options ...UploadOptions) *TelemetryUploader

func (*TelemetryUploader) Upload

func (tu *TelemetryUploader) Upload(ctx context.Context) error

Upload kicks off the file upload process. This involves reading trace event files and uploading them to a determined location. See Options (With*) for extra documentation

type UnlockFunc

type UnlockFunc = func(ctx context.Context) error

UnluckFunc clears the locks set for the storage location

type UploadFunc

type UploadFunc = func(ctx context.Context, url string, event []UploadTraceEvent) error

UploadFunc handles upload for a set of trace events

type UploadOptions

type UploadOptions = func(*TelemetryUploader)

func WithAvailabilityCheck

func WithAvailabilityCheck(url string) UploadOptions

WithAvailabilityCheck adds a check for the upload location, this is useful if there are scenarios where the upload process shouldn't be run. I.e. you're not on a vpn, or on a slow internet connection

func WithCleanUp

func WithCleanUp(enabled bool) UploadOptions

WithCleanUp determines whether to remove telemetry files after they've been read. There are no consistency guarantees that no duplicates will be uploaded on error if run, or dropped traces

func WithDefaultAvailabilityCheck

func WithDefaultAvailabilityCheck() UploadOptions

WithDefaultAvailabilityCheck sets a Noop availability check

func WithFileLock

func WithFileLock(storageLocation string) UploadOptions

WithFileLock this adds a file lock at a certain location, this is useful if there may be concurrent/parallel processes on the same storage location

func WithGetTelemetryFile

func WithGetTelemetryFile(getTelemetryFileFunc GetTelemetryFileFunc) UploadOptions

WithGetTelemetryFile sets the get telemetry file func

func WithGetTelemetryFiles

func WithGetTelemetryFiles(getTelemetryFilesFunc GetTelemetryFilesFunc) UploadOptions

WithGetTelemetryFiles sets the get telemetry files

func WithNoLock

func WithNoLock() UploadOptions

WithNoLock removes the default file lock

func WithRate

func WithRate(rate time.Duration) UploadOptions

WithRate sets the current rate of which events will be uploaded

func WithRemoteLogLocation

func WithRemoteLogLocation(location string) UploadOptions

WithRemoteLogLocation sets where shuttle telemetry files are located

func WithUploadFunction

func WithUploadFunction(uploadFunc UploadFunc) UploadOptions

WithUploadFunction sets the upload function to something custom

type UploadTraceEvent

type UploadTraceEvent struct {
	App        string            `json:"app"`
	Timestamp  time.Time         `json:"timestamp"`
	Properties map[string]string `json:"properties"`
}

Jump to

Keyboard shortcuts

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