2019-05-22 23:16:55 +02:00
|
|
|
{% import (
|
2022-06-01 01:29:19 +02:00
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/querytracer"
|
2019-05-22 23:16:55 +02:00
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/storage"
|
|
|
|
) %}
|
|
|
|
|
|
|
|
{% stripspace %}
|
|
|
|
|
|
|
|
{% func metricNameObject(mn *storage.MetricName) %}
|
|
|
|
{
|
|
|
|
{% if len(mn.MetricGroup) > 0 %}
|
|
|
|
"__name__":{%qz= mn.MetricGroup %}{% if len(mn.Tags) > 0 %},{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% for j := range mn.Tags %}
|
|
|
|
{% code tag := &mn.Tags[j] %}
|
|
|
|
{%qz= tag.Key %}:{%qz= tag.Value %}{% if j+1 < len(mn.Tags) %},{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
}
|
|
|
|
{% endfunc %}
|
|
|
|
|
|
|
|
{% func metricRow(timestamp int64, value float64) %}
|
|
|
|
[{%f= float64(timestamp)/1e3 %},"{%f= value %}"]
|
|
|
|
{% endfunc %}
|
|
|
|
|
|
|
|
{% func valuesWithTimestamps(values []float64, timestamps []int64) %}
|
2020-07-13 20:40:38 +02:00
|
|
|
{% if len(values) == 0 %}
|
|
|
|
[]
|
|
|
|
{% return %}
|
|
|
|
{% endif %}
|
2019-05-22 23:16:55 +02:00
|
|
|
[
|
2020-07-13 20:40:38 +02:00
|
|
|
{% code /* inline metricRow call here for the sake of performance optimization */ %}
|
|
|
|
[{%f= float64(timestamps[0])/1e3 %},"{%f= values[0] %}"]
|
|
|
|
{% code
|
|
|
|
timestamps = timestamps[1:]
|
|
|
|
values = values[1:]
|
|
|
|
%}
|
2019-05-22 23:16:55 +02:00
|
|
|
{% if len(values) > 0 %}
|
2020-07-13 20:40:38 +02:00
|
|
|
{%code
|
|
|
|
// Remove bounds check inside the loop below
|
|
|
|
_ = timestamps[len(values)-1]
|
2019-05-22 23:16:55 +02:00
|
|
|
%}
|
2020-07-13 20:40:38 +02:00
|
|
|
{% for i, v := range values %}
|
|
|
|
{% code /* inline metricRow call here for the sake of performance optimization */ %}
|
|
|
|
,[{%f= float64(timestamps[i])/1e3 %},"{%f= v %}"]
|
|
|
|
{% endfor %}
|
2019-05-22 23:16:55 +02:00
|
|
|
{% endif %}
|
|
|
|
]
|
|
|
|
{% endfunc %}
|
|
|
|
|
2022-06-01 01:29:19 +02:00
|
|
|
{% func dumpQueryTrace(qt *querytracer.Tracer) %}
|
|
|
|
{% code traceJSON := qt.ToJSON() %}
|
|
|
|
{% if traceJSON != "" %},"trace":{%s= traceJSON %}{% endif %}
|
|
|
|
{% endfunc %}
|
|
|
|
|
2019-05-22 23:16:55 +02:00
|
|
|
{% endstripspace %}
|