telemetry

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package telemetry collects the CLI metrics and sends the telemetry data to supercollider

Index

Constants

View Source
const (
	LocalTanzuCLIMetricsDBFileLock = ".cli_metrics_db.lock"
	// DefaultMetricsDBLockTimeout is the default time waiting on the filelock
	DefaultMetricsDBLockTimeout = 3 * time.Second
)
View Source
const (
	// SQliteDBFileName is the name of the DB file that has CLI metrics
	SQliteDBFileName = "cli_metrics.db"

	// TanzuCLITelemetryMaxRowCount Max metric instances to be accumulated before pausing the collection
	TanzuCLITelemetryMaxRowCount = 10000
)

Variables

View Source
var (
	// CreateTablesSchema defines the database schema to create sqlite database
	CreateTablesSchema = strings.TrimSpace(createTablesSchema)
)

Functions

func AcquireTanzuMetricDBLock

func AcquireTanzuMetricDBLock() error

AcquireTanzuMetricDBLock tries to acquire lock to update tanzu cli metrics DB file with timeout

func LogError

func LogError(err error, msg string, kvs ...interface{})

func LogWarning

func LogWarning(msg string, kvs ...interface{})

func ReleaseTanzuMetricDBLock

func ReleaseTanzuMetricDBLock()

ReleaseTanzuMetricDBLock releases the lock if the cliMetricDBLock was acquired

func TraverseFlagNames

func TraverseFlagNames(args []string) []string

Types

type MetricsDB

type MetricsDB interface {
	// CreateSchema creates table schemas to the provided database.
	// returns error if table creation fails for any reason
	CreateSchema() error

	// SaveOperationMetric inserts CLI operation metrics collected into database
	SaveOperationMetric(*OperationMetricsPayload) error

	// GetRowCount gets metrics table current row count
	GetRowCount() (int, error)

	// ClearMetricData clears all the CLI operation metrics collected in the database
	ClearMetricData() error
}

type MetricsHandler

type MetricsHandler interface {
	// SetInstalledPlugins adds the installed plugins to the handler used to retrieve
	// the plugin information
	SetInstalledPlugins(plugins []cli.PluginInfo)
	// UpdateCmdPreRunMetrics updates the metrics collected before running the command
	UpdateCmdPreRunMetrics(cmd *cobra.Command, args []string) error
	// UpdateCmdPostRunMetrics updates the metrics collected after command execution is completed
	UpdateCmdPostRunMetrics(metrics *PostRunMetrics) error
	// SaveMetrics saves the metrics to the metrics store/DB
	SaveMetrics() error
	// SendMetrics sends the metrics to the destination(metrics data lake)
	SendMetrics(ctx context.Context, timeoutInSecs int) error
}

func Client

func Client() MetricsHandler

type OperationMetricsPayload

type OperationMetricsPayload struct {
	CliID         string
	StartTime     time.Time
	EndTime       time.Time
	Args          []string
	NameArg       string
	CommandName   string
	ExitStatus    int
	PluginName    string
	Flags         string
	CliVersion    string
	PluginVersion string
	Target        string
	Endpoint      string
	IsInternal    bool
	Error         string
}

type PostRunMetrics

type PostRunMetrics struct {
	ExitCode int
}

Jump to

Keyboard shortcuts

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