mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-21 15:45:01 +00:00

`MustParsePromMetrics` imports `lib/protoparser/prometheus`, and this package exposes the following metrics: ``` vm_protoparser_rows_read_total{type="promscrape"} vm_rows_invalid_total{type="prometheus"} ``` It means every package that uses `lib/prompbmarshal` will start exposing these metrics. For example, vlogs imports `lib/protoparser/common` which uses `lib/prompbmarshal.Label`. And only because of this vlogs starts exposing unrelated prometheus metrics on /metrics page. Moving `MustParsePromMetrics` to `lib/protoparser/prometheus` seems like the leas intrusive change. ----------- Depends on another change https://github.com/VictoriaMetrics/VictoriaMetrics/pull/8403 Signed-off-by: hagen1778 <roman@victoriametrics.com>
30 lines
784 B
Go
30 lines
784 B
Go
package prompbmarshal
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/slicesutil"
|
|
)
|
|
|
|
// MarshalProtobuf marshals wr to dst and returns the result.
|
|
func (wr *WriteRequest) MarshalProtobuf(dst []byte) []byte {
|
|
size := wr.Size()
|
|
dstLen := len(dst)
|
|
dst = slicesutil.SetLength(dst, dstLen+size)
|
|
n, err := wr.MarshalToSizedBuffer(dst[dstLen:])
|
|
if err != nil {
|
|
panic(fmt.Errorf("BUG: unexpected error when marshaling WriteRequest: %w", err))
|
|
}
|
|
return dst[:dstLen+n]
|
|
}
|
|
|
|
// Reset resets wr.
|
|
func (wr *WriteRequest) Reset() {
|
|
wr.Timeseries = ResetTimeSeries(wr.Timeseries)
|
|
}
|
|
|
|
// ResetTimeSeries clears all the GC references from tss and returns an empty tss ready for further use.
|
|
func ResetTimeSeries(tss []TimeSeries) []TimeSeries {
|
|
clear(tss)
|
|
return tss[:0]
|
|
}
|