mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
rollback go to 1.20.4
Signed-off-by: f41gh7 <nik@victoriametrics.com>
This commit is contained in:
parent
115a76d28c
commit
ce7a156c3b
8 changed files with 43 additions and 18 deletions
|
@ -6,7 +6,8 @@ ROOT_IMAGE ?= alpine:3.20.2
|
|||
ROOT_IMAGE_SCRATCH ?= scratch
|
||||
CERTS_IMAGE := alpine:3.20.2
|
||||
|
||||
GO_BUILDER_IMAGE := golang:1.22.5-alpine
|
||||
GO_BUILDER_IMAGE := golang:1.20.4-alpine
|
||||
|
||||
BUILDER_IMAGE := local/builder:2.0.0-$(shell echo $(GO_BUILDER_IMAGE) | tr :/ __)-1
|
||||
BASE_IMAGE := local/base:1.1.4-$(shell echo $(ROOT_IMAGE) | tr :/ __)-$(shell echo $(CERTS_IMAGE) | tr :/ __)
|
||||
DOCKER ?= docker
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,6 +1,6 @@
|
|||
module github.com/VictoriaMetrics/VictoriaMetrics
|
||||
|
||||
go 1.22.5
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
cloud.google.com/go/storage v1.43.0
|
||||
|
|
|
@ -26,7 +26,9 @@ func (wr *WriteRequest) Reset() {
|
|||
|
||||
// ResetTimeSeries clears all the GC references from tss and returns an empty tss ready for further use.
|
||||
func ResetTimeSeries(tss []TimeSeries) []TimeSeries {
|
||||
clear(tss)
|
||||
for i := range tss {
|
||||
tss[i] = TimeSeries{}
|
||||
}
|
||||
return tss[:0]
|
||||
}
|
||||
|
||||
|
|
|
@ -589,7 +589,9 @@ func GetLabelByName(labels []prompbmarshal.Label, name string) *prompbmarshal.La
|
|||
//
|
||||
// This should help GC cleaning up label.Name and label.Value strings.
|
||||
func CleanLabels(labels []prompbmarshal.Label) {
|
||||
clear(labels)
|
||||
for i := range labels {
|
||||
labels[i] = prompbmarshal.Label{}
|
||||
}
|
||||
}
|
||||
|
||||
// LabelsToString returns Prometheus string representation for the given labels.
|
||||
|
|
|
@ -115,9 +115,15 @@ func (x *Labels) String() string {
|
|||
return bytesutil.ToUnsafeString(b)
|
||||
}
|
||||
|
||||
func cleanLabels(labels []prompbmarshal.Label) {
|
||||
for i := range labels {
|
||||
labels[i] = prompbmarshal.Label{}
|
||||
}
|
||||
}
|
||||
|
||||
// Reset resets x.
|
||||
func (x *Labels) Reset() {
|
||||
clear(x.Labels)
|
||||
cleanLabels(x.Labels)
|
||||
x.Labels = x.Labels[:0]
|
||||
}
|
||||
|
||||
|
@ -245,7 +251,7 @@ func (x *Labels) RemoveDuplicates() {
|
|||
prevName = label.Name
|
||||
}
|
||||
}
|
||||
clear(labels[len(tmp):])
|
||||
cleanLabels(labels[len(tmp):])
|
||||
x.Labels = tmp
|
||||
}
|
||||
|
||||
|
@ -261,7 +267,7 @@ func (x *Labels) RemoveMetaLabels() {
|
|||
}
|
||||
dst = append(dst, label)
|
||||
}
|
||||
clear(src[len(dst):])
|
||||
cleanLabels(src[len(dst):])
|
||||
x.Labels = dst
|
||||
}
|
||||
|
||||
|
@ -276,7 +282,7 @@ func (x *Labels) RemoveLabelsWithDoubleUnderscorePrefix() {
|
|||
}
|
||||
dst = append(dst, label)
|
||||
}
|
||||
clear(src[len(dst):])
|
||||
cleanLabels(src[len(dst):])
|
||||
x.Labels = dst
|
||||
}
|
||||
|
||||
|
|
|
@ -218,6 +218,8 @@ func (lm *labelsMap) moveMutableToReadOnlyLocked(pReadOnly *[]*prompbmarshal.Lab
|
|||
labels = append(labels, pLabel)
|
||||
}
|
||||
}
|
||||
clear(lm.mutable)
|
||||
for k := range lm.mutable {
|
||||
delete(lm.mutable, k)
|
||||
}
|
||||
lm.readOnly.Store(&labels)
|
||||
}
|
||||
|
|
|
@ -2,17 +2,14 @@ package stream
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promrelabel"
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/protoparser/opentelemetry/pb"
|
||||
)
|
||||
|
||||
var (
|
||||
usePrometheusNaming = flag.Bool("opentelemetry.usePrometheusNaming", false, "Whether to convert metric names and labels into Prometheus-compatible format for the metrics ingested "+
|
||||
var usePrometheusNaming = flag.Bool("opentelemetry.usePrometheusNaming", false, "Whether to convert metric names and labels into Prometheus-compatible format for the metrics ingested "+
|
||||
"via OpenTelemetry protocol; see https://docs.victoriametrics.com/#sending-data-via-opentelemetry")
|
||||
)
|
||||
|
||||
// unitMap is obtained from https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/b8655058501bed61a06bb660869051491f46840b/pkg/translator/prometheus/normalize_name.go#L19
|
||||
var unitMap = map[string]string{
|
||||
|
@ -91,6 +88,15 @@ func sanitizeMetricName(m *pb.Metric) string {
|
|||
return sanitizePrometheusMetricName(m)
|
||||
}
|
||||
|
||||
func contains(src []string, value string) bool {
|
||||
for _, v := range src {
|
||||
if v == value {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func sanitizePrometheusMetricName(m *pb.Metric) string {
|
||||
nameTokens := promrelabel.SplitMetricNameToTokens(m.Name)
|
||||
|
||||
|
@ -101,7 +107,7 @@ func sanitizePrometheusMetricName(m *pb.Metric) string {
|
|||
if u, ok := unitMap[mainUnit]; ok {
|
||||
mainUnit = u
|
||||
}
|
||||
if mainUnit != "" && !slices.Contains(nameTokens, mainUnit) {
|
||||
if mainUnit != "" && !contains(nameTokens, mainUnit) {
|
||||
nameTokens = append(nameTokens, mainUnit)
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +118,7 @@ func sanitizePrometheusMetricName(m *pb.Metric) string {
|
|||
if u, ok := perUnitMap[perUnit]; ok {
|
||||
perUnit = u
|
||||
}
|
||||
if perUnit != "" && !slices.Contains(nameTokens, perUnit) {
|
||||
if perUnit != "" && !contains(nameTokens, perUnit) {
|
||||
nameTokens = append(nameTokens, "per", perUnit)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -238,7 +238,11 @@ type writeContext struct {
|
|||
func (wr *writeContext) reset() {
|
||||
wr.bb.Reset()
|
||||
|
||||
clear(wr.tss)
|
||||
for i := range wr.tss {
|
||||
ts := &wr.tss[i]
|
||||
ts.Labels = nil
|
||||
ts.Samples = nil
|
||||
}
|
||||
wr.tss = wr.tss[:0]
|
||||
|
||||
wr.baseLabels = resetLabels(wr.baseLabels)
|
||||
|
@ -249,7 +253,9 @@ func (wr *writeContext) reset() {
|
|||
}
|
||||
|
||||
func resetLabels(labels []prompbmarshal.Label) []prompbmarshal.Label {
|
||||
clear(labels)
|
||||
for i := range labels {
|
||||
labels[i] = prompbmarshal.Label{}
|
||||
}
|
||||
return labels[:0]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue