Skip to content

Commit

Permalink
fix(cheker,api,notifier): update carbonapi to v0.16.2-0 (#947)
Browse files Browse the repository at this point in the history
* fix(cheker,api,notifier): update carbonapi to v0.16.2-0

* fix(test): fix flapping TestParseMetric
  • Loading branch information
msaf1980 authored Nov 7, 2023
1 parent 28a9866 commit f534208
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 9 deletions.
2 changes: 1 addition & 1 deletion filter/metrics_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func TestParseMetric(t *testing.T) {
// [n=19] One.two.three 123 1234567890.6790847778320312500

for i := 1; i < 7; i++ {
rawTimestamp := strconv.FormatFloat(float64(testTimestamp)+rand.Float64(), 'f', i, 64)
rawTimestamp := strconv.FormatFloat(float64(testTimestamp)+0.9*rand.Float64(), 'f', i, 64)
rawMetric := "One.two.three 123 " + rawTimestamp
validMetric := ValidMetricCase{rawMetric, "One.two.three", "One.two.three", map[string]string{}, 123, testTimestamp}
parsedMetric, err := ParseMetric([]byte(validMetric.input))
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/dustin/go-humanize v1.0.1
github.com/go-chi/chi v4.1.2+incompatible
github.com/go-chi/render v1.0.1
github.com/go-graphite/carbonapi v0.16.0
github.com/go-graphite/carbonapi v0.16.2-0.20231101113133-39b476ab3e6d
github.com/go-graphite/protocol v1.0.0
github.com/go-redis/redis/v8 v8.11.5
github.com/go-redsync/redsync/v4 v4.4.4
Expand Down Expand Up @@ -55,7 +55,6 @@ require (
)

require (
bitbucket.org/tebeka/strftime v0.0.0-20140926081919-2194253a23c0 // indirect
github.com/JaderDias/movingmedian v0.0.0-20220813210630-d8c6b6de8835 // indirect
github.com/Masterminds/sprig/v3 v3.2.3
github.com/RoaringBitmap/roaring v1.3.0 // indirect
Expand Down Expand Up @@ -192,6 +191,7 @@ require (
github.com/shopspring/decimal v1.2.0 // indirect
github.com/swaggo/files v1.0.1 // indirect
github.com/swaggo/swag v1.8.12 // indirect
github.com/tebeka/strftime v0.1.5 // indirect
golang.org/x/tools v0.12.0 // indirect
)

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
bitbucket.org/tebeka/strftime v0.0.0-20140926081919-2194253a23c0 h1:800dI8vRxVMgss6UcZY8gxk8PvYw7Qo1ZI3TrUkTKjc=
bitbucket.org/tebeka/strftime v0.0.0-20140926081919-2194253a23c0/go.mod h1:9BKpS/J2txC7Ql3QUhesesiV3HsIsA7zl7VK6cQVg5M=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.31.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
Expand Down Expand Up @@ -589,8 +587,8 @@ github.com/go-errors/errors v1.1.1/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWE
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-graphite/carbonapi v0.16.0 h1:HvPjAKYChiwdHtNpFu33hLRpPCYA7gyyeFWpPR2XvXs=
github.com/go-graphite/carbonapi v0.16.0/go.mod h1:RQpis4h2a1kxn1s/R5LQXbumFj+kR2bRz+BebPN1Z1Q=
github.com/go-graphite/carbonapi v0.16.2-0.20231101113133-39b476ab3e6d h1:XzKqULyL0Qlsz5VVl7Q82YWFbdnJTZYCc1lO4kKKUEs=
github.com/go-graphite/carbonapi v0.16.2-0.20231101113133-39b476ab3e6d/go.mod h1:vefIVMyWf471SFMpHS4CSbySjGaMPtNxmMTnTlU2tSc=
github.com/go-graphite/protocol v1.0.0 h1:Fqb0mkVVtfMrn6vw6Ntm3raf3gVVZCOVdZu4JosW5qE=
github.com/go-graphite/protocol v1.0.0/go.mod h1:eonkg/0UGhJUYu+PshOg1NzWSUcXskr/yHeQXJHJr8Y=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
Expand Down Expand Up @@ -1086,6 +1084,8 @@ github.com/swaggo/http-swagger v1.3.4/go.mod h1:9dAh0unqMBAlbp1uE2Uc2mQTxNMU/ha4
github.com/swaggo/swag v1.8.12 h1:pctzkNPu0AlQP2royqX3apjKCQonAnf7KGoxeO4y64w=
github.com/swaggo/swag v1.8.12/go.mod h1:lNfm6Gg+oAq3zRJQNEMBE66LIJKM44mxFqhEEgy2its=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/tebeka/strftime v0.1.5 h1:1NQKN1NiQgkqd/2moD6ySP/5CoZQsKa1d3ZhJ44Jpmg=
github.com/tebeka/strftime v0.1.5/go.mod h1:29/OidkoWHdEKZqzyDLUyC+LmgDgdHo4WAFCDT7D/Ig=
github.com/tinylib/msgp v1.1.8 h1:FCXC1xanKO4I8plpHGH2P7koL/RzZs12l/+r7vakfm0=
github.com/tinylib/msgp v1.1.8/go.mod h1:qkpG+2ldGg4xRFmx+jfTvZPxfGFhi64BcnL9vkCm/Tw=
github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU=
Expand Down
4 changes: 2 additions & 2 deletions metric_source/local/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (ctx *evalCtx) parse(target string) (parser.Expr, error) {
}

func (ctx *evalCtx) getMetricsData(database moira.Database, parsedExpr parser.Expr) (*fetchedMetrics, error) {
metricRequests := parsedExpr.Metrics()
metricRequests := parsedExpr.Metrics(0, 0)

metrics := make([]string, 0)
metricsMap := make(map[parser.MetricRequest][]*types.MetricData)
Expand Down Expand Up @@ -190,7 +190,7 @@ func (ctx *evalCtx) writeResult(exp parser.Expr, metrics *fetchedMetrics, metric
}

result.Metrics = append(result.Metrics, metrics.metrics...)
for _, mr := range exp.Metrics() {
for _, mr := range exp.Metrics(0, 0) {
result.Patterns = append(result.Patterns, mr.Metric)
}
}
Expand Down
60 changes: 60 additions & 0 deletions metric_source/local/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,66 @@ func TestLocalSourceFetch(t *testing.T) {
Patterns: []string{pattern1},
})
})

Convey("Test success evaluate target with aliasByTags('name')", t, func() {
database.EXPECT().GetPatternMetrics(pattern1).Return([]string{metric}, nil)
database.EXPECT().GetMetricRetention(metric).Return(retention, nil)
database.EXPECT().GetMetricsValues([]string{metric}, retentionFrom, retentionUntil-1).Return(dataList, nil)
database.EXPECT().GetMetricsTTLSeconds().Return(metricsTTL)

result, err := localSource.Fetch("super.puper.pattern | aliasByTags('name')", from, until, true)

So(err, ShouldBeNil)
So(result, ShouldResemble, &FetchResult{
MetricsData: []metricSource.MetricData{{
Name: "super.puper.metric",
StartTime: retentionFrom,
StopTime: retentionUntil,
StepTime: retention,
Values: []float64{0, 1, 2, 3, 4},
}},
Metrics: []string{metric},
Patterns: []string{pattern1},
})
})

Convey("Test success evaluate target with currentAbove(3.99)", t, func() {
database.EXPECT().GetPatternMetrics(pattern1).Return([]string{metric}, nil)
database.EXPECT().GetMetricRetention(metric).Return(retention, nil)
database.EXPECT().GetMetricsValues([]string{metric}, retentionFrom, retentionUntil-1).Return(dataList, nil)
database.EXPECT().GetMetricsTTLSeconds().Return(metricsTTL)

result, err := localSource.Fetch("super.puper.pattern | currentAbove(3.99)", from, until, true)

So(err, ShouldBeNil)
So(result, ShouldResemble, &FetchResult{
MetricsData: []metricSource.MetricData{{
Name: "super.puper.metric",
StartTime: retentionFrom,
StopTime: retentionUntil,
StepTime: retention,
Values: []float64{0, 1, 2, 3, 4},
}},
Metrics: []string{metric},
Patterns: []string{pattern1},
})
})

Convey("Test success evaluate target with currentAbove(4)", t, func() {
database.EXPECT().GetPatternMetrics(pattern1).Return([]string{metric}, nil)
database.EXPECT().GetMetricRetention(metric).Return(retention, nil)
database.EXPECT().GetMetricsValues([]string{metric}, retentionFrom, retentionUntil-1).Return(dataList, nil)
database.EXPECT().GetMetricsTTLSeconds().Return(metricsTTL)

result, err := localSource.Fetch("super.puper.pattern | currentAbove(4)", from, until, true)

So(err, ShouldBeNil)
So(result, ShouldResemble, &FetchResult{
MetricsData: []metricSource.MetricData{},
Metrics: []string{metric},
Patterns: []string{pattern1},
})
})
}

func TestLocalSourceFetchNoRealTimeAlerting(t *testing.T) {
Expand Down

0 comments on commit f534208

Please sign in to comment.