// Code generated by qtc from "export.qtpl". DO NOT EDIT.
// See https://github.com/valyala/quicktemplate for details.

//line app/vmselect/prometheus/export.qtpl:1
package prometheus

//line app/vmselect/prometheus/export.qtpl:1
import (
	"bytes"
	"math"
	"strings"
	"time"

	"github.com/VictoriaMetrics/VictoriaMetrics/lib/querytracer"
	"github.com/VictoriaMetrics/VictoriaMetrics/lib/storage"
	"github.com/valyala/quicktemplate"
)

//line app/vmselect/prometheus/export.qtpl:14
import (
	qtio422016 "io"

	qt422016 "github.com/valyala/quicktemplate"
)

//line app/vmselect/prometheus/export.qtpl:14
var (
	_ = qtio422016.Copy
	_ = qt422016.AcquireByteBuffer
)

//line app/vmselect/prometheus/export.qtpl:14
func StreamExportCSVHeader(qw422016 *qt422016.Writer, fieldNames []string) {
//line app/vmselect/prometheus/export.qtpl:15
	if len(fieldNames) == 0 {
//line app/vmselect/prometheus/export.qtpl:15
		return
//line app/vmselect/prometheus/export.qtpl:15
	}
//line app/vmselect/prometheus/export.qtpl:16
	qw422016.N().S(fieldNames[0])
//line app/vmselect/prometheus/export.qtpl:17
	for _, fieldName := range fieldNames[1:] {
//line app/vmselect/prometheus/export.qtpl:17
		qw422016.N().S(`,`)
//line app/vmselect/prometheus/export.qtpl:19
		qw422016.N().S(fieldName)
//line app/vmselect/prometheus/export.qtpl:20
	}
//line app/vmselect/prometheus/export.qtpl:21
	qw422016.N().S(`
`)
//line app/vmselect/prometheus/export.qtpl:22
}

//line app/vmselect/prometheus/export.qtpl:22
func WriteExportCSVHeader(qq422016 qtio422016.Writer, fieldNames []string) {
//line app/vmselect/prometheus/export.qtpl:22
	qw422016 := qt422016.AcquireWriter(qq422016)
//line app/vmselect/prometheus/export.qtpl:22
	StreamExportCSVHeader(qw422016, fieldNames)
//line app/vmselect/prometheus/export.qtpl:22
	qt422016.ReleaseWriter(qw422016)
//line app/vmselect/prometheus/export.qtpl:22
}

//line app/vmselect/prometheus/export.qtpl:22
func ExportCSVHeader(fieldNames []string) string {
//line app/vmselect/prometheus/export.qtpl:22
	qb422016 := qt422016.AcquireByteBuffer()
//line app/vmselect/prometheus/export.qtpl:22
	WriteExportCSVHeader(qb422016, fieldNames)
//line app/vmselect/prometheus/export.qtpl:22
	qs422016 := string(qb422016.B)
//line app/vmselect/prometheus/export.qtpl:22
	qt422016.ReleaseByteBuffer(qb422016)
//line app/vmselect/prometheus/export.qtpl:22
	return qs422016
//line app/vmselect/prometheus/export.qtpl:22
}

//line app/vmselect/prometheus/export.qtpl:24
func StreamExportCSVLine(qw422016 *qt422016.Writer, xb *exportBlock, fieldNames []string) {
//line app/vmselect/prometheus/export.qtpl:25
	if len(xb.timestamps) == 0 || len(fieldNames) == 0 {
//line app/vmselect/prometheus/export.qtpl:25
		return
//line app/vmselect/prometheus/export.qtpl:25
	}
//line app/vmselect/prometheus/export.qtpl:26
	for i, timestamp := range xb.timestamps {
//line app/vmselect/prometheus/export.qtpl:27
		value := xb.values[i]

//line app/vmselect/prometheus/export.qtpl:28
		streamexportCSVField(qw422016, xb.mn, fieldNames[0], timestamp, value)
//line app/vmselect/prometheus/export.qtpl:29
		for _, fieldName := range fieldNames[1:] {
//line app/vmselect/prometheus/export.qtpl:29
			qw422016.N().S(`,`)
//line app/vmselect/prometheus/export.qtpl:31
			streamexportCSVField(qw422016, xb.mn, fieldName, timestamp, value)
//line app/vmselect/prometheus/export.qtpl:32
		}
//line app/vmselect/prometheus/export.qtpl:33
		qw422016.N().S(`
`)
//line app/vmselect/prometheus/export.qtpl:34
	}
//line app/vmselect/prometheus/export.qtpl:35
}

//line app/vmselect/prometheus/export.qtpl:35
func WriteExportCSVLine(qq422016 qtio422016.Writer, xb *exportBlock, fieldNames []string) {
//line app/vmselect/prometheus/export.qtpl:35
	qw422016 := qt422016.AcquireWriter(qq422016)
//line app/vmselect/prometheus/export.qtpl:35
	StreamExportCSVLine(qw422016, xb, fieldNames)
//line app/vmselect/prometheus/export.qtpl:35
	qt422016.ReleaseWriter(qw422016)
//line app/vmselect/prometheus/export.qtpl:35
}

//line app/vmselect/prometheus/export.qtpl:35
func ExportCSVLine(xb *exportBlock, fieldNames []string) string {
//line app/vmselect/prometheus/export.qtpl:35
	qb422016 := qt422016.AcquireByteBuffer()
//line app/vmselect/prometheus/export.qtpl:35
	WriteExportCSVLine(qb422016, xb, fieldNames)
//line app/vmselect/prometheus/export.qtpl:35
	qs422016 := string(qb422016.B)
//line app/vmselect/prometheus/export.qtpl:35
	qt422016.ReleaseByteBuffer(qb422016)
//line app/vmselect/prometheus/export.qtpl:35
	return qs422016
//line app/vmselect/prometheus/export.qtpl:35
}

//line app/vmselect/prometheus/export.qtpl:37
const rfc3339Milli = "2006-01-02T15:04:05.999Z07:00"

//line app/vmselect/prometheus/export.qtpl:38
func streamexportCSVField(qw422016 *qt422016.Writer, mn *storage.MetricName, fieldName string, timestamp int64, value float64) {
//line app/vmselect/prometheus/export.qtpl:39
	if fieldName == "__value__" {
//line app/vmselect/prometheus/export.qtpl:40
		qw422016.N().F(value)
//line app/vmselect/prometheus/export.qtpl:41
		return
//line app/vmselect/prometheus/export.qtpl:42
	}
//line app/vmselect/prometheus/export.qtpl:43
	if fieldName == "__timestamp__" {
//line app/vmselect/prometheus/export.qtpl:44
		qw422016.N().DL(timestamp)
//line app/vmselect/prometheus/export.qtpl:45
		return
//line app/vmselect/prometheus/export.qtpl:46
	}
//line app/vmselect/prometheus/export.qtpl:47
	if strings.HasPrefix(fieldName, "__timestamp__:") {
//line app/vmselect/prometheus/export.qtpl:48
		timeFormat := fieldName[len("__timestamp__:"):]

//line app/vmselect/prometheus/export.qtpl:49
		switch timeFormat {
//line app/vmselect/prometheus/export.qtpl:50
		case "unix_s":
//line app/vmselect/prometheus/export.qtpl:51
			qw422016.N().DL(timestamp / 1000)
//line app/vmselect/prometheus/export.qtpl:52
		case "unix_ms":
//line app/vmselect/prometheus/export.qtpl:53
			qw422016.N().DL(timestamp)
//line app/vmselect/prometheus/export.qtpl:54
		case "unix_ns":
//line app/vmselect/prometheus/export.qtpl:55
			qw422016.N().DL(timestamp * 1e6)
//line app/vmselect/prometheus/export.qtpl:56
		case "rfc3339":
//line app/vmselect/prometheus/export.qtpl:58
			bb := quicktemplate.AcquireByteBuffer()
			bb.B = time.Unix(timestamp/1000, (timestamp%1000)*1e6).AppendFormat(bb.B[:0], rfc3339Milli)

//line app/vmselect/prometheus/export.qtpl:61
			qw422016.N().Z(bb.B)
//line app/vmselect/prometheus/export.qtpl:63
			quicktemplate.ReleaseByteBuffer(bb)

//line app/vmselect/prometheus/export.qtpl:65
		default:
//line app/vmselect/prometheus/export.qtpl:66
			if strings.HasPrefix(timeFormat, "custom:") {
//line app/vmselect/prometheus/export.qtpl:68
				layout := timeFormat[len("custom:"):]
				bb := quicktemplate.AcquireByteBuffer()
				bb.B = time.Unix(timestamp/1000, (timestamp%1000)*1e6).AppendFormat(bb.B[:0], layout)

//line app/vmselect/prometheus/export.qtpl:72
				if bytes.ContainsAny(bb.B, `"`+",\n") {
//line app/vmselect/prometheus/export.qtpl:73
					qw422016.E().QZ(bb.B)
//line app/vmselect/prometheus/export.qtpl:74
				} else {
//line app/vmselect/prometheus/export.qtpl:75
					qw422016.N().Z(bb.B)
//line app/vmselect/prometheus/export.qtpl:76
				}
//line app/vmselect/prometheus/export.qtpl:78
				quicktemplate.ReleaseByteBuffer(bb)

//line app/vmselect/prometheus/export.qtpl:80
			} else {
//line app/vmselect/prometheus/export.qtpl:80
				qw422016.N().S(`Unsupported timeFormat=`)
//line app/vmselect/prometheus/export.qtpl:81
				qw422016.N().S(timeFormat)
//line app/vmselect/prometheus/export.qtpl:82
			}
//line app/vmselect/prometheus/export.qtpl:83
		}
//line app/vmselect/prometheus/export.qtpl:84
		return
//line app/vmselect/prometheus/export.qtpl:85
	}
//line app/vmselect/prometheus/export.qtpl:86
	v := mn.GetTagValue(fieldName)

//line app/vmselect/prometheus/export.qtpl:87
	if bytes.ContainsAny(v, `"`+",\n") {
//line app/vmselect/prometheus/export.qtpl:88
		qw422016.N().QZ(v)
//line app/vmselect/prometheus/export.qtpl:89
	} else {
//line app/vmselect/prometheus/export.qtpl:90
		qw422016.N().Z(v)
//line app/vmselect/prometheus/export.qtpl:91
	}
//line app/vmselect/prometheus/export.qtpl:92
}

//line app/vmselect/prometheus/export.qtpl:92
func writeexportCSVField(qq422016 qtio422016.Writer, mn *storage.MetricName, fieldName string, timestamp int64, value float64) {
//line app/vmselect/prometheus/export.qtpl:92
	qw422016 := qt422016.AcquireWriter(qq422016)
//line app/vmselect/prometheus/export.qtpl:92
	streamexportCSVField(qw422016, mn, fieldName, timestamp, value)
//line app/vmselect/prometheus/export.qtpl:92
	qt422016.ReleaseWriter(qw422016)
//line app/vmselect/prometheus/export.qtpl:92
}

//line app/vmselect/prometheus/export.qtpl:92
func exportCSVField(mn *storage.MetricName, fieldName string, timestamp int64, value float64) string {
//line app/vmselect/prometheus/export.qtpl:92
	qb422016 := qt422016.AcquireByteBuffer()
//line app/vmselect/prometheus/export.qtpl:92
	writeexportCSVField(qb422016, mn, fieldName, timestamp, value)
//line app/vmselect/prometheus/export.qtpl:92
	qs422016 := string(qb422016.B)
//line app/vmselect/prometheus/export.qtpl:92
	qt422016.ReleaseByteBuffer(qb422016)
//line app/vmselect/prometheus/export.qtpl:92
	return qs422016
//line app/vmselect/prometheus/export.qtpl:92
}

//line app/vmselect/prometheus/export.qtpl:94
func StreamExportPrometheusLine(qw422016 *qt422016.Writer, xb *exportBlock) {
//line app/vmselect/prometheus/export.qtpl:95
	if len(xb.timestamps) == 0 {
//line app/vmselect/prometheus/export.qtpl:95
		return
//line app/vmselect/prometheus/export.qtpl:95
	}
//line app/vmselect/prometheus/export.qtpl:96
	bb := quicktemplate.AcquireByteBuffer()

//line app/vmselect/prometheus/export.qtpl:97
	writeprometheusMetricName(bb, xb.mn)

//line app/vmselect/prometheus/export.qtpl:98
	for i, ts := range xb.timestamps {
//line app/vmselect/prometheus/export.qtpl:99
		qw422016.N().Z(bb.B)
//line app/vmselect/prometheus/export.qtpl:99
		qw422016.N().S(` `)
//line app/vmselect/prometheus/export.qtpl:100
		qw422016.N().F(xb.values[i])
//line app/vmselect/prometheus/export.qtpl:100
		qw422016.N().S(` `)
//line app/vmselect/prometheus/export.qtpl:101
		qw422016.N().DL(ts)
//line app/vmselect/prometheus/export.qtpl:101
		qw422016.N().S(`
`)
//line app/vmselect/prometheus/export.qtpl:102
	}
//line app/vmselect/prometheus/export.qtpl:103
	quicktemplate.ReleaseByteBuffer(bb)

//line app/vmselect/prometheus/export.qtpl:104
}

//line app/vmselect/prometheus/export.qtpl:104
func WriteExportPrometheusLine(qq422016 qtio422016.Writer, xb *exportBlock) {
//line app/vmselect/prometheus/export.qtpl:104
	qw422016 := qt422016.AcquireWriter(qq422016)
//line app/vmselect/prometheus/export.qtpl:104
	StreamExportPrometheusLine(qw422016, xb)
//line app/vmselect/prometheus/export.qtpl:104
	qt422016.ReleaseWriter(qw422016)
//line app/vmselect/prometheus/export.qtpl:104
}

//line app/vmselect/prometheus/export.qtpl:104
func ExportPrometheusLine(xb *exportBlock) string {
//line app/vmselect/prometheus/export.qtpl:104
	qb422016 := qt422016.AcquireByteBuffer()
//line app/vmselect/prometheus/export.qtpl:104
	WriteExportPrometheusLine(qb422016, xb)
//line app/vmselect/prometheus/export.qtpl:104
	qs422016 := string(qb422016.B)
//line app/vmselect/prometheus/export.qtpl:104
	qt422016.ReleaseByteBuffer(qb422016)
//line app/vmselect/prometheus/export.qtpl:104
	return qs422016
//line app/vmselect/prometheus/export.qtpl:104
}

//line app/vmselect/prometheus/export.qtpl:106
func StreamExportJSONLine(qw422016 *qt422016.Writer, xb *exportBlock) {
//line app/vmselect/prometheus/export.qtpl:107
	if len(xb.timestamps) == 0 {
//line app/vmselect/prometheus/export.qtpl:107
		return
//line app/vmselect/prometheus/export.qtpl:107
	}
//line app/vmselect/prometheus/export.qtpl:107
	qw422016.N().S(`{"metric":`)
//line app/vmselect/prometheus/export.qtpl:109
	streammetricNameObject(qw422016, xb.mn)
//line app/vmselect/prometheus/export.qtpl:109
	qw422016.N().S(`,"values":[`)
//line app/vmselect/prometheus/export.qtpl:111
	if len(xb.values) > 0 {
//line app/vmselect/prometheus/export.qtpl:112
		values := xb.values

//line app/vmselect/prometheus/export.qtpl:113
		streamconvertValueToSpecialJSON(qw422016, values[0])
//line app/vmselect/prometheus/export.qtpl:114
		values = values[1:]

//line app/vmselect/prometheus/export.qtpl:115
		for _, v := range values {
//line app/vmselect/prometheus/export.qtpl:115
			qw422016.N().S(`,`)
//line app/vmselect/prometheus/export.qtpl:116
			streamconvertValueToSpecialJSON(qw422016, v)
//line app/vmselect/prometheus/export.qtpl:117
		}
//line app/vmselect/prometheus/export.qtpl:118
	}
//line app/vmselect/prometheus/export.qtpl:118
	qw422016.N().S(`],"timestamps":[`)
//line app/vmselect/prometheus/export.qtpl:121
	if len(xb.timestamps) > 0 {
//line app/vmselect/prometheus/export.qtpl:122
		timestamps := xb.timestamps

//line app/vmselect/prometheus/export.qtpl:123
		qw422016.N().DL(timestamps[0])
//line app/vmselect/prometheus/export.qtpl:124
		timestamps = timestamps[1:]

//line app/vmselect/prometheus/export.qtpl:125
		for _, ts := range timestamps {
//line app/vmselect/prometheus/export.qtpl:125
			qw422016.N().S(`,`)
//line app/vmselect/prometheus/export.qtpl:126
			qw422016.N().DL(ts)
//line app/vmselect/prometheus/export.qtpl:127
		}
//line app/vmselect/prometheus/export.qtpl:128
	}
//line app/vmselect/prometheus/export.qtpl:128
	qw422016.N().S(`]}`)
//line app/vmselect/prometheus/export.qtpl:130
	qw422016.N().S(`
`)
//line app/vmselect/prometheus/export.qtpl:131
}

//line app/vmselect/prometheus/export.qtpl:131
func WriteExportJSONLine(qq422016 qtio422016.Writer, xb *exportBlock) {
//line app/vmselect/prometheus/export.qtpl:131
	qw422016 := qt422016.AcquireWriter(qq422016)
//line app/vmselect/prometheus/export.qtpl:131
	StreamExportJSONLine(qw422016, xb)
//line app/vmselect/prometheus/export.qtpl:131
	qt422016.ReleaseWriter(qw422016)
//line app/vmselect/prometheus/export.qtpl:131
}

//line app/vmselect/prometheus/export.qtpl:131
func ExportJSONLine(xb *exportBlock) string {
//line app/vmselect/prometheus/export.qtpl:131
	qb422016 := qt422016.AcquireByteBuffer()
//line app/vmselect/prometheus/export.qtpl:131
	WriteExportJSONLine(qb422016, xb)
//line app/vmselect/prometheus/export.qtpl:131
	qs422016 := string(qb422016.B)
//line app/vmselect/prometheus/export.qtpl:131
	qt422016.ReleaseByteBuffer(qb422016)
//line app/vmselect/prometheus/export.qtpl:131
	return qs422016
//line app/vmselect/prometheus/export.qtpl:131
}

//line app/vmselect/prometheus/export.qtpl:133
func StreamExportPromAPILine(qw422016 *qt422016.Writer, xb *exportBlock) {
//line app/vmselect/prometheus/export.qtpl:133
	qw422016.N().S(`{"metric":`)
//line app/vmselect/prometheus/export.qtpl:135
	streammetricNameObject(qw422016, xb.mn)
//line app/vmselect/prometheus/export.qtpl:135
	qw422016.N().S(`,"values":`)
//line app/vmselect/prometheus/export.qtpl:136
	streamvaluesWithTimestamps(qw422016, xb.values, xb.timestamps)
//line app/vmselect/prometheus/export.qtpl:136
	qw422016.N().S(`}`)
//line app/vmselect/prometheus/export.qtpl:138
}

//line app/vmselect/prometheus/export.qtpl:138
func WriteExportPromAPILine(qq422016 qtio422016.Writer, xb *exportBlock) {
//line app/vmselect/prometheus/export.qtpl:138
	qw422016 := qt422016.AcquireWriter(qq422016)
//line app/vmselect/prometheus/export.qtpl:138
	StreamExportPromAPILine(qw422016, xb)
//line app/vmselect/prometheus/export.qtpl:138
	qt422016.ReleaseWriter(qw422016)
//line app/vmselect/prometheus/export.qtpl:138
}

//line app/vmselect/prometheus/export.qtpl:138
func ExportPromAPILine(xb *exportBlock) string {
//line app/vmselect/prometheus/export.qtpl:138
	qb422016 := qt422016.AcquireByteBuffer()
//line app/vmselect/prometheus/export.qtpl:138
	WriteExportPromAPILine(qb422016, xb)
//line app/vmselect/prometheus/export.qtpl:138
	qs422016 := string(qb422016.B)
//line app/vmselect/prometheus/export.qtpl:138
	qt422016.ReleaseByteBuffer(qb422016)
//line app/vmselect/prometheus/export.qtpl:138
	return qs422016
//line app/vmselect/prometheus/export.qtpl:138
}

//line app/vmselect/prometheus/export.qtpl:140
func StreamExportPromAPIHeader(qw422016 *qt422016.Writer) {
//line app/vmselect/prometheus/export.qtpl:140
	qw422016.N().S(`{"status":"success","data":{"resultType":"matrix","result":[`)
//line app/vmselect/prometheus/export.qtpl:146
}

//line app/vmselect/prometheus/export.qtpl:146
func WriteExportPromAPIHeader(qq422016 qtio422016.Writer) {
//line app/vmselect/prometheus/export.qtpl:146
	qw422016 := qt422016.AcquireWriter(qq422016)
//line app/vmselect/prometheus/export.qtpl:146
	StreamExportPromAPIHeader(qw422016)
//line app/vmselect/prometheus/export.qtpl:146
	qt422016.ReleaseWriter(qw422016)
//line app/vmselect/prometheus/export.qtpl:146
}

//line app/vmselect/prometheus/export.qtpl:146
func ExportPromAPIHeader() string {
//line app/vmselect/prometheus/export.qtpl:146
	qb422016 := qt422016.AcquireByteBuffer()
//line app/vmselect/prometheus/export.qtpl:146
	WriteExportPromAPIHeader(qb422016)
//line app/vmselect/prometheus/export.qtpl:146
	qs422016 := string(qb422016.B)
//line app/vmselect/prometheus/export.qtpl:146
	qt422016.ReleaseByteBuffer(qb422016)
//line app/vmselect/prometheus/export.qtpl:146
	return qs422016
//line app/vmselect/prometheus/export.qtpl:146
}

//line app/vmselect/prometheus/export.qtpl:148
func StreamExportPromAPIFooter(qw422016 *qt422016.Writer, qt *querytracer.Tracer) {
//line app/vmselect/prometheus/export.qtpl:148
	qw422016.N().S(`]}`)
//line app/vmselect/prometheus/export.qtpl:152
	qt.Donef("export format=promapi")

//line app/vmselect/prometheus/export.qtpl:154
	streamdumpQueryTrace(qw422016, qt)
//line app/vmselect/prometheus/export.qtpl:154
	qw422016.N().S(`}`)
//line app/vmselect/prometheus/export.qtpl:156
}

//line app/vmselect/prometheus/export.qtpl:156
func WriteExportPromAPIFooter(qq422016 qtio422016.Writer, qt *querytracer.Tracer) {
//line app/vmselect/prometheus/export.qtpl:156
	qw422016 := qt422016.AcquireWriter(qq422016)
//line app/vmselect/prometheus/export.qtpl:156
	StreamExportPromAPIFooter(qw422016, qt)
//line app/vmselect/prometheus/export.qtpl:156
	qt422016.ReleaseWriter(qw422016)
//line app/vmselect/prometheus/export.qtpl:156
}

//line app/vmselect/prometheus/export.qtpl:156
func ExportPromAPIFooter(qt *querytracer.Tracer) string {
//line app/vmselect/prometheus/export.qtpl:156
	qb422016 := qt422016.AcquireByteBuffer()
//line app/vmselect/prometheus/export.qtpl:156
	WriteExportPromAPIFooter(qb422016, qt)
//line app/vmselect/prometheus/export.qtpl:156
	qs422016 := string(qb422016.B)
//line app/vmselect/prometheus/export.qtpl:156
	qt422016.ReleaseByteBuffer(qb422016)
//line app/vmselect/prometheus/export.qtpl:156
	return qs422016
//line app/vmselect/prometheus/export.qtpl:156
}

//line app/vmselect/prometheus/export.qtpl:158
func streamprometheusMetricName(qw422016 *qt422016.Writer, mn *storage.MetricName) {
//line app/vmselect/prometheus/export.qtpl:159
	qw422016.N().Z(mn.MetricGroup)
//line app/vmselect/prometheus/export.qtpl:160
	if len(mn.Tags) > 0 {
//line app/vmselect/prometheus/export.qtpl:160
		qw422016.N().S(`{`)
//line app/vmselect/prometheus/export.qtpl:162
		tags := mn.Tags

//line app/vmselect/prometheus/export.qtpl:163
		qw422016.N().Z(tags[0].Key)
//line app/vmselect/prometheus/export.qtpl:163
		qw422016.N().S(`=`)
//line app/vmselect/prometheus/export.qtpl:163
		streamescapePrometheusLabel(qw422016, tags[0].Value)
//line app/vmselect/prometheus/export.qtpl:164
		tags = tags[1:]

//line app/vmselect/prometheus/export.qtpl:165
		for i := range tags {
//line app/vmselect/prometheus/export.qtpl:166
			tag := &tags[i]

//line app/vmselect/prometheus/export.qtpl:166
			qw422016.N().S(`,`)
//line app/vmselect/prometheus/export.qtpl:167
			qw422016.N().Z(tag.Key)
//line app/vmselect/prometheus/export.qtpl:167
			qw422016.N().S(`=`)
//line app/vmselect/prometheus/export.qtpl:167
			streamescapePrometheusLabel(qw422016, tag.Value)
//line app/vmselect/prometheus/export.qtpl:168
		}
//line app/vmselect/prometheus/export.qtpl:168
		qw422016.N().S(`}`)
//line app/vmselect/prometheus/export.qtpl:170
	}
//line app/vmselect/prometheus/export.qtpl:171
}

//line app/vmselect/prometheus/export.qtpl:171
func writeprometheusMetricName(qq422016 qtio422016.Writer, mn *storage.MetricName) {
//line app/vmselect/prometheus/export.qtpl:171
	qw422016 := qt422016.AcquireWriter(qq422016)
//line app/vmselect/prometheus/export.qtpl:171
	streamprometheusMetricName(qw422016, mn)
//line app/vmselect/prometheus/export.qtpl:171
	qt422016.ReleaseWriter(qw422016)
//line app/vmselect/prometheus/export.qtpl:171
}

//line app/vmselect/prometheus/export.qtpl:171
func prometheusMetricName(mn *storage.MetricName) string {
//line app/vmselect/prometheus/export.qtpl:171
	qb422016 := qt422016.AcquireByteBuffer()
//line app/vmselect/prometheus/export.qtpl:171
	writeprometheusMetricName(qb422016, mn)
//line app/vmselect/prometheus/export.qtpl:171
	qs422016 := string(qb422016.B)
//line app/vmselect/prometheus/export.qtpl:171
	qt422016.ReleaseByteBuffer(qb422016)
//line app/vmselect/prometheus/export.qtpl:171
	return qs422016
//line app/vmselect/prometheus/export.qtpl:171
}

//line app/vmselect/prometheus/export.qtpl:173
func streamconvertValueToSpecialJSON(qw422016 *qt422016.Writer, v float64) {
//line app/vmselect/prometheus/export.qtpl:174
	if math.IsNaN(v) {
//line app/vmselect/prometheus/export.qtpl:174
		qw422016.N().S(`null`)
//line app/vmselect/prometheus/export.qtpl:176
	} else if math.IsInf(v, 0) {
//line app/vmselect/prometheus/export.qtpl:177
		if v > 0 {
//line app/vmselect/prometheus/export.qtpl:177
			qw422016.N().S(`"Infinity"`)
//line app/vmselect/prometheus/export.qtpl:179
		} else {
//line app/vmselect/prometheus/export.qtpl:179
			qw422016.N().S(`"-Infinity"`)
//line app/vmselect/prometheus/export.qtpl:181
		}
//line app/vmselect/prometheus/export.qtpl:182
	} else {
//line app/vmselect/prometheus/export.qtpl:183
		qw422016.N().F(v)
//line app/vmselect/prometheus/export.qtpl:184
	}
//line app/vmselect/prometheus/export.qtpl:185
}

//line app/vmselect/prometheus/export.qtpl:185
func writeconvertValueToSpecialJSON(qq422016 qtio422016.Writer, v float64) {
//line app/vmselect/prometheus/export.qtpl:185
	qw422016 := qt422016.AcquireWriter(qq422016)
//line app/vmselect/prometheus/export.qtpl:185
	streamconvertValueToSpecialJSON(qw422016, v)
//line app/vmselect/prometheus/export.qtpl:185
	qt422016.ReleaseWriter(qw422016)
//line app/vmselect/prometheus/export.qtpl:185
}

//line app/vmselect/prometheus/export.qtpl:185
func convertValueToSpecialJSON(v float64) string {
//line app/vmselect/prometheus/export.qtpl:185
	qb422016 := qt422016.AcquireByteBuffer()
//line app/vmselect/prometheus/export.qtpl:185
	writeconvertValueToSpecialJSON(qb422016, v)
//line app/vmselect/prometheus/export.qtpl:185
	qs422016 := string(qb422016.B)
//line app/vmselect/prometheus/export.qtpl:185
	qt422016.ReleaseByteBuffer(qb422016)
//line app/vmselect/prometheus/export.qtpl:185
	return qs422016
//line app/vmselect/prometheus/export.qtpl:185
}

//line app/vmselect/prometheus/export.qtpl:187
func streamescapePrometheusLabel(qw422016 *qt422016.Writer, b []byte) {
//line app/vmselect/prometheus/export.qtpl:187
	qw422016.N().S(`"`)
//line app/vmselect/prometheus/export.qtpl:189
	for len(b) > 0 {
//line app/vmselect/prometheus/export.qtpl:190
		n := bytes.IndexAny(b, "\\\n\"")

//line app/vmselect/prometheus/export.qtpl:191
		if n < 0 {
//line app/vmselect/prometheus/export.qtpl:192
			qw422016.N().Z(b)
//line app/vmselect/prometheus/export.qtpl:193
			break
//line app/vmselect/prometheus/export.qtpl:194
		}
//line app/vmselect/prometheus/export.qtpl:195
		qw422016.N().Z(b[:n])
//line app/vmselect/prometheus/export.qtpl:196
		switch b[n] {
//line app/vmselect/prometheus/export.qtpl:197
		case '\\':
//line app/vmselect/prometheus/export.qtpl:197
			qw422016.N().S(`\\`)
//line app/vmselect/prometheus/export.qtpl:199
		case '\n':
//line app/vmselect/prometheus/export.qtpl:199
			qw422016.N().S(`\n`)
//line app/vmselect/prometheus/export.qtpl:201
		case '"':
//line app/vmselect/prometheus/export.qtpl:201
			qw422016.N().S(`\"`)
//line app/vmselect/prometheus/export.qtpl:203
		}
//line app/vmselect/prometheus/export.qtpl:204
		b = b[n+1:]

//line app/vmselect/prometheus/export.qtpl:205
	}
//line app/vmselect/prometheus/export.qtpl:205
	qw422016.N().S(`"`)
//line app/vmselect/prometheus/export.qtpl:207
}

//line app/vmselect/prometheus/export.qtpl:207
func writeescapePrometheusLabel(qq422016 qtio422016.Writer, b []byte) {
//line app/vmselect/prometheus/export.qtpl:207
	qw422016 := qt422016.AcquireWriter(qq422016)
//line app/vmselect/prometheus/export.qtpl:207
	streamescapePrometheusLabel(qw422016, b)
//line app/vmselect/prometheus/export.qtpl:207
	qt422016.ReleaseWriter(qw422016)
//line app/vmselect/prometheus/export.qtpl:207
}

//line app/vmselect/prometheus/export.qtpl:207
func escapePrometheusLabel(b []byte) string {
//line app/vmselect/prometheus/export.qtpl:207
	qb422016 := qt422016.AcquireByteBuffer()
//line app/vmselect/prometheus/export.qtpl:207
	writeescapePrometheusLabel(qb422016, b)
//line app/vmselect/prometheus/export.qtpl:207
	qs422016 := string(qb422016.B)
//line app/vmselect/prometheus/export.qtpl:207
	qt422016.ReleaseByteBuffer(qb422016)
//line app/vmselect/prometheus/export.qtpl:207
	return qs422016
//line app/vmselect/prometheus/export.qtpl:207
}
