Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run gofumpt -w on all go files and integrate with CI #2584

Merged
merged 6 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* [CHANGE] Make vParquet2 the default block format [#2526](https://github.com/grafana/tempo/pull/2526) (@stoewer)
* [CHANGE] Disable tempo-query by default in Jsonnet libs. [#2462](https://github.com/grafana/tempo/pull/2462) (@electron0zero)
* [CHANGE] Integrate `gofumpt` into CI for formatting requirements [2584](https://github.com/grafana/tempo/pull/2584) (@zalegrala)
* [FEATURE] New experimental API to derive on-demand RED metrics grouped by any attribute, and new metrics generator processor [#2368](https://github.com/grafana/tempo/pull/2368) [#2418](https://github.com/grafana/tempo/pull/2418) [#2424](https://github.com/grafana/tempo/pull/2424) [#2442](https://github.com/grafana/tempo/pull/2442) [#2480](https://github.com/grafana/tempo/pull/2480) [#2481](https://github.com/grafana/tempo/pull/2481) [#2501](https://github.com/grafana/tempo/pull/2501) [#2579](https://github.com/grafana/tempo/pull/2579) [#2582](https://github.com/grafana/tempo/pull/2582) (@mdisibio @zalegrala)
* [FEATURE] New TraceQL structural operators descendant (>>), child (>), and sibling (~) [#2625](https://github.com/grafana/tempo/pull/2625) [#2660](https://github.com/grafana/tempo/pull/2660) (@mdisibio)
* [FEATURE] Add user-configurable overrides module [#2543](https://github.com/grafana/tempo/pull/2543) (@electron0zero @kvrhdn)
Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Before submitting please run the following to verify that all dependencies and p
make vendor-check
```

Additionally, this project uses `gofumpt` for code formatting. Contributors may wish to configure editors based on the [gofumpt documentation](https://github.com/mvdan/gofumpt), or alternatively run `make fmt` before committing changes for submission.

# Project structure

```
Expand Down Expand Up @@ -176,4 +178,4 @@ and try again.
Tempo uses a CI action to sync documentation to the [Grafana website](https://grafana.com/docs/tempo/latest). The CI is
triggered on every merge to main in the `docs` subfolder.

The `helm-charts` folder is published from Tempo's next branch. The Tempo documentation is published from the `latest` branch.
The `helm-charts` folder is published from Tempo's next branch. The Tempo documentation is published from the `latest` branch.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ test-bench: tools docker-tempo
$(GOTEST) -v $(GOTEST_OPT) ./integration/bench

.PHONY: fmt check-fmt
fmt:
@gofmt -s -w $(FILES_TO_FMT)
fmt: tools
@gofumpt -w $(FILES_TO_FMT)
@goimports -w $(FILES_TO_FMT)

check-fmt: fmt
Expand Down
2 changes: 1 addition & 1 deletion cmd/tempo-cli/cmd-gen-bloom.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type forEachRecord func(id common.ID) error

func ReplayBlockAndDoForEachRecord(meta *backend.BlockMeta, filepath string, forEach forEachRecord) error {
// replay file to extract records
f, err := os.OpenFile(filepath, os.O_RDONLY, 0644)
f, err := os.OpenFile(filepath, os.O_RDONLY, 0o644)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/tempo-cli/cmd-gen-index.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type indexCmd struct {
func ReplayBlockAndGetRecords(meta *backend.BlockMeta, filepath string) ([]v2.Record, error, error) {
var replayError error
// replay file to extract records
f, err := os.OpenFile(filepath, os.O_RDONLY, 0644)
f, err := os.OpenFile(filepath, os.O_RDONLY, 0o644)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -151,7 +151,7 @@ func (cmd *indexCmd) Run(ctx *globalOptions) error {

// get index file with records
indexFilePath := cmd.backendOptions.Bucket + cmd.TenantID + "/" + cmd.BlockID + "/" + indexFilename
indexFile, err := os.OpenFile(indexFilePath, os.O_RDONLY, 0644)
indexFile, err := os.OpenFile(indexFilePath, os.O_RDONLY, 0o644)
if err != nil {
fmt.Println("error opening index file")
return err
Expand All @@ -165,7 +165,7 @@ func (cmd *indexCmd) Run(ctx *globalOptions) error {

// data reader
dataFilePath := cmd.backendOptions.Bucket + cmd.TenantID + "/" + cmd.BlockID + "/" + dataFilename
dataFile, err := os.OpenFile(dataFilePath, os.O_RDONLY, 0644)
dataFile, err := os.OpenFile(dataFilePath, os.O_RDONLY, 0o644)
if err != nil {
fmt.Println("error opening data file")
return err
Expand Down
3 changes: 3 additions & 0 deletions cmd/tempo-cli/cmd-list-block.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func printKVPairs(kvp kvPairs) {
func relativeValue(v values) float64 {
return (float64(v.count) * float64(v.count)) / float64(len(v.all))
}

func extractKVPairs(t *tempopb.Trace) kvPairs {
kvp := kvPairs{}
for _, b := range t.Batches {
Expand Down Expand Up @@ -228,6 +229,7 @@ func extractKVPairs(t *tempopb.Trace) kvPairs {
}
return kvp
}

func addKey(kvp kvPairs, key string, count int) {
v, ok := kvp[key]
if !ok {
Expand All @@ -239,6 +241,7 @@ func addKey(kvp kvPairs, key string, count int) {
v.count += count
kvp[key] = v
}

func addVal(kvp kvPairs, key string, val string, count int) {
v := kvp[key]
stats, ok := v.all[val]
Expand Down
1 change: 0 additions & 1 deletion cmd/tempo-cli/cmd-list-blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func (l *listBlocksCmd) Run(ctx *globalOptions) error {
}

func displayResults(results []blockStats, windowDuration time.Duration, includeCompacted bool) {

columns := []string{"id", "lvl", "objects", "size", "encoding", "vers", "window", "start", "end", "duration", "age"}
if includeCompacted {
columns = append(columns, "cmp")
Expand Down
3 changes: 0 additions & 3 deletions cmd/tempo-query/tempo/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func createHTTPClient(cfg *Config) (*http.Client, error) {
}
transport := &http.Transport{TLSClientConfig: config}
return &http.Client{Transport: transport}, nil

}

func mapCipherNamesToIDs(cipherSuiteNames []string) ([]uint16, error) {
Expand Down Expand Up @@ -165,7 +164,6 @@ func (b *Backend) apiSchema() string {
}

func (b *Backend) GetTrace(ctx context.Context, traceID jaeger.TraceID) (*jaeger.Trace, error) {

url := fmt.Sprintf("%s://%s/api/traces/%s", b.apiSchema(), b.tempoBackend, traceID)

span, ctx := opentracing.StartSpanFromContext(ctx, "tempo-query.GetTrace")
Expand Down Expand Up @@ -255,7 +253,6 @@ func (b *Backend) GetOperations(ctx context.Context, _ jaeger_spanstore.Operatio
}

return operations, nil

}

func (b *Backend) FindTraces(ctx context.Context, query *jaeger_spanstore.TraceQueryParameters) ([]*jaeger.Trace, error) {
Expand Down
3 changes: 2 additions & 1 deletion cmd/tempo-serverless/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ func stringToFlagExt() mapstructure.DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
data interface{},
) (interface{}, error) {
if f.Kind() != reflect.String {
return data, nil
}
Expand Down
2 changes: 0 additions & 2 deletions cmd/tempo-vulture/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ func searchTag(client *httpclient.Client, seed time.Time) (traceMetrics, error)
start := seed.Add(-30 * time.Minute).Unix()
end := seed.Add(30 * time.Minute).Unix()
resp, err := client.SearchWithRange(fmt.Sprintf("%s=%s", attr.Key, util.StringifyAnyValue(attr.Value)), start, end)

if err != nil {
logger.Error(fmt.Sprintf("failed to search traces with tag %s: %s", attr.Key, err.Error()))
tm.requestFailed++
Expand Down Expand Up @@ -438,7 +437,6 @@ func searchTraceql(client *httpclient.Client, seed time.Time) (traceMetrics, err
start := seed.Add(-30 * time.Minute).Unix()
end := seed.Add(30 * time.Minute).Unix()
resp, err := client.SearchTraceQLWithRange(fmt.Sprintf(`{span.%s = "%s"}`, attr.Key, util.StringifyAnyValue(attr.Value)), start, end)

if err != nil {
logger.Error(fmt.Sprintf("failed to search traces with traceql %s: %s", attr.Key, err.Error()))
tm.requestFailed++
Expand Down
6 changes: 4 additions & 2 deletions cmd/tempo/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ import (
"github.com/grafana/tempo/pkg/util/log"
)

const metricsNamespace = "tempo"
const apiDocs = "https://grafana.com/docs/tempo/latest/api_docs/"
const (
metricsNamespace = "tempo"
apiDocs = "https://grafana.com/docs/tempo/latest/api_docs/"
)

var (
metricConfigFeatDesc = prometheus.NewDesc(
Expand Down
1 change: 0 additions & 1 deletion cmd/tempo/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ func (c *Config) Describe(ch chan<- *prometheus.Desc) {
}

func (c *Config) Collect(ch chan<- prometheus.Metric) {

features := map[string]int{
"search_external_endpoints": 0,
}
Expand Down
1 change: 0 additions & 1 deletion integration/e2e/compression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func TestCompression(t *testing.T) {
}

func queryAndAssertTraceCompression(t *testing.T, client *httpclient.Client, info *tempoUtil.TraceInfo) {

// The received client will strip the header before we have a chance to inspect it, so just validate that the compressed client works as expected.
result, err := client.QueryTrace(info.HexID())
require.NoError(t, err)
Expand Down
3 changes: 0 additions & 3 deletions integration/e2e/query_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func TestSearchUsingJaegerPlugin(t *testing.T) {
}

func callJaegerQuerySearchServicesAssert(t *testing.T, svc *e2e.HTTPService, expected servicesOrOpJaegerQueryResponse) {

// search for tag values
req, err := http.NewRequest(http.MethodGet, "http://"+svc.Endpoint(16686)+"/api/services", nil)
require.NoError(t, err)
Expand All @@ -97,7 +96,6 @@ func callJaegerQuerySearchServicesAssert(t *testing.T, svc *e2e.HTTPService, exp
}

func callJaegerQuerySearchOperationAssert(t *testing.T, svc *e2e.HTTPService, operation string, expected servicesOrOpJaegerQueryResponse) {

apiURL := fmt.Sprintf("/api/services/%s/operations", operation)

// search for tag values
Expand All @@ -122,7 +120,6 @@ func callJaegerQuerySearchOperationAssert(t *testing.T, svc *e2e.HTTPService, op
}

func callJaegerQuerySearchTraceAssert(t *testing.T, svc *e2e.HTTPService, operation, service string) {

start := time.Now().Add(-10 * time.Minute)
end := start.Add(1 * time.Hour)

Expand Down
3 changes: 0 additions & 3 deletions integration/e2e/serverless/serverless_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const (
)

func TestServerless(t *testing.T) {

testClouds := []struct {
name string
serverless *e2e.HTTPService
Expand Down Expand Up @@ -119,10 +118,8 @@ func TestServerless(t *testing.T) {
// search the backend. this works b/c we're passing a start/end AND setting query ingesters within min/max to 0
now := time.Now()
util.SearchAndAssertTraceBackend(t, apiClient, info, now.Add(-20*time.Minute).Unix(), now.Unix())

})
}

}

func newTempoServerlessGCR() *e2e.HTTPService {
Expand Down
4 changes: 1 addition & 3 deletions modules/compactor/compactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ const (
reasonCompactorDiscardedSpans = "trace_too_large_to_compact"
)

var (
ringOp = ring.NewOp([]ring.InstanceState{ring.ACTIVE}, nil)
)
var ringOp = ring.NewOp([]ring.InstanceState{ring.ACTIVE}, nil)

type Compactor struct {
services.Service
Expand Down
Loading