func (p *Parser) Metric(l *labels.Labels) string {
	s := string(p.l.b[p.l.mstart:p.l.mend])
	*l = append(*l, labels.Label{
		Name:  labels.MetricName,
		Value: s[:p.l.offsets[0]-p.l.mstart],
	})
	for i := 1; i < len(p.l.offsets); i += 4 {
		a := p.l.offsets[i] - p.l.mstart
		b := p.l.offsets[i+1] - p.l.mstart
		c := p.l.offsets[i+2] - p.l.mstart
		d := p.l.offsets[i+3] - p.l.mstart
		if strings.IndexByte(s[c:d], byte('\\')) >= 0 {
			*l = append(*l, labels.Label{Name: s[a:b], Value: replacer.Replace(s[c:d])})
			continue
		}
		*l = append(*l, labels.Label{Name: s[a:b], Value: s[c:d]})
	}
	sort.Sort((*l)[1:])
	return s
}
Metric writes the labels of the current sample into the passed labels.
It returns the string from which the metric was parsed.
package textparse
import (
	"errors"
	"io"
	"sort"
	"strings"
	"unsafe"
	"github.com/prometheus/prometheus/pkg/labels"
)
type lexer struct {
	b      []byte
	i      int
	vstart int
	tstart int
	err          error
	val          float64
	ts           *int64
	offsets      []int
	mstart, mend int
	nextMstart   int
	state int
}
const eof = 0
func (l *lexer) next() byte {
	l.i++
	if l.i >= len(l.b) {
		l.err = io.EOF
		return eof
	}
	c := l.b[l.i]
	if c == eof && (l.state == lstateLValueIn || l.state == lstateLValue) {
		return l.next()
	}
	return c
}
func (l *lexer) Error(es string) {
	l.err = errors.New(es)
}
type Parser struct {
	l   *lexer
	err error
	val float64
}
func New(b []byte) *Parser {
	return &Parser{l: &lexer{b: b}}
}
func (p *Parser) Next() bool {
	switch p.l.Lex() {
	case -1, eof:
		return false
	case 1:
		return true
	}
	panic("unexpected")
}
func (p *Parser) At() ([]byte, *int64, float64) {
	return p.l.b[p.l.mstart:p.l.mend], p.l.ts, p.l.val
}
func (p *Parser) Err() error {
	if p.err != nil {
		return p.err
	}
	if p.l.err == io.EOF {
		return nil
	}
	return p.l.err
}