common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRetryInterval = 100 * time.Millisecond
View Source
const DefaultTimeout = time.Minute

Variables

View Source
var OtelDefaultHistogramMetrics = []string{
	"example_exponential_histogram",
	"example_exponential_float_histogram",
}

Default histogram metrics list according to what the otel-metrics-gen app is generating.

View Source
var OtelDefaultMetrics = []string{
	"example_counter",
	"example_float_counter",
	"example_updowncounter",
	"example_float_updowncounter",
	"example_histogram_bucket",
	"example_float_histogram_bucket",
}

Default metrics list according to what the otel-metrics-gen app is generating.

View Source
var PromDefaultHistogramMetric = []string{
	"golang_native_histogram",
}

Default histogram metrics list according to what the prom-gen app is generating.

View Source
var PromDefaultMetrics = []string{
	"golang_counter",
	"golang_gauge",
	"golang_histogram_bucket",
	"golang_summary",
}

Default metrics list according to what the prom-gen app is generating.

Functions

func AssertHistogramData

func AssertHistogramData(t *testing.T, query string, expectedMetric string, testName string)

AssertHistogramData performs a Prometheus query and expect the result to eventually contain the expected histogram. The count and sum metrics should be greater than 10 before the timeout triggers.

func AssertMetricData

func AssertMetricData(t *testing.T, query, expectedMetric string, testName string)

AssertMetricData performs a Prometheus query and expect the result to eventually contain the expected metric.

func AssertMetricsAvailable

func AssertMetricsAvailable(t *testing.T, metrics []string, histogramMetrics []string, testName string)

AssertMetricsAvailable performs a Prometheus query and expect the result to eventually contain the list of expected metrics.

func FetchDataFromURL

func FetchDataFromURL(url string, target Unmarshaler) error

func MetricQuery

func MetricQuery(metricName string, testName string) string

MetricQuery returns a formatted Prometheus metric query with a given metricName and the given test_name label.

func MetricsQuery

func MetricsQuery(testName string) string

MetricsQuery returns the list of available metrics matching the given test_name label.

func MimirMetricsTest

func MimirMetricsTest(t *testing.T, metrics []string, histogramMetrics []string, testName string)

MimirMetricsTest checks that all given metrics are stored in Mimir.

Types

type Bucket

type Bucket struct {
	BoundaryRule  float64
	LeftBoundary  string
	RightBoundary string
	CountInBucket string
}

func (*Bucket) UnmarshalJSON

func (b *Bucket) UnmarshalJSON(data []byte) error

type HistogramData

type HistogramData struct {
	Count   string   `json:"count"`
	Sum     string   `json:"sum"`
	Buckets []Bucket `json:"buckets"`
}

type HistogramRawData

type HistogramRawData struct {
	Timestamp int64
	Data      HistogramData
}

func (*HistogramRawData) UnmarshalJSON

func (h *HistogramRawData) UnmarshalJSON(b []byte) error

type LogData

type LogData struct {
	Stream map[string]string `json:"stream"`
	Values [][2]string       `json:"values"`
}

type LogResponse

type LogResponse struct {
	Status string `json:"status"`
	Data   struct {
		ResultType string    `json:"resultType"`
		Result     []LogData `json:"result"`
	} `json:"data"`
}

func (*LogResponse) Unmarshal

func (m *LogResponse) Unmarshal(data []byte) error

type Metric

type Metric struct {
	TestName string `json:"test_name"`
	Name     string `json:"__name__"`
}

type MetricData

type MetricData struct {
	ResultType string         `json:"resultType"`
	Result     []MetricResult `json:"result"`
}

type MetricResponse

type MetricResponse struct {
	Status string     `json:"status"`
	Data   MetricData `json:"data"`
}

func (*MetricResponse) Unmarshal

func (m *MetricResponse) Unmarshal(data []byte) error

type MetricResult

type MetricResult struct {
	Metric    Metric            `json:"metric"`
	Value     *Value            `json:"value,omitempty"`
	Histogram *HistogramRawData `json:"histogram,omitempty"`
}

type MetricsResponse

type MetricsResponse struct {
	Status string   `json:"status"`
	Data   []Metric `json:"data"`
}

func (*MetricsResponse) Unmarshal

func (m *MetricsResponse) Unmarshal(data []byte) error

type Unmarshaler

type Unmarshaler interface {
	Unmarshal([]byte) error
}

type Value

type Value struct {
	Timestamp int64
	Value     string
}

func (*Value) UnmarshalJSON

func (v *Value) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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