mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-22 16:36:27 +01:00
c1a8a2d54c
Signed-off-by: Konstantin Kulikov <k.kulikov2@gmail.com>
204 lines
7.1 KiB
Go
204 lines
7.1 KiB
Go
// Code generated by qtc from "render_response.qtpl". DO NOT EDIT.
|
|
// See https://github.com/valyala/quicktemplate for details.
|
|
|
|
//line app/vmselect/graphite/render_response.qtpl:3
|
|
package graphite
|
|
|
|
//line app/vmselect/graphite/render_response.qtpl:3
|
|
import (
|
|
"math"
|
|
"sort"
|
|
)
|
|
|
|
// RenderJSONResponse generates response for /render?format=json .See https://graphite.readthedocs.io/en/stable/render_api.html#json
|
|
|
|
//line app/vmselect/graphite/render_response.qtpl:10
|
|
import (
|
|
qtio422016 "io"
|
|
|
|
qt422016 "github.com/valyala/quicktemplate"
|
|
)
|
|
|
|
//line app/vmselect/graphite/render_response.qtpl:10
|
|
var (
|
|
_ = qtio422016.Copy
|
|
_ = qt422016.AcquireByteBuffer
|
|
)
|
|
|
|
//line app/vmselect/graphite/render_response.qtpl:10
|
|
func StreamRenderJSONResponse(qw422016 *qt422016.Writer, nextSeries nextSeriesFunc, jsonp string) {
|
|
//line app/vmselect/graphite/render_response.qtpl:11
|
|
if jsonp != "" {
|
|
//line app/vmselect/graphite/render_response.qtpl:11
|
|
qw422016.N().S(jsonp)
|
|
//line app/vmselect/graphite/render_response.qtpl:11
|
|
qw422016.N().S(`(`)
|
|
//line app/vmselect/graphite/render_response.qtpl:11
|
|
}
|
|
//line app/vmselect/graphite/render_response.qtpl:12
|
|
ss, err := fetchAllSeries(nextSeries)
|
|
|
|
//line app/vmselect/graphite/render_response.qtpl:13
|
|
if err != nil {
|
|
//line app/vmselect/graphite/render_response.qtpl:13
|
|
qw422016.N().S(`{"error":`)
|
|
//line app/vmselect/graphite/render_response.qtpl:15
|
|
qw422016.N().Q(err.Error())
|
|
//line app/vmselect/graphite/render_response.qtpl:15
|
|
qw422016.N().S(`}`)
|
|
//line app/vmselect/graphite/render_response.qtpl:17
|
|
return
|
|
//line app/vmselect/graphite/render_response.qtpl:18
|
|
}
|
|
//line app/vmselect/graphite/render_response.qtpl:19
|
|
sort.Slice(ss, func(i, j int) bool { return ss[i].Name < ss[j].Name })
|
|
|
|
//line app/vmselect/graphite/render_response.qtpl:19
|
|
qw422016.N().S(`[`)
|
|
//line app/vmselect/graphite/render_response.qtpl:21
|
|
for i, s := range ss {
|
|
//line app/vmselect/graphite/render_response.qtpl:22
|
|
streamrenderSeriesJSON(qw422016, s)
|
|
//line app/vmselect/graphite/render_response.qtpl:23
|
|
if i+1 < len(ss) {
|
|
//line app/vmselect/graphite/render_response.qtpl:23
|
|
qw422016.N().S(`,`)
|
|
//line app/vmselect/graphite/render_response.qtpl:23
|
|
}
|
|
//line app/vmselect/graphite/render_response.qtpl:24
|
|
}
|
|
//line app/vmselect/graphite/render_response.qtpl:24
|
|
qw422016.N().S(`]`)
|
|
//line app/vmselect/graphite/render_response.qtpl:26
|
|
if jsonp != "" {
|
|
//line app/vmselect/graphite/render_response.qtpl:26
|
|
qw422016.N().S(`)`)
|
|
//line app/vmselect/graphite/render_response.qtpl:26
|
|
}
|
|
//line app/vmselect/graphite/render_response.qtpl:27
|
|
}
|
|
|
|
//line app/vmselect/graphite/render_response.qtpl:27
|
|
func WriteRenderJSONResponse(qq422016 qtio422016.Writer, nextSeries nextSeriesFunc, jsonp string) {
|
|
//line app/vmselect/graphite/render_response.qtpl:27
|
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
|
//line app/vmselect/graphite/render_response.qtpl:27
|
|
StreamRenderJSONResponse(qw422016, nextSeries, jsonp)
|
|
//line app/vmselect/graphite/render_response.qtpl:27
|
|
qt422016.ReleaseWriter(qw422016)
|
|
//line app/vmselect/graphite/render_response.qtpl:27
|
|
}
|
|
|
|
//line app/vmselect/graphite/render_response.qtpl:27
|
|
func RenderJSONResponse(nextSeries nextSeriesFunc, jsonp string) string {
|
|
//line app/vmselect/graphite/render_response.qtpl:27
|
|
qb422016 := qt422016.AcquireByteBuffer()
|
|
//line app/vmselect/graphite/render_response.qtpl:27
|
|
WriteRenderJSONResponse(qb422016, nextSeries, jsonp)
|
|
//line app/vmselect/graphite/render_response.qtpl:27
|
|
qs422016 := string(qb422016.B)
|
|
//line app/vmselect/graphite/render_response.qtpl:27
|
|
qt422016.ReleaseByteBuffer(qb422016)
|
|
//line app/vmselect/graphite/render_response.qtpl:27
|
|
return qs422016
|
|
//line app/vmselect/graphite/render_response.qtpl:27
|
|
}
|
|
|
|
//line app/vmselect/graphite/render_response.qtpl:29
|
|
func streamrenderSeriesJSON(qw422016 *qt422016.Writer, s *series) {
|
|
//line app/vmselect/graphite/render_response.qtpl:29
|
|
qw422016.N().S(`{"target":`)
|
|
//line app/vmselect/graphite/render_response.qtpl:31
|
|
qw422016.N().Q(s.Name)
|
|
//line app/vmselect/graphite/render_response.qtpl:31
|
|
qw422016.N().S(`,"tags":{`)
|
|
//line app/vmselect/graphite/render_response.qtpl:34
|
|
tagKeys := make([]string, 0, len(s.Tags))
|
|
for k := range s.Tags {
|
|
tagKeys = append(tagKeys, k)
|
|
}
|
|
sort.Strings(tagKeys)
|
|
|
|
//line app/vmselect/graphite/render_response.qtpl:40
|
|
for i, k := range tagKeys {
|
|
//line app/vmselect/graphite/render_response.qtpl:41
|
|
v := s.Tags[k]
|
|
|
|
//line app/vmselect/graphite/render_response.qtpl:42
|
|
qw422016.N().Q(k)
|
|
//line app/vmselect/graphite/render_response.qtpl:42
|
|
qw422016.N().S(`:`)
|
|
//line app/vmselect/graphite/render_response.qtpl:42
|
|
qw422016.N().Q(v)
|
|
//line app/vmselect/graphite/render_response.qtpl:43
|
|
if i+1 < len(tagKeys) {
|
|
//line app/vmselect/graphite/render_response.qtpl:43
|
|
qw422016.N().S(`,`)
|
|
//line app/vmselect/graphite/render_response.qtpl:43
|
|
}
|
|
//line app/vmselect/graphite/render_response.qtpl:44
|
|
}
|
|
//line app/vmselect/graphite/render_response.qtpl:44
|
|
qw422016.N().S(`},"datapoints":[`)
|
|
//line app/vmselect/graphite/render_response.qtpl:47
|
|
timestamps := s.Timestamps
|
|
|
|
//line app/vmselect/graphite/render_response.qtpl:48
|
|
for i, v := range s.Values {
|
|
//line app/vmselect/graphite/render_response.qtpl:48
|
|
qw422016.N().S(`[`)
|
|
//line app/vmselect/graphite/render_response.qtpl:50
|
|
if math.IsNaN(v) || math.IsInf(v, 0) {
|
|
//line app/vmselect/graphite/render_response.qtpl:50
|
|
qw422016.N().S(`null`)
|
|
//line app/vmselect/graphite/render_response.qtpl:50
|
|
} else {
|
|
//line app/vmselect/graphite/render_response.qtpl:50
|
|
qw422016.N().F(v)
|
|
//line app/vmselect/graphite/render_response.qtpl:50
|
|
}
|
|
//line app/vmselect/graphite/render_response.qtpl:50
|
|
qw422016.N().S(`,`)
|
|
//line app/vmselect/graphite/render_response.qtpl:51
|
|
qw422016.N().DL(timestamps[i] / 1e3)
|
|
//line app/vmselect/graphite/render_response.qtpl:51
|
|
qw422016.N().S(`]`)
|
|
//line app/vmselect/graphite/render_response.qtpl:53
|
|
if i+1 < len(timestamps) {
|
|
//line app/vmselect/graphite/render_response.qtpl:53
|
|
qw422016.N().S(`,`)
|
|
//line app/vmselect/graphite/render_response.qtpl:53
|
|
}
|
|
//line app/vmselect/graphite/render_response.qtpl:54
|
|
}
|
|
//line app/vmselect/graphite/render_response.qtpl:54
|
|
qw422016.N().S(`]}`)
|
|
//line app/vmselect/graphite/render_response.qtpl:57
|
|
}
|
|
|
|
//line app/vmselect/graphite/render_response.qtpl:57
|
|
func writerenderSeriesJSON(qq422016 qtio422016.Writer, s *series) {
|
|
//line app/vmselect/graphite/render_response.qtpl:57
|
|
qw422016 := qt422016.AcquireWriter(qq422016)
|
|
//line app/vmselect/graphite/render_response.qtpl:57
|
|
streamrenderSeriesJSON(qw422016, s)
|
|
//line app/vmselect/graphite/render_response.qtpl:57
|
|
qt422016.ReleaseWriter(qw422016)
|
|
//line app/vmselect/graphite/render_response.qtpl:57
|
|
}
|
|
|
|
//line app/vmselect/graphite/render_response.qtpl:57
|
|
func renderSeriesJSON(s *series) string {
|
|
//line app/vmselect/graphite/render_response.qtpl:57
|
|
qb422016 := qt422016.AcquireByteBuffer()
|
|
//line app/vmselect/graphite/render_response.qtpl:57
|
|
writerenderSeriesJSON(qb422016, s)
|
|
//line app/vmselect/graphite/render_response.qtpl:57
|
|
qs422016 := string(qb422016.B)
|
|
//line app/vmselect/graphite/render_response.qtpl:57
|
|
qt422016.ReleaseByteBuffer(qb422016)
|
|
//line app/vmselect/graphite/render_response.qtpl:57
|
|
return qs422016
|
|
//line app/vmselect/graphite/render_response.qtpl:57
|
|
}
|