Documentation ¶
Index ¶
- Variables
- func HashGUIDv1(rawGUID []byte) []byte
- func MustRegister(cs ...Collector)
- func Register(c Collector) error
- func StartKSurveyClient(ctx context.Context, config *Config, registry *Registry) error
- type Collector
- type Config
- type ConstMap
- type Metric
- type MetricData
- type MetricSet
- type Registry
Constants ¶
This section is empty.
Variables ¶
var ( DefaultProgramName = "unknown" DefaultProgramVersion = "0.0.0-unknown" DefaultProgramGUID = []byte("") )
Default proram name and version number which are being used when not provided directly or empty. It is exposed here so it can be overriden.
var DefaultConfig = &Config{ URL: "https://stats.kopano.io/api/stats/v1/submit", StartDelay: 60, ErrorDelay: 60, Interval: 3600, Insecure: false, UserAgent: "ksurveyclient-go/1.0", }
DefaultConfig hols the service client default configuration.
var DefaultLogger logger = &noopLogger{}
DefaultLogger is the logger used by this library if no other is explicitly specified.
var SurveyClientEnabled = true
SurveyClientEnabled directly controls if surveys are sent. When false, all survice clients do nothing.
Functions ¶
func HashGUIDv1 ¶ added in v0.4.0
HashGUIDv1 takes the provided GUID and returns its hash.
func MustRegister ¶
func MustRegister(cs ...Collector)
MustRegister registers the provided Collectors with the default Registry and panics if any error occurs.
func Register ¶
Register registers the provided Collector with the default Registry.
Types ¶
type Collector ¶
type Collector interface {
Collect(ch chan<- Metric)
}
Collector is the interface implemented by anything that can be used to collect survey Metrics.
type Config ¶
type Config struct { URL string StartDelay uint64 ErrorDelay uint64 Interval uint64 Insecure bool UserAgent string Logger logger HTTPClient *http.Client }
Config defines the settings for the service client.
type ConstMap ¶ added in v0.6.0
ConstMap is a used to hold a constant set of key values.
func MustNewConstMap ¶ added in v0.6.0
MustNewConstMap creates a ConstMap with the provided name and field data and panics of an error occurs.
type Metric ¶
type Metric interface { // Write encodes the Metric into MetricData. Write(*MetricData) error }
Metric is the interface implemented by anything that can be used to provide survey Metrics.
type MetricData ¶
MetricData holds the collected data with its name and fields.
type MetricSet ¶
type MetricSet struct {
Content []*MetricData
}
A MetricSet holds the collected MetricData.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
A Registry holds registered Collectors and collects their Metrics.
var DefaultRegistry *Registry
DefaultRegistry is a Registry which is used by default.
func (*Registry) Gather ¶
Gather calls the Collect method of the registered Collectors and then gathers the collected metrics into a MetricSet.
func (*Registry) MustRegister ¶
MustRegister registers the provided Collectors with the accociated Registry and panics if any error occurs.