telemetry

package
v0.129.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DATASOURCE_USAGE_METRIC_NAME = "WG_DATASOURCE_USAGE"
)
View Source
const (
	DefaultTimeout = 5
)

Variables

This section is empty.

Functions

func Annotations added in v0.128.0

func Annotations(annotations Annotation) map[string]string

func CobraFullCommandPathMetricName

func CobraFullCommandPathMetricName(cmd *cobra.Command) string

func DurationMetricSuffix

func DurationMetricSuffix(cmdName string) string

func HasAnnotations added in v0.128.0

func HasAnnotations(annotations Annotation, values map[string]string) bool

func Hash added in v0.128.0

func Hash(value string) (string, error)

Hash hashes a telemetry value to anonymize it. Always use this function to ensure the hashing algorithm stays consistent

func UsageMetricSuffix

func UsageMetricSuffix(cmdName string) string

Types

type Annotation added in v0.128.0

type Annotation int

Annotation indicates which data should be reported as telemetry when a wunderctl command is ran

const (
	// AnnotationCommand indicates the annotated command usage and duration should be reported as telemetry
	AnnotationCommand Annotation = 1 << iota
	// AnnotationDataSources indicates the data sources should be reported as telemetry
	AnnotationDataSources
)

type Client

type Client interface {
	Send(metrics []*Metric) error
}

func NewClient

func NewClient(address string, clientInfo *MetricClientInfo, opts ...ClientOption) Client

type ClientOption

type ClientOption func(*client)

func WithAuthToken added in v0.128.0

func WithAuthToken(token string) ClientOption

func WithDebug

func WithDebug(debug bool) ClientOption

func WithLogger

func WithLogger(logger *zap.Logger) ClientOption

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

type DurationMetric

type DurationMetric func() *Metric

func NewDurationMetric

func NewDurationMetric(name string) DurationMetric

NewDurationMetric starts a duration metric. The duration will be stop when PrepareBatch is called.

type GraphQLError

type GraphQLError struct {
	Message string `json:"message"`
}

type GraphQLResponse

type GraphQLResponse struct {
	Data   interface{} `json:"data"`
	Errors []GraphQLError
}

type Metric

type Metric struct {
	Name  string      `json:"name"`
	Value float64     `json:"value"`
	Tags  []MetricTag `json:"tags,omitempty"`
}

func DataSourceMetrics added in v0.128.0

func DataSourceMetrics(wunderGraphDir string) ([]*Metric, error)

func NewDataSourceMetric added in v0.128.0

func NewDataSourceMetric(dataSourceName string) *Metric

NewDataSourceMetric creates a data metric from the data source name

func NewUsageMetric

func NewUsageMetric(name string) *Metric

NewUsageMetric creates a simple metric. The value will be 1.

func (*Metric) AddTag added in v0.128.0

func (m *Metric) AddTag(name string, value string) error

AddTag adds a tag to the Metric, validating its name and ensuring there are no duplicates.

func (*Metric) Equal added in v0.128.0

func (m *Metric) Equal(other *Metric) bool

Equal returns true iff both Metric instances contain the same data (tags might be in different order)

type MetricClientInfo

type MetricClientInfo struct {
	OsName           string `json:"osName,omitempty"`
	CpuCount         int    `json:"cpuCount,omitempty"`
	IsCI             bool   `json:"isCI"`
	WunderctlVersion string `json:"wunderctlVersion,omitempty"`
	AnonymousID      string `json:"anonymousID,omitempty"`
	GitRepoURLHash   string `json:"gitRepoURLHash,omitempty"`
}

type MetricRequest

type MetricRequest struct {
	Metrics    []*Metric        `json:"metrics"`
	ClientInfo MetricClientInfo `json:"clientInfo"`
}

type MetricTag added in v0.128.0

type MetricTag struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

func (MetricTag) Equal added in v0.128.0

func (m MetricTag) Equal(other MetricTag) bool

Equal returns true iff both Name and Value are Equal

Jump to

Keyboard shortcuts

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