Documentation
¶
Index ¶
- Constants
- Variables
- func AlloyStartTimeUnix() int64
- func AlloyStartTimeUnixNano() int64
- func AssertHistogramData(t *testing.T, query string, expectedMetric string, testName string)
- func AssertLabelsNotIndexed(t *testing.T, labels ...string)
- func AssertLogsPresent(t *testing.T, totalCount int, expected ...ExpectedLogResult)
- func AssertMetricData(t *testing.T, query, expectedMetric string, testName string)
- func AssertMetricsAvailable(t *testing.T, metrics []string, histogramMetrics []string, testName string)
- func AssertStatefulTestEnv(t *testing.T)
- func AssertTracesAvailable(t *testing.T, tags map[string]string, probe func(c *assert.CollectT))
- func FetchDataFromURL(url string, target Unmarshaler) (string, error)
- func FetchDataFromURLWithHeaders(url string, headers map[string]string, target Unmarshaler) (string, error)
- func IsStatefulTest() bool
- func LogQuery(testName string, limit int) string
- func LogSeriesQuery(testName string) string
- func MetadataQuery() string
- func MetricQuery(metricName string, testName string) string
- func MetricsQuery(testName string) string
- func MimirMetadataTest(t *testing.T, expectedMetadata map[string]Metadata)
- func MimirMetricsTest(t *testing.T, metrics []string, histogramMetrics []string, testName string)
- func SanitizeTestName(t *testing.T) string
- func TempoSearchQuery(tags map[string]string) string
- func TestTimeoutEnv(t *testing.T) time.Duration
- func TracesTest(t *testing.T, tags map[string]string, testName string)
- func TracesTestWithProbe(t *testing.T, tags map[string]string, testName string, ...)
- func WaitForInitalLogs(testName string) error
- type Bucket
- type ExpectedLogResult
- type HistogramData
- type HistogramRawData
- type LogData
- type LogEntry
- type LogEntryMetadata
- type LogResponse
- type LogSeriesResponse
- type Metadata
- type MetadataResponse
- type Metric
- type MetricData
- type MetricResponse
- type MetricResult
- type MetricsResponse
- type PushRequest
- type TempoTraceSearchResponse
- type TraceInfo
- type Unmarshaler
- type Value
Constants ¶
const ( DefaultRetryInterval = 100 * time.Millisecond DefaultTimeout = 90 * time.Second )
Variables ¶
var ( // Environment variables which carry information about the alloy container under test are prefixed with ALLOY_ AlloyStartTimeEnv = "ALLOY_START_TIME_UNIX" // Environment variables which adjust the test behavior are prefixed with TEST_ TestStatefulEnv = "TEST_STATEFUL" TestTimeout = "TEST_TIMEOUT" )
var OtelDefaultHistogramMetrics = []string{
"example_exponential_histogram",
"example_exponential_float_histogram",
}
Default histogram metrics list according to what the otel-gen app is generating.
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-gen app is generating.
var PromDefaultMetricMetadata = map[string]Metadata{
"golang_counter": {Type: "counter", Help: "The counter description string"},
"golang_gauge": {Type: "gauge", Help: "The gauge description string"},
"golang_histogram": {Type: "histogram", Help: "The histogram description string"},
"golang_mixed_histogram": {Type: "histogram", Help: "The mixed_histogram description string"},
"golang_summary": {Type: "summary", Help: "The summary description string"},
}
Default metrics metadata that the prometheus.remote_write and otelcol.exporter.otlphttp components create in Mimir.
var PromDefaultMetrics = []string{
"golang_counter",
"golang_gauge",
"golang_histogram_bucket",
"golang_histogram_count",
"golang_histogram_sum",
"golang_mixed_histogram_bucket",
"golang_mixed_histogram_count",
"golang_mixed_histogram_sum",
"golang_summary",
}
Default metrics list according to what the prom-gen app is generating.
var PromDefaultNativeHistogramMetadata = map[string]Metadata{
"golang_native_histogram": {Type: "histogram", Help: "The native_histogram description string"},
"golang_mixed_histogram": {Type: "histogram", Help: "The mixed_histogram description string"},
}
Default native histogram metadata
var PromDefaultNativeHistogramMetrics = []string{
"golang_native_histogram",
"golang_mixed_histogram",
}
Default native histogram metrics list according to what the prom-gen app is generating.
var WriteQueueDefaultMetricMetadata = map[string]Metadata{
"golang_counter": {Type: "counter", Help: "The counter description string"},
"golang_gauge": {Type: "gauge", Help: "The gauge description string"},
"golang_histogram_bucket": {Type: "histogram", Help: "The histogram description string"},
"golang_histogram_count": {Type: "histogram", Help: "The histogram description string"},
"golang_histogram_sum": {Type: "histogram", Help: "The histogram description string"},
"golang_mixed_histogram_bucket": {Type: "histogram", Help: "The mixed_histogram description string"},
"golang_mixed_histogram_count": {Type: "histogram", Help: "The mixed_histogram description string"},
"golang_mixed_histogram_sum": {Type: "histogram", Help: "The mixed_histogram description string"},
"golang_summary": {Type: "summary", Help: "The summary description string"},
}
Default metrics metadata that the prometheus.write_queue component creates in Mimir. For some reason it causes _bucket, _count, and _sum metrics to be visible on Mimir's /metadata endpoint. This is not normal. When Prometheus or Alloy's prometheus.remote_write components send metrics to Mimir, only the metric family is visible on Mimir's /metadata endpoint. TODO: Look into why the write_queue components causes Mimir to behave this way.
Functions ¶
func AlloyStartTimeUnix ¶
func AlloyStartTimeUnix() int64
AlloyStartTimeUnix pulls the start time from env.
func AlloyStartTimeUnixNano ¶
func AlloyStartTimeUnixNano() int64
func AssertHistogramData ¶
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 AssertLabelsNotIndexed ¶ added in v1.16.0
AssertLabelsNotIndexed checks that the given label names are not present in Loki stream indexes for this test. This should be call after all logs have been ingested into loki.
func AssertLogsPresent ¶
func AssertLogsPresent(t *testing.T, totalCount int, expected ...ExpectedLogResult)
AssertLogsPresent checks that logs are present in Loki and match expected labels.
func AssertMetricData ¶
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 AssertStatefulTestEnv ¶
AssertStatefulTestEnv verifies the environment is properly configured if the test is supposed to be stateful
func AssertTracesAvailable ¶
AssertTracesAvailable performs a Tempo search query and expects to eventually find traces with the given tags
func FetchDataFromURL ¶
func FetchDataFromURL(url string, target Unmarshaler) (string, error)
func FetchDataFromURLWithHeaders ¶ added in v1.16.0
func IsStatefulTest ¶
func IsStatefulTest() bool
func LogSeriesQuery ¶ added in v1.16.0
LogSeriesQuery returns a Loki series query scoped to the given test_name label.
func MetadataQuery ¶
func MetadataQuery() string
func MetricQuery ¶
MetricQuery returns a formatted Prometheus metric query with a given metricName and the given test_name label.
func MetricsQuery ¶
MetricsQuery returns the list of available metrics matching the given test_name label.
func MimirMetricsTest ¶
MimirMetricsTest checks that all given metrics are stored in Mimir.
func SanitizeTestName ¶
func TempoSearchQuery ¶
TempoSearchQuery builds a Tempo search query URL for traces with given tags
func TracesTest ¶
TracesTest checks that traces with the given tags are stored in Tempo
func TracesTestWithProbe ¶ added in v1.16.0
func TracesTestWithProbe(t *testing.T, tags map[string]string, testName string, probe func(c *assert.CollectT))
TracesTestWithProbe checks that traces with the given tags are stored in Tempo, optionally running probe logic before each Tempo query attempt.
func WaitForInitalLogs ¶
WaitForInitalLogs will try to wait until any logs can be retrieved from loki for testName. It will return an error if no logs are found after test timeout.
Types ¶
type Bucket ¶
type Bucket struct {
BoundaryRule float64
LeftBoundary string
RightBoundary string
CountInBucket string
}
func (*Bucket) UnmarshalJSON ¶
type ExpectedLogResult ¶
type HistogramData ¶
type HistogramRawData ¶
type HistogramRawData struct {
Timestamp float64
Data HistogramData
}
func (*HistogramRawData) UnmarshalJSON ¶
func (h *HistogramRawData) UnmarshalJSON(b []byte) error
type LogEntry ¶ added in v1.16.0
type LogEntry struct {
Timestamp string
Line string
Metadata LogEntryMetadata
}
func (LogEntry) MarshalJSON ¶ added in v1.16.0
func (*LogEntry) UnmarshalJSON ¶ added in v1.16.0
type LogEntryMetadata ¶ added in v1.16.0
type LogResponse ¶
type LogResponse struct {
Status string `json:"status"`
Data struct {
ResultType string `json:"resultType"`
Result []LogData `json:"result"`
} `json:"data"`
}
Query response types
func (*LogResponse) Unmarshal ¶
func (m *LogResponse) Unmarshal(data []byte) error
type LogSeriesResponse ¶ added in v1.16.0
type LogSeriesResponse struct {
Status string `json:"status"`
Data []map[string]string `json:"data"`
}
func (*LogSeriesResponse) Unmarshal ¶ added in v1.16.0
func (m *LogSeriesResponse) Unmarshal(data []byte) error
type MetadataResponse ¶
type MetadataResponse struct {
Status string `json:"status"`
Data map[string][]Metadata `json:"data"`
}
func GetMetadata ¶
func GetMetadata() (MetadataResponse, error)
GetMetadata returns all available metric metadata
func (*MetadataResponse) Unmarshal ¶
func (m *MetadataResponse) Unmarshal(bytes []byte) error
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 ¶
func (*MetricsResponse) Unmarshal ¶
func (m *MetricsResponse) Unmarshal(data []byte) error
type PushRequest ¶
type PushRequest struct {
Streams []LogData `json:"streams"`
}
Push request types
type TempoTraceSearchResponse ¶
type TempoTraceSearchResponse struct {
Traces []TraceInfo `json:"traces"`
}
TempoTraceSearchResponse represents the response from Tempo's trace search API
func (*TempoTraceSearchResponse) Unmarshal ¶
func (t *TempoTraceSearchResponse) Unmarshal(data []byte) error
type TraceInfo ¶
type TraceInfo struct {
TraceID string `json:"traceID"`
RootServiceName string `json:"rootServiceName"`
RootTraceName string `json:"rootTraceName"`
StartTimeUnixNano string `json:"startTimeUnixNano"`
DurationMs float64 `json:"durationMs"`
SpanSet map[string]string `json:"spanSet,omitempty"`
}
TraceInfo represents basic trace information from Tempo search