usagestats

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// File name for the cluster seed file.
	ClusterSeedFileName = "loki_cluster_seed.json"
)

Variables

View Source
var JSONCodec = jsonCodec{}

Functions

func Edition

func Edition(edition string)

Edition sets the edition name. This can be set multiple times.

func NewFloat

func NewFloat(name string) *expvar.Float

NewFloat returns a new Float stats object. If a Float stats object with the same name already exists it is returned.

func NewInt

func NewInt(name string) *expvar.Int

NewInt returns a new Int stats object. If an Int stats object object with the same name already exists it is returned.

func NewString

func NewString(name string) *expvar.String

NewString returns a new String stats object. If a String stats object with the same name already exists it is returned.

func Target

func Target(target string)

Target sets the target name. This can be set multiple times.

Types

type ClusterSeed

type ClusterSeed struct {
	UID                    string    `json:"UID"`
	CreatedAt              time.Time `json:"created_at"`
	prom.PrometheusVersion `json:"version"`
}

ClusterSeed is the seed for the usage stats. A unique ID is generated for each cluster.

func (*ClusterSeed) Clone

func (c *ClusterSeed) Clone() memberlist.Mergeable

func (*ClusterSeed) Merge

func (c *ClusterSeed) Merge(mergeable memberlist.Mergeable, localCAS bool) (change memberlist.Mergeable, error error)

Merge implements the memberlist.Mergeable interface. It allow to merge the content of two different seeds.

func (*ClusterSeed) MergeContent

func (c *ClusterSeed) MergeContent() []string

MergeContent tells if the content of the two seeds are the same.

func (*ClusterSeed) RemoveTombstones

func (c *ClusterSeed) RemoveTombstones(limit time.Time) (total, removed int)

RemoveTombstones is not required for usagestats

type Config

type Config struct {
	Enabled bool `yaml:"reporting_enabled"`
	Leader  bool `yaml:"-"`
}

func (*Config) RegisterFlags

func (cfg *Config) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet

type Counter

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

func NewCounter

func NewCounter(name string) *Counter

NewCounter returns a new Counter stats object. If a Counter stats object with the same name already exists it is returned.

func (*Counter) Inc

func (c *Counter) Inc(i int64)

func (*Counter) String

func (c *Counter) String() string

func (*Counter) Value

func (c *Counter) Value() map[string]interface{}

type Report

type Report struct {
	ClusterID              string    `json:"clusterID"`
	CreatedAt              time.Time `json:"createdAt"`
	Interval               time.Time `json:"interval"`
	IntervalPeriod         float64   `json:"intervalPeriod"`
	Target                 string    `json:"target"`
	prom.PrometheusVersion `json:"version"`
	Os                     string                 `json:"os"`
	Arch                   string                 `json:"arch"`
	Edition                string                 `json:"edition"`
	Metrics                map[string]interface{} `json:"metrics"`
}

Report is the JSON object sent to the stats server

type Reporter

type Reporter struct {
	services.Service
	// contains filtered or unexported fields
}

func NewReporter

func NewReporter(config Config, kvConfig kv.Config, objectClient client.ObjectClient, logger log.Logger, reg prometheus.Registerer) (*Reporter, error)

type Statistics

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

func NewStatistics

func NewStatistics(name string) *Statistics

NewStatistics returns a new Statistics object. Statistics object is thread-safe and compute statistics on the fly based on sample recorded. Available statistics are: - min - max - avg - count - stddev - stdvar If a Statistics object with the same name already exists it is returned.

func (*Statistics) Record

func (s *Statistics) Record(v float64)

func (*Statistics) String

func (s *Statistics) String() string

func (*Statistics) Value

func (s *Statistics) Value() map[string]interface{}

type WordCounter

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

func NewWordCounter

func NewWordCounter(name string) *WordCounter

NewWordCounter returns a new WordCounter stats object. The WordCounter object is thread-safe and counts the number of words recorded. If a WordCounter stats object with the same name already exists it is returned.

func (*WordCounter) Add

func (w *WordCounter) Add(word string)

func (*WordCounter) String

func (w *WordCounter) String() string

func (*WordCounter) Value

func (w *WordCounter) Value() int64

Jump to

Keyboard shortcuts

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