collector

package
v0.0.0-...-b846661 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InFlightGauge = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: namespace,
		Name:      "client_in_flight_requests",
		Help:      "A gauge of in-flight requests for the wrapped client.",
	})

	ClientRequestCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: namespace,
			Name:      "client_api_requests_total",
			Help:      "A counter for requests from the wrapped client.",
		},
		[]string{"code", "method"},
	)

	// DnsLatencyVec uses custom buckets based on expected dns durations.
	// It has an instance label "event", which is set in the
	// DNSStart and DNSDonehook functions defined in the
	// InstrumentTrace struct below.
	DnsLatencyVec = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: namespace,
			Name:      "dns_duration_seconds",
			Help:      "Trace dns latency histogram.",
			Buckets:   []float64{.005, .01, .025, .05},
		},
		[]string{"event"},
	)

	// TlsLatencyVec uses custom buckets based on expected tls durations.
	// It has an instance label "event", which is set in the
	// TLSHandshakeStart and TLSHandshakeDone hook functions defined in the
	// InstrumentTrace struct below.
	TlsLatencyVec = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: namespace,
			Name:      "tls_duration_seconds",
			Help:      "Trace tls latency histogram.",
			Buckets:   []float64{.05, .1, .25, .5},
		},
		[]string{"event"},
	)

	// HistVec has no labels, making it a zero-dimensional ObserverVec.
	HistVec = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: namespace,
			Name:      "request_duration_seconds",
			Help:      "A histogram of request latencies.",
			Buckets:   prometheus.DefBuckets,
		},
		[]string{},
	)
)
View Source
var ErrNoData = errors.New("collector returned no data")

ErrNoData indicates the collector found no data to collect, but had no other error.

Functions

func InstrumentTransport

func InstrumentTransport(t http.RoundTripper) http.RoundTripper

InstrumentTransportMiddleware wraps the transport and instruments it

func InstrumentTransportMiddleware

func InstrumentTransportMiddleware() func(t http.RoundTripper) http.RoundTripper

InstrumentTransportMiddleware creates a middleware which can be used to instrument transports

func IsNoDataError

func IsNoDataError(err error) bool

Types

type BucketStatsCollector

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

func (*BucketStatsCollector) Collect

func (bsc *BucketStatsCollector) Collect(ch chan<- prometheus.Metric)

Collect is called by the Prometheus registry when collecting metrics. The implementation sends each collected metric via the provided channel and returns once the last metric has been sent. The descriptor of each sent metric is one of those returned by Describe (unless the Collector is unchecked, see above). Returned metrics that share the same descriptor must differ in their variable label values.

This method may be called concurrently and must therefore be implemented in a concurrency safe way. Blocking occurs at the expense of total performance of rendering all registered metrics. Ideally, Collector implementations support concurrent readers.

func (*BucketStatsCollector) Describe

func (bsc *BucketStatsCollector) Describe(ch chan<- *prometheus.Desc)

Describe sends the super-set of all possible descriptors of metrics collected by this Collector to the provided channel and returns once the last descriptor has been sent. The sent descriptors fulfill the consistency and uniqueness requirements described in the Desc documentation.

It is valid if one and the same Collector sends duplicate descriptors. Those duplicates are simply ignored. However, two different Collectors must not send duplicate descriptors.

Sending no descriptor at all marks the Collector as “unchecked”, i.e. no checks will be performed at registration time, and the Collector may yield any Metric it sees fit in its Collect method.

This method idempotently sends the same descriptors throughout the lifetime of the Collector. It may be called concurrently and therefore must be implemented in a concurrency safe way.

If a Collector encounters an error while executing this method, it must send an invalid descriptor (created with NewInvalidDesc) to signal the error to the registry.

func (*BucketStatsCollector) Update

func (bsc *BucketStatsCollector) Update(ch chan<- prometheus.Metric) error

Update gets new metrics and expose them via prometheus registry.

type Collector

type Collector interface {
	// Get new metrics and expose them via prometheus registry.
	Update(ch chan<- prometheus.Metric) error
}

Collector is the interface a collector has to implement.

func NewBucketStatsCollector

func NewBucketStatsCollector(api *client.API, clusterName string, batchSize int, collectTimeout time.Duration) Collector

func NewUserStatsCollector

func NewUserStatsCollector(api *client.API, clusterName string) Collector

func NewUserUsageCollector

func NewUserUsageCollector(api *client.API, clusterName string, usagePerBucket bool) Collector

type UsageCollector

type UsageCollector struct {
	Collectors map[string]Collector
	// contains filtered or unexported fields
}

func NewUsageCollector

func NewUsageCollector(logger log.Logger, collector map[string]Collector) (*UsageCollector, error)

func (*UsageCollector) Collect

func (uc *UsageCollector) Collect(ch chan<- prometheus.Metric)

Collect is called by the Prometheus registry when collecting metrics. The implementation sends each collected metric via the provided channel and returns once the last metric has been sent. The descriptor of each sent metric is one of those returned by Describe (unless the Collector is unchecked, see above). Returned metrics that share the same descriptor must differ in their variable label values.

This method may be called concurrently and must therefore be implemented in a concurrency safe way. Blocking occurs at the expense of total performance of rendering all registered metrics. Ideally, Collector implementations support concurrent readers.

func (*UsageCollector) Describe

func (u *UsageCollector) Describe(ch chan<- *prometheus.Desc)

Describe sends the super-set of all possible descriptors of metrics collected by this Collector to the provided channel and returns once the last descriptor has been sent. The sent descriptors fulfill the consistency and uniqueness requirements described in the Desc documentation.

It is valid if one and the same Collector sends duplicate descriptors. Those duplicates are simply ignored. However, two different Collectors must not send duplicate descriptors.

Sending no descriptor at all marks the Collector as “unchecked”, i.e. no checks will be performed at registration time, and the Collector may yield any Metric it sees fit in its Collect method.

This method idempotently sends the same descriptors throughout the lifetime of the Collector. It may be called concurrently and therefore must be implemented in a concurrency safe way.

If a Collector encounters an error while executing this method, it must send an invalid descriptor (created with NewInvalidDesc) to signal the error to the registry.

type UserStatsCollector

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

func (*UserStatsCollector) Collect

func (usc *UserStatsCollector) Collect(ch chan<- prometheus.Metric)

Collect is called by the Prometheus registry when collecting metrics. The implementation sends each collected metric via the provided channel and returns once the last metric has been sent. The descriptor of each sent metric is one of those returned by Describe (unless the Collector is unchecked, see above). Returned metrics that share the same descriptor must differ in their variable label values.

This method may be called concurrently and must therefore be implemented in a concurrency safe way. Blocking occurs at the expense of total performance of rendering all registered metrics. Ideally, Collector implementations support concurrent readers.

func (*UserStatsCollector) Describe

func (usc *UserStatsCollector) Describe(ch chan<- *prometheus.Desc)

Describe sends the super-set of all possible descriptors of metrics collected by this Collector to the provided channel and returns once the last descriptor has been sent. The sent descriptors fulfill the consistency and uniqueness requirements described in the Desc documentation.

It is valid if one and the same Collector sends duplicate descriptors. Those duplicates are simply ignored. However, two different Collectors must not send duplicate descriptors.

Sending no descriptor at all marks the Collector as “unchecked”, i.e. no checks will be performed at registration time, and the Collector may yield any Metric it sees fit in its Collect method.

This method idempotently sends the same descriptors throughout the lifetime of the Collector. It may be called concurrently and therefore must be implemented in a concurrency safe way.

If a Collector encounters an error while executing this method, it must send an invalid descriptor (created with NewInvalidDesc) to signal the error to the registry.

func (*UserStatsCollector) Update

func (usc *UserStatsCollector) Update(ch chan<- prometheus.Metric) error

Update gets new metrics and expose them via prometheus registry.

type UserUsageCollector

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

func (*UserUsageCollector) Collect

func (uuc *UserUsageCollector) Collect(ch chan<- prometheus.Metric)

Collect is called by the Prometheus registry when collecting metrics. The implementation sends each collected metric via the provided channel and returns once the last metric has been sent. The descriptor of each sent metric is one of those returned by Describe (unless the Collector is unchecked, see above). Returned metrics that share the same descriptor must differ in their variable label values.

This method may be called concurrently and must therefore be implemented in a concurrency safe way. Blocking occurs at the expense of total performance of rendering all registered metrics. Ideally, Collector implementations support concurrent readers.

func (*UserUsageCollector) Describe

func (uuc *UserUsageCollector) Describe(ch chan<- *prometheus.Desc)

Describe sends the super-set of all possible descriptors of metrics collected by this Collector to the provided channel and returns once the last descriptor has been sent. The sent descriptors fulfill the consistency and uniqueness requirements described in the Desc documentation.

It is valid if one and the same Collector sends duplicate descriptors. Those duplicates are simply ignored. However, two different Collectors must not send duplicate descriptors.

Sending no descriptor at all marks the Collector as “unchecked”, i.e. no checks will be performed at registration time, and the Collector may yield any Metric it sees fit in its Collect method.

This method idempotently sends the same descriptors throughout the lifetime of the Collector. It may be called concurrently and therefore must be implemented in a concurrency safe way.

If a Collector encounters an error while executing this method, it must send an invalid descriptor (created with NewInvalidDesc) to signal the error to the registry.

func (*UserUsageCollector) Update

func (uuc *UserUsageCollector) Update(ch chan<- prometheus.Metric) error

Update gets new metrics and expose them via prometheus registry.

type UserWithBuckets

type UserWithBuckets struct {
	admin.User
	Buckets []string
}

Jump to

Keyboard shortcuts

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