telemetry

package
v0.0.0-...-1fa5987 Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithTelemetry

func ContextWithTelemetry(ctx context.Context, telemetry Telemetry) context.Context

Types

type AmplitudeClient

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

AmplitudeClient was inlfuenced by https://github.com/savaki/amplitude-go but uses the version 2 HTTP API.

func NewAmplitudeClient

func NewAmplitudeClient(ctx context.Context, client *http.Client, apiKey string) *AmplitudeClient

func (*AmplitudeClient) Close

func (a *AmplitudeClient) Close()

func (*AmplitudeClient) Flush

func (a *AmplitudeClient) Flush()

func (*AmplitudeClient) Publish

func (a *AmplitudeClient) Publish(evt Event) error

type Config

type Config struct {
	Disable           bool
	DerefInternalUser bool
	DeviceID          string
}

type Event

type Event struct {
	// Set by event constructor.
	Type            string         `json:"event_type"`
	EventProperties map[string]any `json:"event_properties,omitempty"`
	UserProperties  map[string]any `json:"user_properties,omitempty"`
	Platform        string         `json:"platform,omitempty"`
	OSName          string         `json:"os_name,omitempty"`
	OSVersion       string         `json:"os_version,omitempty"`
	AppVersion      string         `json:"app_version,omitempty"`

	// Set by telemetry.
	DeviceID  string `json:"device_id"`
	SessionID int64  `json:"session_id"`
	EventID   int    `json:"event_id"`
	Time      int64  `json:"time"`
}

func OperationsPerformedEvent

func OperationsPerformedEvent(operation string, success bool, duration SummaryStatistics) Event

func SystemInfoIdentifiedEvent

func SystemInfoIdentifiedEvent() Event

type Nop

type Nop struct {
}

func (*Nop) IsEnabled

func (t *Nop) IsEnabled() bool

func (*Nop) LatestVersion

func (t *Nop) LatestVersion(_ context.Context) (string, error)

func (*Nop) RecordOperation

func (t *Nop) RecordOperation(_ OperationInvocation)

func (*Nop) SendEvent

func (t *Nop) SendEvent(_ context.Context, _ Event)

func (*Nop) StartSession

func (t *Nop) StartSession(_ context.Context)

type OperationInvocation

type OperationInvocation struct {
	Operation      string
	DurationMicros int
	Success        bool
}

type SummaryGauge

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

func NewSummaryGauge

func NewSummaryGauge(tagLabels []string) *SummaryGauge

func (*SummaryGauge) Buckets

func (g *SummaryGauge) Buckets() []taggedSummaryBucket

func (*SummaryGauge) Observe

func (g *SummaryGauge) Observe(tags Tags, amount float64)

type SummaryStatistics

type SummaryStatistics struct {
	Count  int     `json:"count"`
	Sum    float64 `json:"sum"`
	Min    float64 `json:"min"`
	Max    float64 `json:"max"`
	Median float64 `json:"median"`
	Mean   float64 `json:"mean"`
	StdDev float64 `json:"stdDev"`
}

type Tags

type Tags map[string]string

type Telemetry

type Telemetry interface {
	IsEnabled() bool
	LatestVersion(context.Context) (string, error)
	StartSession(context.Context)
	SendEvent(context.Context, Event)
	RecordOperation(OperationInvocation)
}

func FromContext

func FromContext(ctx context.Context) Telemetry

func New

func New(ctx context.Context, cfg Config) Telemetry

type UploadRequest

type UploadRequest struct {
	APIKey string  `json:"api_key"`
	Events []Event `json:"events"`
}

Jump to

Keyboard shortcuts

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