Documentation ¶
Index ¶
- Constants
- func Annotations(annotations Annotation) map[string]string
- func CobraFullCommandPathMetricName(cmd *cobra.Command) string
- func DurationMetricSuffix(cmdName string) string
- func HasAnnotations(annotations Annotation, values map[string]string) bool
- func Hash(value string) (string, error)
- func UsageMetricSuffix(cmdName string) string
- type Annotation
- type Client
- type ClientOption
- type DurationMetric
- type GraphQLError
- type GraphQLResponse
- type Metric
- type MetricClientInfo
- type MetricRequest
- type MetricTag
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 DurationMetricSuffix ¶
func HasAnnotations ¶ added in v0.128.0
func HasAnnotations(annotations Annotation, values map[string]string) bool
func Hash ¶ added in v0.128.0
Hash hashes a telemetry value to anonymize it. Always use this function to ensure the hashing algorithm stays consistent
func UsageMetricSuffix ¶
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 ¶
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 FeatureMetrics ¶ added in v0.164.0
func NewDataSourceMetric ¶ added in v0.128.0
NewDataSourceMetric creates a data metric from the data source name
func NewFeatureMetric ¶ added in v0.164.0
NewFeatureMetric creates a data metric which tracks the usage of the given featureName
func NewUsageMetric ¶
NewUsageMetric creates a simple metric. The value will be 1.
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"` }
Click to show internal directories.
Click to hide internal directories.