Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateRandomFloat64(min, max float64) float64
- func GenerateRandomTimestamps(aggregation AggregateBucket, endTimestamp, targetTime time.Time, ...) []time.Time
- type AggregateBucket
- type AggregateFunction
- type AggregationInterval
- type ByMetricName
- type CounterMetricsResponse
- type DataGenerator
- type Filter
- type FilterOp
- type GaugeMetricsResponse
- type GaugeRow
- type GeneratedRawData
- type GeneratedTimeseries
- type GeneratedTimestamp
- func GenerateTimestampsAggregatedPerDay(startTimestamp, endTimestamp time.Time, count int) []GeneratedTimestamp
- func GenerateTimestampsAggregatedPerHour(startTimestamp, endTimestamp time.Time, count int) []GeneratedTimestamp
- func GenerateTimestampsAggregatedPerMinute(startTimestamp, endTimestamp time.Time, count int) []GeneratedTimestamp
- func GenerateTimestampsAggregatedPerSecond(startTimestamp, endTimestamp time.Time, count int) []GeneratedTimestamp
- type GroupBy
- type HistogramDistributionData
- type HistogramDistributionResponse
- type HistogramDistributionRow
- type HistogramMetricRow
- type MetricAttributesGetFn
- type MetricAttributesRow
- type MetricName
- type MetricNameFilters
- type MetricNameGetFn
- type MetricNameResponse
- type MetricNameRow
- type MetricRow
- type MetricSearchMetadataResponse
- type MetricSearchMetadataRow
- type MetricsResponse
- type MockQuerier
- type PerBucketDistribution
- type Querier
- type Query
- type QueryContext
- type QueryData
- type QueryPoint
- type SumMetricsResponse
Constants ¶
const ( AggregationInterval1m = "1m" // minutely AggregationInterval1h = "1h" // hourly AggregationInterval1d = "1d" // daily )
const ( GroupByAttributesAll string = "*" GroupByAttributesBucket string = "bucket" )
const ( RandomProjectID string = "12345" RandomNamespaceID string = "123" RandomServiceName string = "test-service" RandomMetricName string = "random-metric-name" )
const ( GroupingOverAttributes int = iota GroupingOverMetricName GroupingOverNone )
Variables ¶
var ( RandomTraceID = [16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4} RandomSpanID = [8]byte{0, 0, 0, 0, 1, 2, 3, 4} )
var DailyMetricTables = map[pmetric.MetricType]string{ pmetric.MetricTypeGauge: constants.MetricsGauge1dTableNameV2, pmetric.MetricTypeSum: constants.MetricsSum1dTableNameV2, pmetric.MetricTypeHistogram: constants.MetricsHistogram1dTableName, }
var HourlyMetricTables = map[pmetric.MetricType]string{ pmetric.MetricTypeGauge: constants.MetricsGauge1hTableNameV2, pmetric.MetricTypeSum: constants.MetricsSum1hTableNameV2, pmetric.MetricTypeHistogram: constants.MetricsHistogram1hTableName, }
var MinutelyMetricTables = map[pmetric.MetricType]string{ pmetric.MetricTypeGauge: constants.MetricsGauge1mTableNameV2, pmetric.MetricTypeSum: constants.MetricsSum1mTableNameV2, pmetric.MetricTypeHistogram: constants.MetricsHistogram1mTableName, }
var RawMetricTables = map[pmetric.MetricType]string{ pmetric.MetricTypeGauge: constants.MetricsGaugeTableName, pmetric.MetricTypeSum: constants.MetricsSumTableName, pmetric.MetricTypeHistogram: constants.MetricsHistogramTableName, pmetric.MetricTypeExponentialHistogram: constants.MetricsExponentialHistogramTableName, }
var SupportedTimeAggregations = []string{ AggregationInterval1m, AggregationInterval1h, AggregationInterval1d, }
Functions ¶
func GenerateRandomFloat64 ¶
Generate a random float64 value within the range [min .. max)
func GenerateRandomTimestamps ¶
func GenerateRandomTimestamps( aggregation AggregateBucket, endTimestamp, targetTime time.Time, numTimestamps int, ) []time.Time
GenerateRandomTimestamps generates a slice of random timestamps within the given minute
Types ¶
type AggregateBucket ¶
type AggregateBucket string
const ( Raw AggregateBucket = "main" Secondly AggregateBucket = "1s" Minutely AggregateBucket = "1m" Hourly AggregateBucket = "1h" Daily AggregateBucket = "1d" )
type AggregateFunction ¶
type AggregateFunction string
const ( AggregateFunctionUnknown AggregateFunction = "unknown" AggregateFunctionLast AggregateFunction = "last" AggregateFunctionSum AggregateFunction = "sum" AggregateFunctionAvg AggregateFunction = "avg" AggregateFunctionMin AggregateFunction = "min" AggregateFunctionMax AggregateFunction = "max" AggregateFunctionCount AggregateFunction = "count" AggregateFunctionP50 AggregateFunction = "p50" AggregateFunctionP75 AggregateFunction = "p75" AggregateFunctionP90 AggregateFunction = "p90" AggregateFunctionP95 AggregateFunction = "p95" AggregateFunctionP99 AggregateFunction = "p99" )
func GetAggregationFunctionFromString ¶
func GetAggregationFunctionFromString(fn string) AggregateFunction
type AggregationInterval ¶
type AggregationInterval string
type ByMetricName ¶
type ByMetricName []MetricName
func (ByMetricName) Len ¶
func (s ByMetricName) Len() int
func (ByMetricName) Less ¶
func (s ByMetricName) Less(i, j int) bool
func (ByMetricName) Swap ¶
func (s ByMetricName) Swap(i, j int)
type CounterMetricsResponse ¶
type DataGenerator ¶
type DataGenerator struct {
// contains filtered or unexported fields
}
func NewDataGenerator ¶
func NewDataGenerator(db clickhouse.Conn, logger *zap.Logger) *DataGenerator
func (*DataGenerator) GenerateMetrics ¶
func (*DataGenerator) RawData ¶
func (d *DataGenerator) RawData() []GeneratedRawData
func (*DataGenerator) RawDataAggregated ¶
func (d *DataGenerator) RawDataAggregated(q *Query) []GeneratedTimeseries
type GaugeMetricsResponse ¶
type GaugeRow ¶
type GaugeRow struct { MetricName string `ch:"MetricName"` MetricDescription string `ch:"MetricDescription"` MetricUnit string `ch:"MetricUnit"` Fingerprint string `ch:"Fingerprint"` Attributes map[string]string `ch:"FilteredAttributes"` Values []float64 `ch:"Values"` LastValues []float64 `ch:"LastValues"` Times []time.Time `ch:"Times"` }
type GeneratedRawData ¶
type GeneratedTimeseries ¶
type GeneratedTimestamp ¶
func GenerateTimestampsAggregatedPerDay ¶
func GenerateTimestampsAggregatedPerDay(startTimestamp, endTimestamp time.Time, count int) []GeneratedTimestamp
GenerateTimestampsAggregatedPerDay generates a slice of "count" random timestamps grouped per day within a given time-interval: [start, end].
func GenerateTimestampsAggregatedPerHour ¶
func GenerateTimestampsAggregatedPerHour(startTimestamp, endTimestamp time.Time, count int) []GeneratedTimestamp
GenerateTimestampsAggregatedPerHour generates a slice of "count" random timestamps grouped per hour within a given time-interval: [start, end].
func GenerateTimestampsAggregatedPerMinute ¶
func GenerateTimestampsAggregatedPerMinute(startTimestamp, endTimestamp time.Time, count int) []GeneratedTimestamp
GenerateTimestampsAggregatedPerMinute generates a slice of "count" random timestamps grouped per minute within a given time-interval: [start, end].
func GenerateTimestampsAggregatedPerSecond ¶
func GenerateTimestampsAggregatedPerSecond(startTimestamp, endTimestamp time.Time, count int) []GeneratedTimestamp
GenerateTimestampsAggregatedPerSecond generates a slice of "count" random timestamps grouped per second within a given time-interval: [start, end].
type GroupBy ¶
type GroupBy struct { Attributes []string `json:"attribute"` Function AggregateFunction `json:"function"` }
type HistogramDistributionResponse ¶
type HistogramDistributionResponse struct { StartTimestamp int64 `json:"start_ts"` EndTimestamp int64 `json:"end_ts"` Results []HistogramDistributionData `json:"results"` }
type HistogramDistributionRow ¶
type HistogramDistributionRow struct { ProjectID string `ch:"ProjectId"` MetricName string `ch:"MetricName"` MetricDescription string `ch:"MetricDescription"` MetricUnit string `ch:"MetricUnit"` Fingerprint string `ch:"Fingerprint"` StartTimeUnix time.Time `ch:"StartTimeUnix"` AggTimeUnix time.Time `ch:"AggTimeUnix"` AggTemp int32 `ch:"AggTemp"` Min float64 `ch:"Min"` Max float64 `ch:"Max"` Count uint64 `ch:"Count"` Sum float64 `ch:"Sum"` Bounds []float64 `ch:"Bounds"` BoundsHash uint64 `ch:"BoundsHash"` SamplesCount uint64 `ch:"SamplesCount"` Delta []uint64 `ch:"Delta"` Cumulative []uint64 `ch:"Cumulative"` }
type HistogramMetricRow ¶
type HistogramMetricRow struct { MetricName string `ch:"MetricName"` MetricDescription string `ch:"MetricDescription"` MetricUnit string `ch:"MetricUnit"` Fingerprint string `ch:"Fingerprint"` Attributes map[string]string `ch:"Attributes"` Values []float64 `ch:"Values"` Times []time.Time `ch:"Times"` }
type MetricAttributesGetFn ¶
type MetricAttributesRow ¶
type MetricName ¶
type MetricNameFilters ¶
type MetricNameGetFn ¶
type MetricNameGetFn func(context.Context) ([]MetricName, error)
type MetricNameResponse ¶
type MetricNameResponse struct { Metrics []MetricName `json:"metrics"` Attributes []string `json:"all_available_attributes"` }
type MetricNameRow ¶
type MetricRow ¶
type MetricRow struct { MetricName string `ch:"MetricName"` MetricDescription string `ch:"MetricDescription"` MetricUnit string `ch:"MetricUnit"` Fingerprint string `ch:"Fingerprint"` Attributes map[string]string `ch:"FilteredAttributes"` Values []float64 `ch:"Values"` Times []time.Time `ch:"Times"` }
type MetricSearchMetadataResponse ¶
type MetricSearchMetadataResponse struct { MetricName string `json:"name"` MetricType string `json:"type"` MetricDescription string `json:"description"` AttributeKeys []string `json:"attribute_keys"` LastIngestedAt int64 `json:"last_ingested_at"` SupportedAggregations []string `json:"supported_aggregations"` SupportedFunctions []string `json:"supported_functions"` DefaultGroupByAttributes []string `json:"default_group_by_attributes"` DefaultGroupByFunction string `json:"default_group_by_function"` }
type MetricSearchMetadataRow ¶
type MetricsResponse ¶
type MockQuerier ¶
type MockQuerier struct{}
func (*MockQuerier) GetMetricNames ¶
func (*MockQuerier) GetMetricNames(_ context.Context, _ *MetricNameFilters) (*MetricNameResponse, error)
func (*MockQuerier) GetMetrics ¶
func (*MockQuerier) GetMetrics(_ context.Context, _ *QueryContext) (interface{}, error)
func (*MockQuerier) GetSearchMetadata ¶
func (*MockQuerier) GetSearchMetadata(_ context.Context, _ *QueryContext) (interface{}, error)
type PerBucketDistribution ¶
type PerBucketDistribution struct { BucketsHash uint64 `json:"bucketsHash"` Buckets []string `json:"buckets"` Distribution [][]QueryPoint `json:"distribution"` }
type Querier ¶
type Querier interface { GetMetricNames(context.Context, *MetricNameFilters) (*MetricNameResponse, error) GetMetrics(context.Context, *QueryContext) (interface{}, error) GetSearchMetadata(context.Context, *QueryContext) (interface{}, error) }
type Query ¶
type Query struct { TargetMetric string `json:"mname"` TargetType string `json:"mtype"` TargetVisual string `json:"mvisual"` Filters []Filter `json:"filters"` GroupBy GroupBy `json:"groupby"` }
func (*Query) GetGroupingType ¶
type QueryContext ¶
type QueryPoint ¶
type QueryPoint [2]string // time, value