SSE: Add utility methods for HysteresisCommand (#79157)

* add GetCommandsFromPipeline
* refactor method GetCommandType to func GetExpressionCommandType
* add function to create fingerprint frames
* add function to determine whether raw query represents a hysteresis command and a function to patch it with loaded metrics
This commit is contained in:
Yuri Tseretyan
2023-12-11 22:40:31 +02:00
committed by GitHub
parent f69516bf47
commit bf8be46e6f
7 changed files with 284 additions and 6 deletions
+14
View File
@@ -120,3 +120,17 @@ func FingerprintsFromFrame(frame *data.Frame) (Fingerprints, error) {
}
return result, nil
}
// FingerprintsToFrame converts Fingerprints to data.Frame.
func FingerprintsToFrame(fingerprints Fingerprints) *data.Frame {
fp := make([]uint64, 0, len(fingerprints))
for fingerprint := range fingerprints {
fp = append(fp, uint64(fingerprint))
}
frame := data.NewFrame("", data.NewField("fingerprints", nil, fp))
frame.SetMeta(&data.FrameMeta{
Type: "fingerprints",
TypeVersion: data.FrameTypeVersion{1, 0},
})
return frame
}