Skip to content

Commit

Permalink
use slices and map from the go stdlib instead of golang.org/x/exp
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Strobusch <1847260+dastrobu@users.noreply.github.com>
  • Loading branch information
dastrobu committed Oct 2, 2024
1 parent 5592aa7 commit 5154c2b
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 17 deletions.
3 changes: 1 addition & 2 deletions cmd/tempo/app/overrides_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package app

import (
"fmt"
"slices"
"time"

"golang.org/x/exp/slices"

"github.com/grafana/tempo/modules/generator"
"github.com/grafana/tempo/modules/generator/registry"
"github.com/grafana/tempo/modules/overrides"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0
go.opentelemetry.io/proto/otlp v1.3.1
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
golang.org/x/net v0.27.0
golang.org/x/oauth2 v0.21.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20240708141625-4ad9e859172b
Expand Down Expand Up @@ -320,6 +319,7 @@ require (
go.opentelemetry.io/otel/sdk/log v0.4.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
Expand Down
5 changes: 2 additions & 3 deletions modules/distributor/distributor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import (
"encoding/json"
"flag"
"fmt"
"maps"
"math/rand"
"strconv"
"strings"
"testing"
"time"

"golang.org/x/exp/maps"

kitlog "github.com/go-kit/log"
"github.com/gogo/status"
"github.com/golang/protobuf/proto" // nolint: all //ProtoReflect
Expand Down Expand Up @@ -1150,7 +1149,7 @@ func TestLogDiscardedSpansWhenPushToIngesterFails(t *testing.T) {
}

// mock ingester errors
for _, ingester := range maps.Values(ingesters) {
for ingester := range maps.Values(ingesters) {
ingester.pushBytesV2 = func(_ context.Context, _ *tempopb.PushBytesRequest, _ ...grpc.CallOption) (*tempopb.PushResponse, error) {
return &tempopb.PushResponse{
ErrorsByTrace: tc.pushErrorByTrace,
Expand Down
2 changes: 1 addition & 1 deletion modules/distributor/forwarder/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package forwarder

import (
"context"
"slices"
"testing"

"github.com/go-kit/log"
dslog "github.com/grafana/dskit/log"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/pdata/ptrace"
"golang.org/x/exp/slices"
)

type mockWorkingOverrides struct {
Expand Down
2 changes: 1 addition & 1 deletion modules/generator/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package generator
import (
"context"
"fmt"
"maps"
"reflect"
"strings"
"sync"
Expand All @@ -13,7 +14,6 @@ import (
"github.com/grafana/tempo/tempodb"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"golang.org/x/exp/maps"

"github.com/grafana/tempo/modules/generator/processor"
"github.com/grafana/tempo/modules/generator/processor/localblocks"
Expand Down
2 changes: 1 addition & 1 deletion modules/overrides/overrides_tenant_status_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"fmt"
"html/template"
"net/http"
"slices"
"time"

"github.com/gorilla/mux"
"golang.org/x/exp/slices"
"gopkg.in/yaml.v2"

"github.com/grafana/tempo/pkg/util"
Expand Down
6 changes: 3 additions & 3 deletions modules/overrides/overrides_tenants_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package overrides
import (
_ "embed" // Used to embed html templates
"html/template"
"maps"
"net/http"
"slices"
"sort"
"strings"
"time"

"golang.org/x/exp/maps"

"github.com/grafana/tempo/pkg/util"
)

Expand Down Expand Up @@ -63,7 +63,7 @@ func TenantsHandler(o Interface) http.HandlerFunc {
}
}

tenantsList := maps.Values(tenants)
tenantsList := slices.Collect(maps.Values(tenants))
sortTenantsPageTenant(tenantsList)

util.RenderHTTPResponse(w, tenantsPageContents{
Expand Down
5 changes: 3 additions & 2 deletions modules/overrides/runtime_config_overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"context"
"fmt"
"io"
"maps"
"net/http"
"slices"
"time"

"github.com/drone/envsubst"
"github.com/go-kit/log/level"
"golang.org/x/exp/maps"

"github.com/grafana/dskit/runtimeconfig"
"github.com/grafana/dskit/services"
Expand Down Expand Up @@ -277,7 +278,7 @@ func (o *runtimeConfigOverridesManager) GetTenantIDs() []string {
return nil
}

return maps.Keys(tenantOverrides.TenantLimits)
return slices.Collect(maps.Keys(tenantOverrides.TenantLimits))
}

func (o *runtimeConfigOverridesManager) GetRuntimeOverridesFor(userID string) *Overrides {
Expand Down
6 changes: 3 additions & 3 deletions modules/overrides/user_configurable_overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
"flag"
"fmt"
"io"
"maps"
"net/http"
"slices"
"sync"
"time"

Expand All @@ -15,8 +17,6 @@ import (
"github.com/grafana/dskit/services"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"gopkg.in/yaml.v2"

userconfigurableoverrides "github.com/grafana/tempo/modules/overrides/userconfigurable/client"
Expand Down Expand Up @@ -212,7 +212,7 @@ func (o *userConfigurableOverridesManager) setTenantLimit(userID string, limits
}

func (o *userConfigurableOverridesManager) GetTenantIDs() []string {
return maps.Keys(o.getAllTenantLimits())
return slices.Collect(maps.Keys(o.getAllTenantLimits()))
}

func (o *userConfigurableOverridesManager) Forwarders(userID string) []string {
Expand Down

0 comments on commit 5154c2b

Please sign in to comment.