forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prometheus: Add Exemplar sampling for streaming parser (grafana#56049) (
grafana#56571) (cherry picked from commit 152c7f1) Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com>
- Loading branch information
1 parent
94341ed
commit d5bb8ab
Showing
30 changed files
with
76,206 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
GO = go | ||
SHELL = /bin/zsh | ||
|
||
ITERATIONS=10 | ||
BENCH=repeat $(ITERATIONS) $(LEFT_BRACKET) $(GO) test -benchmem -run=^$$ -bench | ||
PROFILE=$(GO) test -benchmem -run=^$$ -benchtime 1x -memprofile memprofile.out -memprofilerate 1 -cpuprofile cpuprofile.out -bench | ||
|
||
LEFT_BRACKET = { | ||
RIGHT_BRACKET = } | ||
|
||
memprofile-exemplar memprofile-range: %: --% | ||
$(GO) tool pprof -http=localhost:6061 memprofile.out | ||
|
||
cpuprofile-exemplar cpuprofile-range: %: --% | ||
$(GO) tool pprof -http=localhost:6061 cpuprofile.out | ||
|
||
benchmark-exemplar benchmark-range: %: --% | ||
sed -i 's/buffered/querydata/g' old.txt | ||
benchstat old.txt new.txt | ||
rm old.txt new.txt | ||
|
||
--benchmark-range: | ||
$(BENCH) ^BenchmarkRangeJson ./buffered >> old.txt $(RIGHT_BRACKET) | ||
$(BENCH) ^BenchmarkRangeJson ./querydata >> new.txt $(RIGHT_BRACKET) | ||
|
||
--memprofile-range: | ||
$(PROFILE) ^BenchmarkRangeJson ./querydata | ||
|
||
--cpuprofile-range: | ||
$(PROFILE) ^BenchmarkRangeJson ./querydata | ||
|
||
--benchmark-exemplar: | ||
$(BENCH) ^BenchmarkExemplarJson ./buffered >> old.txt $(RIGHT_BRACKET) | ||
$(BENCH) ^BenchmarkExemplarJson ./querydata >> new.txt $(RIGHT_BRACKET) | ||
|
||
--memprofile-exemplar: | ||
$(PROFILE) ^BenchmarkExemplarJson ./querydata | ||
|
||
--cpuprofile-exemplar: | ||
$(PROFILE) ^BenchmarkExemplarJson ./querydata | ||
|
||
.PHONY: benchmark-range benchmark-exemplar memprofile-range memprofile-exemplar cpuprofile-range cpuprofile-exemplar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package models | ||
|
||
import "github.com/grafana/grafana-plugin-sdk-go/data" | ||
|
||
type ResultType string | ||
|
||
const ( | ||
ResultTypeMatrix ResultType = "matrix" | ||
ResultTypeExemplar ResultType = "exemplar" | ||
ResultTypeVector ResultType = "vector" | ||
ResultTypeUnknown ResultType = "" | ||
) | ||
|
||
func ResultTypeFromFrame(frame *data.Frame) ResultType { | ||
if frame.Meta.Custom == nil { | ||
return ResultTypeUnknown | ||
} | ||
custom, ok := frame.Meta.Custom.(map[string]string) | ||
if !ok { | ||
return ResultTypeUnknown | ||
} | ||
|
||
rt, ok := custom["resultType"] | ||
if !ok { | ||
return ResultTypeUnknown | ||
} | ||
|
||
switch rt { | ||
case ResultTypeMatrix.String(): | ||
return ResultTypeMatrix | ||
case ResultTypeExemplar.String(): | ||
return ResultTypeExemplar | ||
case ResultTypeVector.String(): | ||
return ResultTypeVector | ||
} | ||
|
||
return ResultTypeUnknown | ||
} | ||
|
||
func (r ResultType) String() string { | ||
return string(r) | ||
} |
Oops, something went wrong.