Update golangci-lint (#17478)
Some checks failed
buf.build / lint and publish (push) Has been cancelled
CI / Go tests (push) Has been cancelled
CI / More Go tests (push) Has been cancelled
CI / Go tests with previous Go version (push) Has been cancelled
CI / UI tests (push) Has been cancelled
CI / Go tests on Windows (push) Has been cancelled
CI / Mixins tests (push) Has been cancelled
CI / Build Prometheus for common architectures (0) (push) Has been cancelled
CI / Build Prometheus for common architectures (1) (push) Has been cancelled
CI / Build Prometheus for common architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (0) (push) Has been cancelled
CI / Build Prometheus for all architectures (1) (push) Has been cancelled
CI / Build Prometheus for all architectures (10) (push) Has been cancelled
CI / Build Prometheus for all architectures (11) (push) Has been cancelled
CI / Build Prometheus for all architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (3) (push) Has been cancelled
CI / Build Prometheus for all architectures (4) (push) Has been cancelled
CI / Build Prometheus for all architectures (5) (push) Has been cancelled
CI / Build Prometheus for all architectures (6) (push) Has been cancelled
CI / Build Prometheus for all architectures (7) (push) Has been cancelled
CI / Build Prometheus for all architectures (8) (push) Has been cancelled
CI / Build Prometheus for all architectures (9) (push) Has been cancelled
CI / Report status of build Prometheus for all architectures (push) Has been cancelled
CI / Check generated parser (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
CI / fuzzing (push) Has been cancelled
CI / codeql (push) Has been cancelled
CI / Publish main branch artifacts (push) Has been cancelled
CI / Publish release artefacts (push) Has been cancelled
CI / Publish UI on npm Registry (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
Sync repo files / repo_sync (push) Has been cancelled
Stale Check / stale (push) Has been cancelled
Lock Threads / action (push) Has been cancelled

* Update golangci-lint to v2.6.0
* Fixup various linting issues.
* Fixup deprecations.
* Add exception for `labels.MetricName` deprecation.

Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
Ben Kochie
2025-11-05 13:47:34 +01:00
committed by GitHub
parent 03d0c18c79
commit 204249fcb5
42 changed files with 280 additions and 268 deletions

View File

@@ -47,7 +47,7 @@ linters:
exclusions:
paths:
# Skip autogenerated files.
- ^.*\.(pb|y)\.go$
- ^.*\.(l|pb|y)\.go$
rules:
- linters:
- errcheck
@@ -76,7 +76,7 @@ linters:
source: "^// ==="
- linters:
- staticcheck
text: 'v1\.(Endpoints|EndpointSubset|EndpointPort|EndpointAddress) is deprecated: This API is deprecated in v1.33+'
text: '(labels.MetricName|v1\.(Endpoints|EndpointSubset|EndpointPort|EndpointAddress)) is deprecated: .*'
warn-unused: true
settings:
depguard:
@@ -128,6 +128,8 @@ linters:
sprintf1: true
# Optimizes into strings concatenation.
strconcat: false
# Disable optimization of concat loop.
concat-loop: false
revive:
# By default, revive will enable only the linting rules that are named in the configuration file.
# So, it's needed to explicitly enable all required rules here.

View File

@@ -61,7 +61,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_
SKIP_GOLANGCI_LINT :=
GOLANGCI_LINT :=
GOLANGCI_LINT_OPTS ?=
GOLANGCI_LINT_VERSION ?= v2.4.0
GOLANGCI_LINT_VERSION ?= v2.6.0
GOLANGCI_FMT_OPTS ?=
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64.
# windows isn't included here because of the path separator being different.

View File

@@ -928,15 +928,16 @@ func checkRuleGroups(rgs *rulefmt.RuleGroups, lintSettings rulesLintConfig) (int
if lintSettings.lintDuplicateRules() {
dRules := checkDuplicates(rgs.Groups)
if len(dRules) != 0 {
errMessage := fmt.Sprintf("%d duplicate rule(s) found.\n", len(dRules))
var errMessage strings.Builder
errMessage.WriteString(fmt.Sprintf("%d duplicate rule(s) found.\n", len(dRules)))
for _, n := range dRules {
errMessage += fmt.Sprintf("Metric: %s\nLabel(s):\n", n.metric)
errMessage.WriteString(fmt.Sprintf("Metric: %s\nLabel(s):\n", n.metric))
n.label.Range(func(l labels.Label) {
errMessage += fmt.Sprintf("\t%s: %s\n", l.Name, l.Value)
errMessage.WriteString(fmt.Sprintf("\t%s: %s\n", l.Name, l.Value))
})
}
errMessage += "Might cause inconsistency while recording expressions"
return 0, []error{fmt.Errorf("%w %s", errLint, errMessage)}
errMessage.WriteString("Might cause inconsistency while recording expressions")
return 0, []error{fmt.Errorf("%w %s", errLint, errMessage.String())}
}
}

View File

@@ -799,7 +799,7 @@ func formatSeriesSetOpenMetrics(ss storage.SeriesSet) error {
series := ss.At()
lbs := series.Labels()
metricName := lbs.Get(labels.MetricName)
lbs = lbs.DropMetricName()
lbs = lbs.DropReserved(func(n string) bool { return n == labels.MetricName })
it := series.Iterator(nil)
for it.Next() == chunkenc.ValFloat {
ts, val := it.At()
@@ -889,5 +889,5 @@ func generateBucket(minVal, maxVal int) (start, end, step int) {
start = minVal - minVal%step
end = maxVal - maxVal%step + step
return
return start, end, step
}

View File

@@ -527,11 +527,12 @@ Outer:
// seriesLoadingString returns the input series in PromQL notation.
func (tg *testGroup) seriesLoadingString() string {
result := fmt.Sprintf("load %v\n", shortDuration(tg.Interval))
var result strings.Builder
result.WriteString(fmt.Sprintf("load %v\n", shortDuration(tg.Interval)))
for _, is := range tg.InputSeries {
result += fmt.Sprintf(" %v %v\n", is.Series, is.Values)
result.WriteString(fmt.Sprintf(" %v %v\n", is.Series, is.Values))
}
return result
return result.String()
}
func shortDuration(d model.Duration) string {

View File

@@ -725,11 +725,11 @@ func defaultMockInterfaceServer(interfaceResp armnetwork.Interface) fakenetwork.
return fakenetwork.InterfacesServer{
Get: func(context.Context, string, string, *armnetwork.InterfacesClientGetOptions) (resp azfake.Responder[armnetwork.InterfacesClientGetResponse], errResp azfake.ErrorResponder) {
resp.SetResponse(http.StatusOK, armnetwork.InterfacesClientGetResponse{Interface: interfaceResp}, nil)
return
return resp, errResp
},
GetVirtualMachineScaleSetNetworkInterface: func(context.Context, string, string, string, string, *armnetwork.InterfacesClientGetVirtualMachineScaleSetNetworkInterfaceOptions) (resp azfake.Responder[armnetwork.InterfacesClientGetVirtualMachineScaleSetNetworkInterfaceResponse], errResp azfake.ErrorResponder) {
resp.SetResponse(http.StatusOK, armnetwork.InterfacesClientGetVirtualMachineScaleSetNetworkInterfaceResponse{Interface: interfaceResp}, nil)
return
return resp, errResp
},
}
}
@@ -740,7 +740,7 @@ func defaultMockVMServer(vmResp []armcompute.VirtualMachinesClientListAllRespons
for _, page := range vmResp {
resp.AddPage(http.StatusOK, page, nil)
}
return
return resp
},
}
}
@@ -751,7 +751,7 @@ func defaultMockVMSSServer(vmssResp []armcompute.VirtualMachineScaleSetsClientLi
for _, page := range vmssResp {
resp.AddPage(http.StatusOK, page, nil)
}
return
return resp
},
}
}
@@ -762,7 +762,7 @@ func defaultMockVMSSVMServer(vmssvmResp []armcompute.VirtualMachineScaleSetVMsCl
for _, page := range vmssvmResp {
resp.AddPage(http.StatusOK, page, nil)
}
return
return resp
},
}
}

View File

@@ -32,6 +32,7 @@ import (
)
// Endpoints discovers new endpoint targets.
//
// Deprecated: The Endpoints API is deprecated starting in K8s v1.33+. Use EndpointSlice.
type Endpoints struct {
logger *slog.Logger
@@ -52,6 +53,7 @@ type Endpoints struct {
}
// NewEndpoints returns a new endpoints discovery.
//
// Deprecated: The Endpoints API is deprecated starting in K8s v1.33+. Use NewEndpointSlice.
func NewEndpoints(l *slog.Logger, eps cache.SharedIndexInformer, svc, pod, node, namespace cache.SharedInformer, eventCount *prometheus.CounterVec) *Endpoints {
if l == nil {

View File

@@ -25,6 +25,7 @@ import (
const (
// MetricName is a special label name that represent a metric name.
//
// Deprecated: Use schema.Metadata structure and its methods.
MetricName = "__name__"

View File

@@ -562,6 +562,7 @@ func (Labels) ReleaseStrings(func(string)) {
}
// DropMetricName returns Labels with the "__name__" removed.
//
// Deprecated: Use DropReserved instead.
func (ls Labels) DropMetricName() Labels {
return ls.DropReserved(func(n string) bool { return n == MetricName })

View File

@@ -349,6 +349,7 @@ func (ls Labels) Validate(f func(l Label) error) error {
}
// DropMetricName returns Labels with the "__name__" removed.
//
// Deprecated: Use DropReserved instead.
func (ls Labels) DropMetricName() Labels {
return ls.DropReserved(func(n string) bool { return n == MetricName })

View File

@@ -421,6 +421,7 @@ func (ls Labels) Validate(f func(l Label) error) error {
}
// DropMetricName returns Labels with the "__name__" removed.
//
// Deprecated: Use DropReserved instead.
func (ls Labels) DropMetricName() Labels {
return ls.DropReserved(func(n string) bool { return n == MetricName })

View File

@@ -370,7 +370,7 @@ func optimizeConcatRegex(r *syntax.Regexp) (prefix, suffix string, contains []st
}
if len(sub) == 0 {
return
return prefix, suffix, contains
}
// Given Prometheus regex matchers are always anchored to the begin/end
@@ -391,7 +391,7 @@ func optimizeConcatRegex(r *syntax.Regexp) (prefix, suffix string, contains []st
}
}
return
return prefix, suffix, contains
}
// StringMatcher is a matcher that matches a string in place of a regular expression.

View File

@@ -988,7 +988,7 @@ func TestFindEqualOrPrefixStringMatchers(t *testing.T) {
return true
})
return
return matches, ok
}
t.Run("empty matcher", func(t *testing.T) {

View File

@@ -100,7 +100,7 @@ type ruleGroups struct {
func (g *RuleGroups) Validate(node ruleGroups, nameValidationScheme model.ValidationScheme) (errs []error) {
if err := namevalidationutil.CheckNameValidationScheme(nameValidationScheme); err != nil {
errs = append(errs, err)
return
return errs
}
set := map[string]struct{}{}
@@ -286,7 +286,7 @@ func (r *Rule) Validate(node RuleNode, nameValidationScheme model.ValidationSche
nodes = append(nodes, WrappedError{err: err})
}
return
return nodes
}
// testTemplateParsing checks if the templates used in labels and annotations

View File

@@ -373,7 +373,7 @@ func (p *NHCBParser) processNHCB() bool {
p.fhNHCB = fh
}
lblsWithMetricName := p.tempLsetNHCB.DropMetricName()
lblsWithMetricName := p.tempLsetNHCB.DropReserved(func(n string) bool { return n == labels.MetricName })
// Ensure we return `metric` instead of `metric{}` for name only
// series, for consistency with wrapped parsers.
if lblsWithMetricName.IsEmpty() {

View File

@@ -74,10 +74,10 @@ yystart1:
yystate2:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == ' ':
case ' ':
goto yystate3
}
@@ -101,43 +101,43 @@ yystate5:
yystate6:
c = l.next()
yystart6:
switch {
switch c {
default:
goto yyabort
case c == 'E':
case 'E':
goto yystate7
case c == 'H':
case 'H':
goto yystate11
case c == 'T':
case 'T':
goto yystate16
case c == 'U':
case 'U':
goto yystate21
}
yystate7:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'O':
case 'O':
goto yystate8
}
yystate8:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'F':
case 'F':
goto yystate9
}
yystate9:
c = l.next()
switch {
switch c {
default:
goto yyrule5
case c == '\n':
case '\n':
goto yystate10
}
@@ -147,37 +147,37 @@ yystate10:
yystate11:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'E':
case 'E':
goto yystate12
}
yystate12:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'L':
case 'L':
goto yystate13
}
yystate13:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'P':
case 'P':
goto yystate14
}
yystate14:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == ' ':
case ' ':
goto yystate15
}
@@ -187,37 +187,37 @@ yystate15:
yystate16:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'Y':
case 'Y':
goto yystate17
}
yystate17:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'P':
case 'P':
goto yystate18
}
yystate18:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'E':
case 'E':
goto yystate19
}
yystate19:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == ' ':
case ' ':
goto yystate20
}
@@ -227,37 +227,37 @@ yystate20:
yystate21:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'N':
case 'N':
goto yystate22
}
yystate22:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'I':
case 'I':
goto yystate23
}
yystate23:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'T':
case 'T':
goto yystate24
}
yystate24:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == ' ':
case ' ':
goto yystate25
}
@@ -315,10 +315,10 @@ yystate30:
yystate31:
c = l.next()
yystart31:
switch {
switch c {
default:
goto yyabort
case c == ' ':
case ' ':
goto yystate32
}
@@ -405,10 +405,10 @@ yystate41:
yystate42:
c = l.next()
yystart42:
switch {
switch c {
default:
goto yyabort
case c == '"':
case '"':
goto yystate43
}
@@ -441,12 +441,12 @@ yystate45:
yystate46:
c = l.next()
yystart46:
switch {
switch c {
default:
goto yyabort
case c == ' ':
case ' ':
goto yystate47
case c == '{':
case '{':
goto yystate49
}
@@ -475,12 +475,12 @@ yystate49:
yystate50:
c = l.next()
yystart50:
switch {
switch c {
default:
goto yyabort
case c == ' ':
case ' ':
goto yystate52
case c == '\n':
case '\n':
goto yystate51
}
@@ -521,10 +521,10 @@ yystate54:
yystate55:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == '{':
case '{':
goto yystate56
}
@@ -600,12 +600,12 @@ yystate64:
yystate65:
c = l.next()
yystart65:
switch {
switch c {
default:
goto yyabort
case c == ' ':
case ' ':
goto yystate66
case c == '"':
case '"':
goto yystate68
}
@@ -656,12 +656,12 @@ yystate70:
yystate71:
c = l.next()
yystart71:
switch {
switch c {
default:
goto yyabort
case c == ' ':
case ' ':
goto yystate73
case c == '\n':
case '\n':
goto yystate72
}
@@ -696,61 +696,61 @@ yyrule2: // HELP{S}
{
l.state = sMeta1
return tHelp
goto yystate0
}
yyrule3: // TYPE{S}
{
l.state = sMeta1
return tType
goto yystate0
}
yyrule4: // UNIT{S}
{
l.state = sMeta1
return tUnit
goto yystate0
}
yyrule5: // "EOF"\n?
{
l.state = sInit
return tEOFWord
goto yystate0
}
yyrule6: // \"(\\.|[^\\"])*\"
{
l.state = sMeta2
return tMName
goto yystate0
}
yyrule7: // {M}({M}|{D})*
{
l.state = sMeta2
return tMName
goto yystate0
}
yyrule8: // {S}{C}*\n
{
l.state = sInit
return tText
goto yystate0
}
yyrule9: // {M}({M}|{D})*
{
l.state = sValue
return tMName
goto yystate0
}
yyrule10: // \{
{
l.state = sLabels
return tBraceOpen
goto yystate0
}
yyrule11: // \{
{
l.state = sLabels
return tBraceOpen
goto yystate0
}
yyrule12: // {L}({L}|{D})*
{
@@ -760,19 +760,19 @@ yyrule13: // \"(\\.|[^\\"])*\"
{
l.state = sLabels
return tQString
goto yystate0
}
yyrule14: // \}
{
l.state = sValue
return tBraceClose
goto yystate0
}
yyrule15: // =
{
l.state = sLValue
return tEqual
goto yystate0
}
yyrule16: // ,
{
@@ -782,13 +782,13 @@ yyrule17: // \"(\\.|[^\\"\n])*\"
{
l.state = sLabels
return tLValue
goto yystate0
}
yyrule18: // {S}[^ \n]+
{
l.state = sTimestamp
return tValue
goto yystate0
}
yyrule19: // {S}[^ \n]+
{
@@ -798,13 +798,13 @@ yyrule20: // \n
{
l.state = sInit
return tLinebreak
goto yystate0
}
yyrule21: // {S}#{S}\{
{
l.state = sExemplar
return tComment
goto yystate0
}
yyrule22: // {L}({L}|{D})*
{
@@ -814,25 +814,25 @@ yyrule23: // \"(\\.|[^\\"\n])*\"
{
l.state = sExemplar
return tQString
goto yystate0
}
yyrule24: // \}
{
l.state = sEValue
return tBraceClose
goto yystate0
}
yyrule25: // =
{
l.state = sEValue
return tEqual
goto yystate0
}
yyrule26: // \"(\\.|[^\\"\n])*\"
{
l.state = sExemplar
return tLValue
goto yystate0
}
yyrule27: // ,
{
@@ -842,7 +842,7 @@ yyrule28: // {S}[^ \n]+
{
l.state = sETimestamp
return tValue
goto yystate0
}
yyrule29: // {S}[^ \n]+
{
@@ -852,7 +852,7 @@ yyrule30: // \n
if true { // avoid go vet determining the below panic will not be reached
l.state = sInit
return tLinebreak
goto yystate0
}
panic("unreachable")

View File

@@ -92,10 +92,10 @@ yystate2:
yystate3:
c = l.next()
switch {
switch c {
default:
goto yyrule3
case c == '\t' || c == ' ':
case '\t', ' ':
goto yystate3
}
@@ -105,19 +105,19 @@ yystate4:
yystate5:
c = l.next()
switch {
switch c {
default:
goto yyrule5
case c == '\t' || c == ' ':
case '\t', ' ':
goto yystate6
}
yystate6:
c = l.next()
switch {
switch c {
default:
goto yyrule4
case c == '\t' || c == ' ':
case '\t', ' ':
goto yystate6
}
@@ -137,104 +137,104 @@ yystate8:
yystate9:
c = l.next()
yystart9:
switch {
switch c {
default:
goto yyabort
case c == 'H':
case 'H':
goto yystate10
case c == 'T':
case 'T':
goto yystate15
case c == '\t' || c == ' ':
case '\t', ' ':
goto yystate3
}
yystate10:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'E':
case 'E':
goto yystate11
}
yystate11:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'L':
case 'L':
goto yystate12
}
yystate12:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'P':
case 'P':
goto yystate13
}
yystate13:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == '\t' || c == ' ':
case '\t', ' ':
goto yystate14
}
yystate14:
c = l.next()
switch {
switch c {
default:
goto yyrule6
case c == '\t' || c == ' ':
case '\t', ' ':
goto yystate14
}
yystate15:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'Y':
case 'Y':
goto yystate16
}
yystate16:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'P':
case 'P':
goto yystate17
}
yystate17:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == 'E':
case 'E':
goto yystate18
}
yystate18:
c = l.next()
switch {
switch c {
default:
goto yyabort
case c == '\t' || c == ' ':
case '\t', ' ':
goto yystate19
}
yystate19:
c = l.next()
switch {
switch c {
default:
goto yyrule7
case c == '\t' || c == ' ':
case '\t', ' ':
goto yystate19
}
@@ -389,12 +389,12 @@ yystate35:
yystate36:
c = l.next()
yystart36:
switch {
switch c {
default:
goto yyabort
case c == '"':
case '"':
goto yystate37
case c == '\t' || c == ' ':
case '\t', ' ':
goto yystate3
}
@@ -486,7 +486,7 @@ yyrule2: // \n
{
l.state = sInit
return tLinebreak
goto yystate0
}
yyrule3: // [ \t]+
{
@@ -505,49 +505,49 @@ yyrule6: // HELP[\t ]+
{
l.state = sMeta1
return tHelp
goto yystate0
}
yyrule7: // TYPE[\t ]+
{
l.state = sMeta1
return tType
goto yystate0
}
yyrule8: // \"(\\.|[^\\"])*\"
{
l.state = sMeta2
return tMName
goto yystate0
}
yyrule9: // {M}({M}|{D})*
{
l.state = sMeta2
return tMName
goto yystate0
}
yyrule10: // {C}*
{
l.state = sInit
return tText
goto yystate0
}
yyrule11: // {M}({M}|{D})*
{
l.state = sValue
return tMName
goto yystate0
}
yyrule12: // \{
{
l.state = sLabels
return tBraceOpen
goto yystate0
}
yyrule13: // \{
{
l.state = sLabels
return tBraceOpen
goto yystate0
}
yyrule14: // {L}({L}|{D})*
{
@@ -557,19 +557,19 @@ yyrule15: // \"(\\.|[^\\"])*\"
{
l.state = sLabels
return tQString
goto yystate0
}
yyrule16: // \}
{
l.state = sValue
return tBraceClose
goto yystate0
}
yyrule17: // =
{
l.state = sLValue
return tEqual
goto yystate0
}
yyrule18: // ,
{
@@ -579,13 +579,13 @@ yyrule19: // \"(\\.|[^\\"])*\"
{
l.state = sLabels
return tLValue
goto yystate0
}
yyrule20: // [^{ \t\n]+
{
l.state = sTimestamp
return tValue
goto yystate0
}
yyrule21: // {D}+
{
@@ -595,7 +595,7 @@ yyrule22: // \n
if true { // avoid go vet determining the below panic will not be reached
l.state = sInit
return tLinebreak
goto yystate0
}
panic("unreachable")

View File

@@ -20,6 +20,7 @@ import (
"fmt"
"io"
"math/rand"
"strings"
"testing"
"github.com/gogo/protobuf/proto"
@@ -236,9 +237,11 @@ func generateMetricFamilyText(labelsCount int) string {
randomName := fmt.Sprintf("metric_%d", rand.Intn(1000))
randomHelp := fmt.Sprintf("Test metric to demonstrate forced corruption %d.", rand.Intn(1000))
labels10 := ""
var labels10Sb239 strings.Builder
for range labelsCount {
labels10 += generateLabels()
labels10Sb239.WriteString(generateLabels())
}
labels10 += labels10Sb239.String()
return fmt.Sprintf(`name: "%s"
help: "%s"
type: GAUGE

View File

@@ -2310,7 +2310,7 @@ func reuseOrGetHPointSlices(prevSS *Series, numSteps int) (r []HPoint) {
if prevSS != nil && cap(prevSS.Histograms)-2*len(prevSS.Histograms) > 0 {
r = prevSS.Histograms[len(prevSS.Histograms):]
prevSS.Histograms = prevSS.Histograms[0:len(prevSS.Histograms):len(prevSS.Histograms)]
return
return r
}
return getHPointSlice(numSteps)
@@ -2322,7 +2322,7 @@ func reuseOrGetFPointSlices(prevSS *Series, numSteps int) (r []FPoint) {
if prevSS != nil && cap(prevSS.Floats)-2*len(prevSS.Floats) > 0 {
r = prevSS.Floats[len(prevSS.Floats):]
prevSS.Floats = prevSS.Floats[0:len(prevSS.Floats):len(prevSS.Floats)]
return
return r
}
return getFPointSlice(numSteps)

View File

@@ -1526,7 +1526,7 @@ func simpleHistogramFunc(vectorVals []Vector, enh *EvalNodeHelper, f func(h *his
for _, el := range vectorVals[0] {
if el.H != nil { // Process only histogram samples.
if !enh.enableDelayedNameRemoval {
el.Metric = el.Metric.DropMetricName()
el.Metric = el.Metric.DropReserved(func(n string) bool { return n == labels.MetricName })
}
enh.Out = append(enh.Out, Sample{
Metric: el.Metric,

View File

@@ -453,14 +453,14 @@ func (p *parser) newAggregateExpr(op Item, modifier, args Node, overread bool) (
p.addParseErrf(ret.PositionRange(), "no arguments for aggregate expression provided")
// Prevents invalid array accesses.
return
return ret
}
desiredArgs := 1
if ret.Op.IsAggregatorWithParam() {
if !EnableExperimentalFunctions && ret.Op.IsExperimentalAggregator() {
p.addParseErrf(ret.PositionRange(), "%s() is experimental and must be enabled with --enable-feature=promql-experimental-functions", ret.Op)
return
return ret
}
desiredArgs = 2
@@ -469,7 +469,7 @@ func (p *parser) newAggregateExpr(op Item, modifier, args Node, overread bool) (
if len(arguments) != desiredArgs {
p.addParseErrf(ret.PositionRange(), "wrong number of arguments for aggregate expression provided, expected %d, got %d", desiredArgs, len(arguments))
return
return ret
}
ret.Expr = arguments[desiredArgs-1]
@@ -652,7 +652,7 @@ func (p *parser) buildHistogramBucketsAndSpans(desc *map[string]any, bucketsKey,
if bucketCount > 0 {
spans = []histogram.Span{{Offset: offset, Length: uint32(bucketCount)}}
}
return
return buckets, spans
}
// number parses a number.
@@ -730,7 +730,7 @@ func (p *parser) checkAST(node Node) (typ ValueType) {
}
for r.End = n.RHS.PositionRange().Start - 1; isSpace(rune(p.lex.input[r.End])); r.End-- {
}
return
return r
}
if n.ReturnBool && !n.Op.IsComparisonOperator() {
@@ -882,7 +882,7 @@ func (p *parser) checkAST(node Node) (typ ValueType) {
default:
p.addParseErrf(n.PositionRange(), "unknown node type: %T", node)
}
return
return typ
}
func (p *parser) unquoteString(s string) string {

View File

@@ -789,7 +789,7 @@ func (g *Group) RestoreForState(ts time.Time) {
// While not technically the same number of series we expect, it's as good of an approximation as any.
seriesByLabels := make(map[string]storage.Series, alertRule.ActiveAlertsCount())
for sset.Next() {
seriesByLabels[sset.At().Labels().DropMetricName().String()] = sset.At()
seriesByLabels[sset.At().Labels().DropReserved(func(n string) bool { return n == labels.MetricName }).String()] = sset.At()
}
// No results for this alert rule.

View File

@@ -1642,7 +1642,7 @@ func (sl *scrapeLoop) updateStaleMarkers(app storage.Appender, defTime int64) (e
}
return err == nil
})
return
return err
}
func (sl *scrapeLoop) append(app storage.Appender, b []byte, contentType string, ts time.Time) (total, added, seriesAdded int, err error) {
@@ -1652,7 +1652,7 @@ func (sl *scrapeLoop) append(app storage.Appender, b []byte, contentType string,
// Empty scrape. Just update the stale makers and swap the cache (but don't flush it).
err = sl.updateStaleMarkers(app, defTime)
sl.cache.iterDone(false)
return
return total, added, seriesAdded, err
}
p, err := textparse.New(b, contentType, sl.symbolTable, textparse.ParserOptions{
@@ -1670,7 +1670,7 @@ func (sl *scrapeLoop) append(app storage.Appender, b []byte, contentType string,
"fallback_media_type", sl.fallbackScrapeProtocol,
"err", err,
)
return
return total, added, seriesAdded, err
}
if err != nil {
sl.l.Debug(
@@ -1952,7 +1952,7 @@ loop:
if err == nil {
err = sl.updateStaleMarkers(app, defTime)
}
return
return total, added, seriesAdded, err
}
func isSeriesPartOfFamily(mName string, mfName []byte, typ model.MetricType) bool {
@@ -2150,32 +2150,32 @@ func (sl *scrapeLoop) report(app storage.Appender, start time.Time, duration tim
b := labels.NewBuilderWithSymbolTable(sl.symbolTable)
if err = sl.addReportSample(app, scrapeHealthMetric, ts, health, b); err != nil {
return
return err
}
if err = sl.addReportSample(app, scrapeDurationMetric, ts, duration.Seconds(), b); err != nil {
return
return err
}
if err = sl.addReportSample(app, scrapeSamplesMetric, ts, float64(scraped), b); err != nil {
return
return err
}
if err = sl.addReportSample(app, samplesPostRelabelMetric, ts, float64(added), b); err != nil {
return
return err
}
if err = sl.addReportSample(app, scrapeSeriesAddedMetric, ts, float64(seriesAdded), b); err != nil {
return
return err
}
if sl.reportExtraMetrics {
if err = sl.addReportSample(app, scrapeTimeoutMetric, ts, sl.timeout.Seconds(), b); err != nil {
return
return err
}
if err = sl.addReportSample(app, scrapeSampleLimitMetric, ts, float64(sl.sampleLimit), b); err != nil {
return
return err
}
if err = sl.addReportSample(app, scrapeBodySizeBytesMetric, ts, float64(bytes), b); err != nil {
return
return err
}
}
return
return err
}
func (sl *scrapeLoop) reportStale(app storage.Appender, start time.Time) (err error) {
@@ -2185,32 +2185,32 @@ func (sl *scrapeLoop) reportStale(app storage.Appender, start time.Time) (err er
b := labels.NewBuilder(labels.EmptyLabels())
if err = sl.addReportSample(app, scrapeHealthMetric, ts, stale, b); err != nil {
return
return err
}
if err = sl.addReportSample(app, scrapeDurationMetric, ts, stale, b); err != nil {
return
return err
}
if err = sl.addReportSample(app, scrapeSamplesMetric, ts, stale, b); err != nil {
return
return err
}
if err = sl.addReportSample(app, samplesPostRelabelMetric, ts, stale, b); err != nil {
return
return err
}
if err = sl.addReportSample(app, scrapeSeriesAddedMetric, ts, stale, b); err != nil {
return
return err
}
if sl.reportExtraMetrics {
if err = sl.addReportSample(app, scrapeTimeoutMetric, ts, stale, b); err != nil {
return
return err
}
if err = sl.addReportSample(app, scrapeSampleLimitMetric, ts, stale, b); err != nil {
return
return err
}
if err = sl.addReportSample(app, scrapeBodySizeBytesMetric, ts, stale, b); err != nil {
return
return err
}
}
return
return err
}
func (sl *scrapeLoop) addReportSample(app storage.Appender, s reportSample, t int64, v float64, b *labels.Builder) error {

View File

@@ -253,7 +253,7 @@ func (f *fanoutAppender) Commit() (err error) {
}
}
}
return
return err
}
func (f *fanoutAppender) Rollback() (err error) {

View File

@@ -186,7 +186,7 @@ func (b *combinedAppender) appendFloatOrHistogram(ls labels.Labels, meta metadat
if ref == 0 {
// We cannot update metadata or add exemplars on non existent series.
return
return err
}
if !exists || series.meta.Help != meta.Help || series.meta.Type != meta.Type || series.meta.Unit != meta.Unit {
@@ -210,7 +210,7 @@ func (b *combinedAppender) appendFloatOrHistogram(ls labels.Labels, meta metadat
b.appendExemplars(ref, ls, es)
return
return err
}
func sampleType(h *histogram.Histogram) string {

View File

@@ -165,7 +165,7 @@ func (c *PrometheusConverter) FromMetrics(ctx context.Context, md pmetric.Metric
for k := 0; k < metricSlice.Len(); k++ {
if err := c.everyN.checkContext(ctx); err != nil {
errs = multierr.Append(errs, err)
return
return annots, errs
}
metric := metricSlice.At(k)
@@ -213,7 +213,7 @@ func (c *PrometheusConverter) FromMetrics(ctx context.Context, md pmetric.Metric
if err := c.addGaugeNumberDataPoints(ctx, dataPoints, resource, settings, scope, meta); err != nil {
errs = multierr.Append(errs, err)
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return
return annots, errs
}
}
case pmetric.MetricTypeSum:
@@ -225,7 +225,7 @@ func (c *PrometheusConverter) FromMetrics(ctx context.Context, md pmetric.Metric
if err := c.addSumNumberDataPoints(ctx, dataPoints, resource, settings, scope, meta); err != nil {
errs = multierr.Append(errs, err)
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return
return annots, errs
}
}
case pmetric.MetricTypeHistogram:
@@ -242,14 +242,14 @@ func (c *PrometheusConverter) FromMetrics(ctx context.Context, md pmetric.Metric
if err != nil {
errs = multierr.Append(errs, err)
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return
return annots, errs
}
}
} else {
if err := c.addHistogramDataPoints(ctx, dataPoints, resource, settings, scope, meta); err != nil {
errs = multierr.Append(errs, err)
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return
return annots, errs
}
}
}
@@ -272,7 +272,7 @@ func (c *PrometheusConverter) FromMetrics(ctx context.Context, md pmetric.Metric
if err != nil {
errs = multierr.Append(errs, err)
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return
return annots, errs
}
}
case pmetric.MetricTypeSummary:
@@ -284,7 +284,7 @@ func (c *PrometheusConverter) FromMetrics(ctx context.Context, md pmetric.Metric
if err := c.addSummaryDataPoints(ctx, dataPoints, resource, settings, scope, meta); err != nil {
errs = multierr.Append(errs, err)
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return
return annots, errs
}
}
default:
@@ -301,7 +301,7 @@ func (c *PrometheusConverter) FromMetrics(ctx context.Context, md pmetric.Metric
}
}
return
return annots, errs
}
func NewPromoteResourceAttributes(otlpCfg config.OTLPConfig) *PromoteResourceAttributes {

View File

@@ -230,59 +230,59 @@ func (a *FloatHistogramAppender) appendable(h *histogram.FloatHistogram) (
okToAppend, counterReset bool,
) {
if a.NumSamples() > 0 && a.GetCounterResetHeader() == GaugeType {
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterReset
}
if h.CounterResetHint == histogram.CounterReset {
// Always honor the explicit counter reset hint.
counterReset = true
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterReset
}
if value.IsStaleNaN(h.Sum) {
// This is a stale sample whose buckets and spans don't matter.
okToAppend = true
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterReset
}
if value.IsStaleNaN(a.sum.value) {
// If the last sample was stale, then we can only accept stale
// samples in this chunk.
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterReset
}
if h.Count < a.cnt.value {
// There has been a counter reset.
counterReset = true
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterReset
}
if h.Schema != a.schema || h.ZeroThreshold != a.zThreshold {
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterReset
}
if histogram.IsCustomBucketsSchema(h.Schema) && !histogram.CustomBucketBoundsMatch(h.CustomValues, a.customValues) {
counterReset = true
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterReset
}
if h.ZeroCount < a.zCnt.value {
// There has been a counter reset since ZeroThreshold didn't change.
counterReset = true
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterReset
}
var ok bool
positiveInserts, backwardPositiveInserts, ok = expandFloatSpansAndBuckets(a.pSpans, h.PositiveSpans, a.pBuckets, h.PositiveBuckets)
if !ok {
counterReset = true
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterReset
}
negativeInserts, backwardNegativeInserts, ok = expandFloatSpansAndBuckets(a.nSpans, h.NegativeSpans, a.nBuckets, h.NegativeBuckets)
if !ok {
counterReset = true
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterReset
}
okToAppend = true
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterReset
}
// expandFloatSpansAndBuckets returns the inserts to expand the bucket spans 'a' so that
@@ -478,31 +478,31 @@ func (a *FloatHistogramAppender) appendableGauge(h *histogram.FloatHistogram) (
okToAppend bool,
) {
if a.NumSamples() > 0 && a.GetCounterResetHeader() != GaugeType {
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, positiveSpans, negativeSpans, okToAppend
}
if value.IsStaleNaN(h.Sum) {
// This is a stale sample whose buckets and spans don't matter.
okToAppend = true
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, positiveSpans, negativeSpans, okToAppend
}
if value.IsStaleNaN(a.sum.value) {
// If the last sample was stale, then we can only accept stale
// samples in this chunk.
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, positiveSpans, negativeSpans, okToAppend
}
if h.Schema != a.schema || h.ZeroThreshold != a.zThreshold {
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, positiveSpans, negativeSpans, okToAppend
}
if histogram.IsCustomBucketsSchema(h.Schema) && !histogram.CustomBucketBoundsMatch(h.CustomValues, a.customValues) {
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, positiveSpans, negativeSpans, okToAppend
}
positiveInserts, backwardPositiveInserts, positiveSpans = expandSpansBothWays(a.pSpans, h.PositiveSpans)
negativeInserts, backwardNegativeInserts, negativeSpans = expandSpansBothWays(a.nSpans, h.NegativeSpans)
okToAppend = true
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, positiveSpans, negativeSpans, okToAppend
}
// appendFloatHistogram appends a float histogram to the chunk. The caller must ensure that

View File

@@ -260,29 +260,29 @@ func (a *HistogramAppender) appendable(h *histogram.Histogram) (
) {
counterResetHint = NotCounterReset
if a.NumSamples() > 0 && a.GetCounterResetHeader() == GaugeType {
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterResetHint
}
if h.CounterResetHint == histogram.CounterReset {
// Always honor the explicit counter reset hint.
counterResetHint = CounterReset
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterResetHint
}
if value.IsStaleNaN(h.Sum) {
// This is a stale sample whose buckets and spans don't matter.
okToAppend = true
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterResetHint
}
if value.IsStaleNaN(a.sum) {
// If the last sample was stale, then we can only accept stale
// samples in this chunk.
counterResetHint = UnknownCounterReset
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterResetHint
}
if h.Count < a.cnt {
// There has been a counter reset.
counterResetHint = CounterReset
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterResetHint
}
if h.Schema != a.schema || h.ZeroThreshold != a.zThreshold {
@@ -291,34 +291,34 @@ func (a *HistogramAppender) appendable(h *histogram.Histogram) (
// as long as https://github.com/prometheus/prometheus/issues/15346 is still open.
// TODO: consider adding the counter reset detection here once #15346 is fixed.
counterResetHint = UnknownCounterReset
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterResetHint
}
if histogram.IsCustomBucketsSchema(h.Schema) && !histogram.CustomBucketBoundsMatch(h.CustomValues, a.customValues) {
counterResetHint = CounterReset
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterResetHint
}
if h.ZeroCount < a.zCnt {
// There has been a counter reset since ZeroThreshold didn't change.
counterResetHint = CounterReset
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterResetHint
}
var ok bool
positiveInserts, backwardPositiveInserts, ok = expandIntSpansAndBuckets(a.pSpans, h.PositiveSpans, a.pBuckets, h.PositiveBuckets)
if !ok {
counterResetHint = CounterReset
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterResetHint
}
negativeInserts, backwardNegativeInserts, ok = expandIntSpansAndBuckets(a.nSpans, h.NegativeSpans, a.nBuckets, h.NegativeBuckets)
if !ok {
counterResetHint = CounterReset
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterResetHint
}
okToAppend = true
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, okToAppend, counterResetHint
}
// expandIntSpansAndBuckets returns the inserts to expand the bucket spans 'a' so that
@@ -515,31 +515,31 @@ func (a *HistogramAppender) appendableGauge(h *histogram.Histogram) (
okToAppend bool,
) {
if a.NumSamples() > 0 && a.GetCounterResetHeader() != GaugeType {
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, positiveSpans, negativeSpans, okToAppend
}
if value.IsStaleNaN(h.Sum) {
// This is a stale sample whose buckets and spans don't matter.
okToAppend = true
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, positiveSpans, negativeSpans, okToAppend
}
if value.IsStaleNaN(a.sum) {
// If the last sample was stale, then we can only accept stale
// samples in this chunk.
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, positiveSpans, negativeSpans, okToAppend
}
if h.Schema != a.schema || h.ZeroThreshold != a.zThreshold {
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, positiveSpans, negativeSpans, okToAppend
}
if histogram.IsCustomBucketsSchema(h.Schema) && !histogram.CustomBucketBoundsMatch(h.CustomValues, a.customValues) {
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, positiveSpans, negativeSpans, okToAppend
}
positiveInserts, backwardPositiveInserts, positiveSpans = expandSpansBothWays(a.pSpans, h.PositiveSpans)
negativeInserts, backwardNegativeInserts, negativeSpans = expandSpansBothWays(a.nSpans, h.NegativeSpans)
okToAppend = true
return
return positiveInserts, negativeInserts, backwardPositiveInserts, backwardNegativeInserts, positiveSpans, negativeSpans, okToAppend
}
// appendHistogram appends a histogram to the chunk. The caller must ensure that

View File

@@ -40,33 +40,33 @@ func readHistogramChunkLayout(b *bstreamReader) (
) {
zeroThreshold, err = readZeroThreshold(b)
if err != nil {
return
return schema, zeroThreshold, positiveSpans, negativeSpans, customValues, err
}
v, err := readVarbitInt(b)
if err != nil {
return
return schema, zeroThreshold, positiveSpans, negativeSpans, customValues, err
}
schema = int32(v)
positiveSpans, err = readHistogramChunkLayoutSpans(b)
if err != nil {
return
return schema, zeroThreshold, positiveSpans, negativeSpans, customValues, err
}
negativeSpans, err = readHistogramChunkLayoutSpans(b)
if err != nil {
return
return schema, zeroThreshold, positiveSpans, negativeSpans, customValues, err
}
if histogram.IsCustomBucketsSchema(schema) {
customValues, err = readHistogramChunkLayoutCustomBounds(b)
if err != nil {
return
return schema, zeroThreshold, positiveSpans, negativeSpans, customValues, err
}
}
return
return schema, zeroThreshold, positiveSpans, negativeSpans, customValues, err
}
func putHistogramChunkLayoutSpans(b *bstream, spans []histogram.Span) {
@@ -550,5 +550,5 @@ func adjustForInserts(spans []histogram.Span, inserts []Insert) (mergedSpans []h
addBucket(insertIdx)
consumeInsert()
}
return
return mergedSpans
}

View File

@@ -197,7 +197,7 @@ func ChunkFromSamplesGeneric(s Samples) (Meta, error) {
// Used in tests to compare the content of chunks.
func ChunkMetasToSamples(chunks []Meta) (result []Sample) {
if len(chunks) == 0 {
return
return result
}
for _, chunk := range chunks {
@@ -218,7 +218,7 @@ func ChunkMetasToSamples(chunks []Meta) (result []Sample) {
}
}
}
return
return result
}
// Iterator iterates over the chunks of a single time series.

View File

@@ -579,5 +579,5 @@ func createChunk(t *testing.T, idx int, hrw *ChunkDiskMapper) (seriesRef HeadSer
close(awaitCb)
})
<-awaitCb
return
return seriesRef, chunkRef, mint, maxt, chunk, isOOO
}

View File

@@ -1768,7 +1768,7 @@ func BeyondTimeRetention(db *DB, blocks []*Block) (deletable map[ulid.ULID]struc
// Time retention is disabled or no blocks to work with.
retentionDuration := db.getRetentionDuration()
if len(blocks) == 0 || retentionDuration == 0 {
return
return deletable
}
deletable = make(map[ulid.ULID]struct{})
@@ -1792,7 +1792,7 @@ func BeyondSizeRetention(db *DB, blocks []*Block) (deletable map[ulid.ULID]struc
// Size retention is disabled or no blocks to work with.
maxBytes := db.getMaxBytes()
if len(blocks) == 0 || maxBytes <= 0 {
return
return deletable
}
deletable = make(map[ulid.ULID]struct{})

View File

@@ -1433,7 +1433,7 @@ func intersection(oldBlocks, actualBlocks []string) (intersection []string) {
intersection = append(intersection, e)
}
}
return
return intersection
}
// mockCompactorFailing creates a new empty block on every write and fails when reached the max allowed total.
@@ -2741,7 +2741,7 @@ func TestDBReadOnly_Querier_NoAlteration(t *testing.T) {
if runtime.GOOS != "windows" {
hash = testutil.DirHash(t, dir)
}
return
return hash
}
spinUpQuerierAndCheck := func(dir, sandboxDir string, chunksCount int) {

View File

@@ -2207,7 +2207,7 @@ func (s *memSeries) mmapCurrentOOOHeadChunk(chunkDiskMapper *chunks.ChunkDiskMap
func (s *memSeries) mmapChunks(chunkDiskMapper *chunks.ChunkDiskMapper) (count int) {
if s.headChunks == nil || s.headChunks.prev == nil {
// There is none or only one head chunk, so nothing to m-map here.
return
return count
}
// Write chunks starting from the oldest one and stop before we get to current s.headChunks.

View File

@@ -548,7 +548,7 @@ func (h *Head) resetSeriesWithMMappedChunks(mSeries *memSeries, mmc, oooMmc []*m
mSeries.nextAt = 0
mSeries.headChunks = nil
mSeries.app = nil
return
return overlapped
}
type walSubsetProcessor struct {
@@ -1194,7 +1194,7 @@ func decodeSeriesFromChunkSnapshot(d *record.Decoder, b []byte) (csr chunkSnapsh
_ = dec.Be64int64() // Was chunkRange but now unused.
if dec.Uvarint() == 0 {
return
return csr, err
}
csr.mc = &memChunk{}
@@ -1235,7 +1235,7 @@ func decodeSeriesFromChunkSnapshot(d *record.Decoder, b []byte) (csr chunkSnapsh
err = fmt.Errorf("unexpected %d bytes left in entry", len(dec.B))
}
return
return csr, err
}
func encodeTombstonesToSnapshotRecord(tr tombstones.Reader) ([]byte, error) {

View File

@@ -120,7 +120,7 @@ func (o *OOOChunk) ToEncodedChunks(mint, maxt int64) (chks []memChunk, err error
}
app, err = chunk.Appender()
if err != nil {
return
return chks, err
}
}
switch encoding {

View File

@@ -670,7 +670,7 @@ func BenchmarkWAL_HistogramEncoding(b *testing.B) {
}
delete(lbls, model.BucketLabel)
}
return
return series, floatSamples, histSamples
}
initNHCBRefs := func(labelCount, histograms, buckets int) (series []RefSeries, floatSamples []RefSample, histSamples []RefHistogramSample) {
@@ -703,7 +703,7 @@ func BenchmarkWAL_HistogramEncoding(b *testing.B) {
})
ref++
}
return
return series, floatSamples, histSamples
}
for _, maker := range []recordsMaker{

View File

@@ -788,12 +788,12 @@ func (w *WL) LastSegmentAndOffset() (seg, offset int, err error) {
_, seg, err = Segments(w.Dir())
if err != nil {
return
return seg, offset, err
}
offset = (w.donePages * pageSize) + w.page.alloc
return
return seg, offset, err
}
// Truncate drops all segments before i.

View File

@@ -107,7 +107,7 @@ func (a Annotations) AsStrings(query string, maxWarnings, maxInfos int) (warning
if infoSkipped > 0 {
infos = append(infos, fmt.Sprintf("%d more info annotations omitted", infoSkipped))
}
return
return warnings, infos
}
// CountWarningsAndInfo counts and returns the number of warnings and infos in the
@@ -121,7 +121,7 @@ func (a Annotations) CountWarningsAndInfo() (countWarnings, countInfo int) {
countInfo++
}
}
return
return countWarnings, countInfo
}
//nolint:staticcheck,revive // error-naming.

View File

@@ -129,7 +129,7 @@ func unquoteChar(s string, quote byte) (value rune, multibyte bool, tail string,
switch c := s[0]; {
case c == quote && (quote == '\'' || quote == '"'):
err = ErrSyntax
return
return value, multibyte, tail, err
case c >= utf8.RuneSelf:
r, size := utf8.DecodeRuneInString(s)
return r, true, s[size:], nil
@@ -140,7 +140,7 @@ func unquoteChar(s string, quote byte) (value rune, multibyte bool, tail string,
// Hard case: c is backslash.
if len(s) <= 1 {
err = ErrSyntax
return
return value, multibyte, tail, err
}
c := s[1]
s = s[2:]
@@ -173,13 +173,13 @@ func unquoteChar(s string, quote byte) (value rune, multibyte bool, tail string,
var v rune
if len(s) < n {
err = ErrSyntax
return
return value, multibyte, tail, err
}
for j := 0; j < n; j++ {
x, ok := unhex(s[j])
if !ok {
err = ErrSyntax
return
return value, multibyte, tail, err
}
v = v<<4 | x
}
@@ -191,7 +191,7 @@ func unquoteChar(s string, quote byte) (value rune, multibyte bool, tail string,
}
if v > utf8.MaxRune {
err = ErrSyntax
return
return value, multibyte, tail, err
}
value = v
multibyte = true
@@ -199,20 +199,20 @@ func unquoteChar(s string, quote byte) (value rune, multibyte bool, tail string,
v := rune(c) - '0'
if len(s) < 2 {
err = ErrSyntax
return
return value, multibyte, tail, err
}
for j := range 2 { // One digit already; two more.
x := rune(s[j]) - '0'
if x < 0 || x > 7 {
err = ErrSyntax
return
return value, multibyte, tail, err
}
v = (v << 3) | x
}
s = s[2:]
if v > 255 {
err = ErrSyntax
return
return value, multibyte, tail, err
}
value = v
case '\\':
@@ -220,15 +220,15 @@ func unquoteChar(s string, quote byte) (value rune, multibyte bool, tail string,
case '\'', '"':
if c != quote {
err = ErrSyntax
return
return value, multibyte, tail, err
}
value = rune(c)
default:
err = ErrSyntax
return
return value, multibyte, tail, err
}
tail = s
return
return value, multibyte, tail, err
}
// contains reports whether the string contains the byte c.
@@ -251,5 +251,5 @@ func unhex(b byte) (v rune, ok bool) {
case 'A' <= c && c <= 'F':
return c - 'A' + 10, true
}
return
return v, ok
}

View File

@@ -127,7 +127,7 @@ func NewTemporaryDirectory(name string, t T) (handler TemporaryDirectory) {
tester: t,
}
return
return handler
}
// DirHash returns a hash of all files attributes and their content within a directory.

View File

@@ -1,4 +1,4 @@
// Copyright 2022 The Prometheus Authors
// Copyright The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -12,7 +12,6 @@
// limitations under the License.
//go:build builtinassets
// +build builtinassets
package ui