Skip to content

Commit

Permalink
fixlint
Browse files Browse the repository at this point in the history
  • Loading branch information
thampiotr committed May 15, 2024
1 parent 447c27c commit 0bcfb0b
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 24 deletions.
5 changes: 3 additions & 2 deletions internal/alloy/logging/deferred_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"bytes"
"context"
"encoding/json"
"github.com/go-kit/log/level"
"github.com/stretchr/testify/require"
"log/slog"
"strings"
"testing"
"testing/slogtest"

"github.com/go-kit/log/level"
"github.com/stretchr/testify/require"
)

func TestDefferredSlogTester(t *testing.T) {
Expand Down
15 changes: 8 additions & 7 deletions internal/component/mimir/rules/kubernetes/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,15 @@ import (
"errors"
"fmt"
"sync"
"sync/atomic"
"time"

"github.com/go-kit/log"
"github.com/grafana/alloy/internal/alloy/logging/level"
"github.com/grafana/alloy/internal/component"
commonK8s "github.com/grafana/alloy/internal/component/common/kubernetes"
"github.com/grafana/alloy/internal/featuregate"
mimirClient "github.com/grafana/alloy/internal/mimir/client"
"github.com/grafana/alloy/internal/service/cluster"
"github.com/grafana/ckit/shard"
"github.com/grafana/dskit/backoff"
"github.com/grafana/dskit/instrument"
promListers "github.com/prometheus-operator/prometheus-operator/pkg/client/listers/monitoring/v1"
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/atomic"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/informers"
Expand All @@ -29,6 +23,13 @@ import (
_ "k8s.io/component-base/metrics/prometheus/workqueue"
controller "sigs.k8s.io/controller-runtime"

"github.com/grafana/alloy/internal/alloy/logging/level"
"github.com/grafana/alloy/internal/component"
commonK8s "github.com/grafana/alloy/internal/component/common/kubernetes"
"github.com/grafana/alloy/internal/featuregate"
mimirClient "github.com/grafana/alloy/internal/mimir/client"
"github.com/grafana/alloy/internal/service/cluster"

promExternalVersions "github.com/prometheus-operator/prometheus-operator/pkg/client/informers/externalversions"
promVersioned "github.com/prometheus-operator/prometheus-operator/pkg/client/versioned"
)
Expand Down
9 changes: 5 additions & 4 deletions internal/component/mimir/rules/kubernetes/rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ import (
"errors"
"fmt"
"sync"
"sync/atomic"
"testing"
"time"

"github.com/go-kit/log"
"github.com/grafana/alloy/internal/component"
"github.com/grafana/alloy/internal/service/cluster"
"github.com/grafana/alloy/syntax"
"github.com/grafana/ckit/peer"
"github.com/grafana/ckit/shard"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/require"
"go.uber.org/atomic"

"github.com/grafana/alloy/internal/component"
"github.com/grafana/alloy/internal/service/cluster"
"github.com/grafana/alloy/syntax"
)

func TestAlloyConfig(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/histogram"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/model/value"
"github.com/prometheus/prometheus/scrape"
Expand Down Expand Up @@ -42,7 +43,7 @@ var mc = testMetadataStore{
},
"counter_created": scrape.MetricMetadata{
Metric: "counter",
Type: textparse.MetricTypeCounter,
Type: model.MetricTypeCounter,
Help: "This is some help for a counter",
Unit: "By",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ func (a *initialPointAdjuster) adjustMetricHistogram(tsm *timeseriesMap, current
if a.useCreatedMetric &&
!currentDist.Flags().NoRecordedValue() &&
currentDist.StartTimestamp() < currentDist.Timestamp() {

continue
}

Expand Down Expand Up @@ -370,6 +371,7 @@ func (a *initialPointAdjuster) adjustMetricExponentialHistogram(tsm *timeseriesM
if a.useCreatedMetric &&
!currentDist.Flags().NoRecordedValue() &&
currentDist.StartTimestamp() < currentDist.Timestamp() {

continue
}

Expand Down Expand Up @@ -412,6 +414,7 @@ func (a *initialPointAdjuster) adjustMetricSum(tsm *timeseriesMap, current pmetr
if a.useCreatedMetric &&
!currentSum.Flags().NoRecordedValue() &&
currentSum.StartTimestamp() < currentSum.Timestamp() {

continue
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,6 @@ func TestMetricBuilderSummary(t *testing.T) {
})
}
}

}

func TestMetricBuilderNativeHistogram(t *testing.T) {
Expand Down Expand Up @@ -1885,5 +1884,4 @@ func assertEquivalentMetrics(t *testing.T, want, got pmetric.Metrics) {
assert.EqualValues(t, wmap, gmap)
}
}

}
10 changes: 4 additions & 6 deletions internal/component/prometheus/scrape/scrape_clustering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ var testCases = []testCase{
}

func TestDetectingMovedTargets(t *testing.T) {
for _, tc := range testCases {
for i := range testCases {
tc := testCases[i]
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
alloyMetricsReg := client.NewRegistry()
Expand All @@ -150,7 +151,7 @@ func TestDetectingMovedTargets(t *testing.T) {
promManagerMutex.Lock()
s, err := New(opts, args)
promManagerMutex.Unlock()

require.NoError(t, err)
ctx, cancelRun := context.WithTimeout(context.Background(), testTimeout)
runErr := make(chan error)
Expand Down Expand Up @@ -178,10 +179,7 @@ func TestDetectingMovedTargets(t *testing.T) {
waitForStalenessInjections(t, appender, tc.expectedStalenessInjections)

cancelRun()
select {
case err := <-runErr:
require.NoError(t, err)
}
require.NoError(t, <-runErr)
})
}
}
Expand Down
3 changes: 1 addition & 2 deletions internal/static/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ package logs
import (
_ "time/tzdata" // embed timezone data


_ "github.com/grafana/alloy/internal/util/otelfeaturegatefix" // Gracefully handle duplicate OTEL feature gates
"github.com/grafana/loki/v3/clients/pkg/promtail/client"
"github.com/grafana/loki/v3/clients/pkg/promtail/config"
"github.com/grafana/loki/v3/clients/pkg/promtail/server"
"github.com/grafana/loki/v3/clients/pkg/promtail/wal"
"github.com/grafana/loki/v3/pkg/tracing"

"github.com/grafana/alloy/internal/useragent"
_ "github.com/grafana/alloy/internal/util/otelfeaturegatefix" // Gracefully handle duplicate OTEL feature gates
)

func init() {
Expand Down

0 comments on commit 0bcfb0b

Please sign in to comment.