Documentation
¶
Index ¶
- func EqualsAmongTwo(sums ...float64) bool
- func EqualsSingle(expected float64) func(float64) bool
- func GreaterAmongTwo(sums ...float64) bool
- func LessAmongTwo(sums ...float64) bool
- func SumValues(values []float64) float64
- type CompositeInstrumentedRunnable
- func (r *CompositeInstrumentedRunnable) Instances() []*InstrumentedRunnable
- func (r *CompositeInstrumentedRunnable) MetricTargets() (ret []Target)
- func (r *CompositeInstrumentedRunnable) SumMetrics(metricNames []string, opts ...MetricsOption) ([]float64, error)
- func (r *CompositeInstrumentedRunnable) WaitSumMetrics(expected MetricValueExpectation, metricNames ...string) error
- func (r *CompositeInstrumentedRunnable) WaitSumMetricsWithOptions(expected MetricValueExpectation, metricNames []string, opts ...MetricsOption) error
- type Instrumented
- type InstrumentedOption
- type InstrumentedRunnable
- func (r *InstrumentedRunnable) MetricTargets() []Target
- func (r *InstrumentedRunnable) Metrics() (_ string, err error)
- func (r *InstrumentedRunnable) SumMetrics(metricNames []string, opts ...MetricsOption) ([]float64, error)
- func (r *InstrumentedRunnable) WaitRemovedMetric(metricName string, opts ...MetricsOption) error
- func (r *InstrumentedRunnable) WaitSumMetrics(expected MetricValueExpectation, metricNames ...string) error
- func (r *InstrumentedRunnable) WaitSumMetricsWithOptions(expected MetricValueExpectation, metricNames []string, opts ...MetricsOption) error
- type MetricValueExpectation
- type MetricsOption
- type Option
- type Prometheus
- type Service
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EqualsAmongTwo ¶
EqualsAmongTwo is an isExpected function for WaitSumMetrics that returns true if first sum is equal to the second. NOTE: Be careful on scrapes in between of process that changes two metrics. Those are usually not atomic.
func EqualsSingle ¶
func GreaterAmongTwo ¶
GreaterAmongTwo is an isExpected function for WaitSumMetrics that returns true if first sum is greater than second. NOTE: Be careful on scrapes in between of process that changes two metrics. Those are usually not atomic.
func LessAmongTwo ¶
LessAmongTwo is an isExpected function for WaitSumMetrics that returns true if first sum is smaller than second. NOTE: Be careful on scrapes in between of process that changes two metrics. Those are usually not atomic.
Types ¶
type CompositeInstrumentedRunnable ¶
type CompositeInstrumentedRunnable struct {
// contains filtered or unexported fields
}
CompositeInstrumentedRunnable abstract a higher-level service composed by more than one InstrumentedRunnable.
func NewCompositeInstrumentedRunnable ¶
func NewCompositeInstrumentedRunnable(runnables ...*InstrumentedRunnable) *CompositeInstrumentedRunnable
func (*CompositeInstrumentedRunnable) Instances ¶
func (r *CompositeInstrumentedRunnable) Instances() []*InstrumentedRunnable
func (*CompositeInstrumentedRunnable) MetricTargets ¶
func (r *CompositeInstrumentedRunnable) MetricTargets() (ret []Target)
func (*CompositeInstrumentedRunnable) SumMetrics ¶
func (r *CompositeInstrumentedRunnable) SumMetrics(metricNames []string, opts ...MetricsOption) ([]float64, error)
SumMetrics returns the sum of the values of each given metric names.
func (*CompositeInstrumentedRunnable) WaitSumMetrics ¶
func (r *CompositeInstrumentedRunnable) WaitSumMetrics(expected MetricValueExpectation, metricNames ...string) error
WaitSumMetrics waits for at least one instance of each given metric names to be present and their sums, returning true when passed to given expected(...).
func (*CompositeInstrumentedRunnable) WaitSumMetricsWithOptions ¶
func (r *CompositeInstrumentedRunnable) WaitSumMetricsWithOptions(expected MetricValueExpectation, metricNames []string, opts ...MetricsOption) error
type Instrumented ¶
type Instrumented interface { MetricTargets() []Target Metrics() (string, error) WaitSumMetrics(expected MetricValueExpectation, metricNames ...string) error WaitSumMetricsWithOptions(expected MetricValueExpectation, metricNames []string, opts ...MetricsOption) error SumMetrics(metricNames []string, opts ...MetricsOption) ([]float64, error) WaitRemovedMetric(metricName string, opts ...MetricsOption) error }
Instrumented represents methods for instrumented runnable focused on accessing instrumented metrics.
type InstrumentedOption ¶
type InstrumentedOption func(*rOpt)
InstrumentedOption is a variadic option for AsInstrumented.
func WithInstrumentedMetricPath ¶
func WithInstrumentedMetricPath(metricPath string) InstrumentedOption
WithInstrumentedMetricPath sets a custom path for metrics page. "/metrics" by default.
func WithInstrumentedScheme ¶
func WithInstrumentedScheme(scheme string) InstrumentedOption
WithInstrumentedScheme allows adding customized scheme. "http" or "https" values allowed. "http" by default. If "https" is specified, insecure TLS will be performed.
func WithInstrumentedWaitBackoff ¶
func WithInstrumentedWaitBackoff(waitBackoff *backoff.Backoff) InstrumentedOption
WithInstrumentedWaitBackoff allows customizing wait backoff when accessing or asserting on the metric endpoint.
type InstrumentedRunnable ¶
InstrumentedRunnable represents runnable with instrumented Prometheus metric endpoint on a certain port.
func AsInstrumented ¶
func AsInstrumented(r e2e.Runnable, instrumentedPortName string, opts ...InstrumentedOption) *InstrumentedRunnable
AsInstrumented wraps e2e.Runnable with InstrumentedRunnable. If runnable is running during invocation AsInstrumented panics. NOTE(bwplotka): Caller is expected to discard passed `r` runnable and use returned InstrumentedRunnable.Runnable instead.
func NewStaticMetricsServer ¶
func NewStaticMetricsServer(e e2e.Environment, name string, metrics []byte) *InstrumentedRunnable
NewStaticMetricsServer creates a new nginx server that serves the content of metrics as /metrics endpoint. This is useful for testing different metrics scrapers.
func (*InstrumentedRunnable) MetricTargets ¶
func (r *InstrumentedRunnable) MetricTargets() []Target
func (*InstrumentedRunnable) Metrics ¶
func (r *InstrumentedRunnable) Metrics() (_ string, err error)
func (*InstrumentedRunnable) SumMetrics ¶
func (r *InstrumentedRunnable) SumMetrics(metricNames []string, opts ...MetricsOption) ([]float64, error)
SumMetrics returns the sum of the values of each given metric names.
func (*InstrumentedRunnable) WaitRemovedMetric ¶
func (r *InstrumentedRunnable) WaitRemovedMetric(metricName string, opts ...MetricsOption) error
WaitRemovedMetric waits until a metric disappear from the list of metrics exported by the service.
func (*InstrumentedRunnable) WaitSumMetrics ¶
func (r *InstrumentedRunnable) WaitSumMetrics(expected MetricValueExpectation, metricNames ...string) error
WaitSumMetrics waits for at least one instance of each given metric names to be present and their sums, returning true when passed to given expected(...).
func (*InstrumentedRunnable) WaitSumMetricsWithOptions ¶
func (r *InstrumentedRunnable) WaitSumMetricsWithOptions(expected MetricValueExpectation, metricNames []string, opts ...MetricsOption) error
type MetricValueExpectation ¶
func Between ¶
func Between(lower, upper float64) MetricValueExpectation
Between is a MetricValueExpectation function for WaitSumMetrics that returns true if given single sum is between the lower and upper bounds (non-inclusive, as in `lower < x < upper`).
func Equals ¶
func Equals(value float64) MetricValueExpectation
Equals is an MetricValueExpectation function for WaitSumMetrics that returns true if given single sum is equals to given value.
func Greater ¶
func Greater(value float64) MetricValueExpectation
Greater is an isExpected function for WaitSumMetrics that returns true if given single sum is greater than given value.
func GreaterOrEqual ¶
func GreaterOrEqual(value float64) MetricValueExpectation
GreaterOrEqual is an isExpected function for WaitSumMetrics that returns true if given single sum is greater or equal than given value.
func Less ¶
func Less(value float64) MetricValueExpectation
Less is an isExpected function for WaitSumMetrics that returns true if given single sum is less than given value.
type MetricsOption ¶
type MetricsOption func(*metricsOptions)
MetricsOption defined the signature of a function used to manipulate options.
func SkipMissingMetrics ¶
func SkipMissingMetrics() MetricsOption
SkipMissingMetrics is an option to skip/ignore whenever an expected metric is missing.
func WaitMissingMetrics ¶
func WaitMissingMetrics() MetricsOption
WaitMissingMetrics is an option to wait whenever an expected metric is missing. If this option is not enabled, will return error on missing metrics.
func WithLabelMatchers ¶
func WithLabelMatchers(matchers ...*matchers.Matcher) MetricsOption
WithLabelMatchers is an option to filter only matching series.
func WithMetricCount ¶
func WithMetricCount() MetricsOption
WithMetricCount is an option to get the histogram/summary count as metric value.
func WithWaitBackoff ¶
func WithWaitBackoff(backoffConfig *backoff.Config) MetricsOption
WithWaitBackoff is an option to configure a backoff when waiting on a metric value.
type Option ¶
type Option func(*opt)
func WithCadvisorDisabled ¶
func WithCadvisorDisabled() Option
func WithCustomRegistry ¶
func WithCustomRegistry(reg *prometheus.Registry) Option
WithCustomRegistry allows injecting a custom registry to use for this process metrics. NOTE(bwplotka): Injected registry will be used as is, while the default registry will have prometheus.NewGoCollector() and prometheus.NewProcessCollector(..) registered.
func WithPrometheusImage ¶
WithPrometheusImage allows injecting custom Prometheus docker image to use as scraper and queryable.
func WithScrapeInterval ¶
WithScrapeInterval changes how often metrics are scrape by Prometheus. 5s by default.
type Prometheus ¶
type Prometheus struct { e2e.Runnable Instrumented }
func NewPrometheus ¶
func NewPrometheus(env e2e.Environment, name string, image string, flagOverride map[string]string) *Prometheus
func (*Prometheus) SetConfig ¶
func (p *Prometheus) SetConfig(config promconfig.Config) error
func (*Prometheus) SetConfigEncoded ¶
func (p *Prometheus) SetConfigEncoded(config []byte) error
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func Start ¶
func Start(env e2e.Environment, opts ...Option) (_ *Service, err error)
Start deploys monitoring service which deploys Prometheus that monitors all InstrumentedRunnable instances in an environment created with AsInstrumented.
func (*Service) GetMonitoringRunnable ¶
GetMonitoringRunnable returns a Prometheus monitoring runnable.
func (*Service) InstantQuery ¶
InstantQuery evaluates instant PromQL queries against monitoring service.