telemetry

package
v0.179.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DATASOURCE_USAGE_METRIC_NAME = "WG_DATASOURCE_USAGE"
	FEATURE_USAGE_METRIC_NAME    = "WG_FEATURE_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
	// AnnotationFeatures indicates that the used features should be reported as telemetry
	AnnotationFeatures
)

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 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 FeatureMetrics added in v0.164.0

func FeatureMetrics(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 NewFeatureMetric added in v0.164.0

func NewFeatureMetric(featureName features.Feature) *Metric

NewFeatureMetric creates a data metric which tracks the usage of the given featureName

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"`
	IsWGCloud                bool   `json:"isWGCloud"`
	WunderctlVersion         string `json:"wunderctlVersion,omitempty"`
	AnonymousID              string `json:"anonymousID,omitempty"`
	GitRepoURLHash           string `json:"gitRepoURLHash,omitempty"`
	APICount                 int    `json:"apiCount"`
	AuthProviderCount        int    `json:"authProviderCount"`
	GraphQLOperationCount    int    `json:"graphqlOperationCount"`
	TypeScriptOperationCount int    `json:"typeScriptOperationCount"`
}

func NewClientInfo added in v0.164.0

func NewClientInfo(version string, anonymousID string, wunderGraphDir string) (*MetricClientInfo, error)

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