rollback go to 1.20.4

Signed-off-by: f41gh7 <nik@victoriametrics.com>
This commit is contained in:
f41gh7 2024-08-29 22:21:51 +02:00
parent 115a76d28c
commit ce7a156c3b
No known key found for this signature in database
GPG key ID: 4558311CF775EC72
8 changed files with 43 additions and 18 deletions

View file

@ -6,7 +6,8 @@ ROOT_IMAGE ?= alpine:3.20.2
ROOT_IMAGE_SCRATCH ?= scratch ROOT_IMAGE_SCRATCH ?= scratch
CERTS_IMAGE := alpine:3.20.2 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 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 :/ __) BASE_IMAGE := local/base:1.1.4-$(shell echo $(ROOT_IMAGE) | tr :/ __)-$(shell echo $(CERTS_IMAGE) | tr :/ __)
DOCKER ?= docker DOCKER ?= docker

2
go.mod
View file

@ -1,6 +1,6 @@
module github.com/VictoriaMetrics/VictoriaMetrics module github.com/VictoriaMetrics/VictoriaMetrics
go 1.22.5 go 1.20
require ( require (
cloud.google.com/go/storage v1.43.0 cloud.google.com/go/storage v1.43.0

View file

@ -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. // ResetTimeSeries clears all the GC references from tss and returns an empty tss ready for further use.
func ResetTimeSeries(tss []TimeSeries) []TimeSeries { func ResetTimeSeries(tss []TimeSeries) []TimeSeries {
clear(tss) for i := range tss {
tss[i] = TimeSeries{}
}
return tss[:0] return tss[:0]
} }

View file

@ -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. // This should help GC cleaning up label.Name and label.Value strings.
func CleanLabels(labels []prompbmarshal.Label) { func CleanLabels(labels []prompbmarshal.Label) {
clear(labels) for i := range labels {
labels[i] = prompbmarshal.Label{}
}
} }
// LabelsToString returns Prometheus string representation for the given labels. // LabelsToString returns Prometheus string representation for the given labels.

View file

@ -115,9 +115,15 @@ func (x *Labels) String() string {
return bytesutil.ToUnsafeString(b) return bytesutil.ToUnsafeString(b)
} }
func cleanLabels(labels []prompbmarshal.Label) {
for i := range labels {
labels[i] = prompbmarshal.Label{}
}
}
// Reset resets x. // Reset resets x.
func (x *Labels) Reset() { func (x *Labels) Reset() {
clear(x.Labels) cleanLabels(x.Labels)
x.Labels = x.Labels[:0] x.Labels = x.Labels[:0]
} }
@ -245,7 +251,7 @@ func (x *Labels) RemoveDuplicates() {
prevName = label.Name prevName = label.Name
} }
} }
clear(labels[len(tmp):]) cleanLabels(labels[len(tmp):])
x.Labels = tmp x.Labels = tmp
} }
@ -261,7 +267,7 @@ func (x *Labels) RemoveMetaLabels() {
} }
dst = append(dst, label) dst = append(dst, label)
} }
clear(src[len(dst):]) cleanLabels(src[len(dst):])
x.Labels = dst x.Labels = dst
} }
@ -276,7 +282,7 @@ func (x *Labels) RemoveLabelsWithDoubleUnderscorePrefix() {
} }
dst = append(dst, label) dst = append(dst, label)
} }
clear(src[len(dst):]) cleanLabels(src[len(dst):])
x.Labels = dst x.Labels = dst
} }

View file

@ -218,6 +218,8 @@ func (lm *labelsMap) moveMutableToReadOnlyLocked(pReadOnly *[]*prompbmarshal.Lab
labels = append(labels, pLabel) labels = append(labels, pLabel)
} }
} }
clear(lm.mutable) for k := range lm.mutable {
delete(lm.mutable, k)
}
lm.readOnly.Store(&labels) lm.readOnly.Store(&labels)
} }

View file

@ -2,17 +2,14 @@ package stream
import ( import (
"flag" "flag"
"slices"
"strings" "strings"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promrelabel" "github.com/VictoriaMetrics/VictoriaMetrics/lib/promrelabel"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/protoparser/opentelemetry/pb" "github.com/VictoriaMetrics/VictoriaMetrics/lib/protoparser/opentelemetry/pb"
) )
var ( var usePrometheusNaming = flag.Bool("opentelemetry.usePrometheusNaming", false, "Whether to convert metric names and labels into Prometheus-compatible format for the metrics ingested "+
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")
"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 // 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{ var unitMap = map[string]string{
@ -91,6 +88,15 @@ func sanitizeMetricName(m *pb.Metric) string {
return sanitizePrometheusMetricName(m) 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 { func sanitizePrometheusMetricName(m *pb.Metric) string {
nameTokens := promrelabel.SplitMetricNameToTokens(m.Name) nameTokens := promrelabel.SplitMetricNameToTokens(m.Name)
@ -101,7 +107,7 @@ func sanitizePrometheusMetricName(m *pb.Metric) string {
if u, ok := unitMap[mainUnit]; ok { if u, ok := unitMap[mainUnit]; ok {
mainUnit = u mainUnit = u
} }
if mainUnit != "" && !slices.Contains(nameTokens, mainUnit) { if mainUnit != "" && !contains(nameTokens, mainUnit) {
nameTokens = append(nameTokens, mainUnit) nameTokens = append(nameTokens, mainUnit)
} }
} }
@ -112,7 +118,7 @@ func sanitizePrometheusMetricName(m *pb.Metric) string {
if u, ok := perUnitMap[perUnit]; ok { if u, ok := perUnitMap[perUnit]; ok {
perUnit = u perUnit = u
} }
if perUnit != "" && !slices.Contains(nameTokens, perUnit) { if perUnit != "" && !contains(nameTokens, perUnit) {
nameTokens = append(nameTokens, "per", perUnit) nameTokens = append(nameTokens, "per", perUnit)
} }
} }

View file

@ -238,7 +238,11 @@ type writeContext struct {
func (wr *writeContext) reset() { func (wr *writeContext) reset() {
wr.bb.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.tss = wr.tss[:0]
wr.baseLabels = resetLabels(wr.baseLabels) wr.baseLabels = resetLabels(wr.baseLabels)
@ -249,7 +253,9 @@ func (wr *writeContext) reset() {
} }
func resetLabels(labels []prompbmarshal.Label) []prompbmarshal.Label { func resetLabels(labels []prompbmarshal.Label) []prompbmarshal.Label {
clear(labels) for i := range labels {
labels[i] = prompbmarshal.Label{}
}
return labels[:0] return labels[:0]
} }