Add goimport local-prefixes configuration to .golangci.yml (#1710)

pull/1717/head
Aditya C S 5 years ago committed by GitHub
parent 45d40a5c00
commit f9ff2a4b02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      .golangci.yml
  2. 22
      CONTRIBUTING.md
  3. 2
      cmd/chunks-inspect/main.go
  4. 3
      cmd/docker-driver/config.go
  5. 5
      cmd/docker-driver/loki.go
  6. 3
      cmd/docker-driver/main.go
  7. 5
      cmd/fluent-bit/config.go
  8. 3
      cmd/fluent-bit/config_test.go
  9. 3
      cmd/fluent-bit/loki.go
  10. 3
      cmd/fluent-bit/out_loki.go
  11. 5
      cmd/logcli/main.go
  12. 8
      cmd/loki/main.go
  13. 5
      pkg/canary/reader/reader.go
  14. 1
      pkg/chunkenc/lazy_chunk.go
  15. 3
      pkg/chunkenc/memchunk_test.go
  16. 1
      pkg/distributor/ingestion_rate_strategy.go
  17. 3
      pkg/distributor/ingestion_rate_strategy_test.go
  18. 3
      pkg/distributor/validator.go
  19. 5
      pkg/ingester/chunk_test.go
  20. 3
      pkg/ingester/client/client.go
  21. 1
      pkg/ingester/flush.go
  22. 3
      pkg/ingester/instance_test.go
  23. 3
      pkg/ingester/limiter_test.go
  24. 5
      pkg/ingester/stream_test.go
  25. 5
      pkg/ingester/tailer.go
  26. 3
      pkg/ingester/tailer_test.go
  27. 5
      pkg/ingester/transfer.go
  28. 3
      pkg/ingester/transfer_test.go
  29. 3
      pkg/iter/iterator_test.go
  30. 5
      pkg/logcli/client/client.go
  31. 1
      pkg/logcli/output/default.go
  32. 3
      pkg/logcli/output/default_test.go
  33. 3
      pkg/logcli/output/jsonl_test.go
  34. 3
      pkg/logcli/output/raw_test.go
  35. 5
      pkg/logcli/query/query.go
  36. 1
      pkg/logcli/query/tail.go
  37. 3
      pkg/logentry/stages/tenant.go
  38. 5
      pkg/logentry/stages/tenant_test.go
  39. 3
      pkg/logentry/stages/timestamp.go
  40. 3
      pkg/logentry/stages/timestamp_test.go
  41. 1
      pkg/loghttp/labels.go
  42. 3
      pkg/loghttp/labels_test.go
  43. 3
      pkg/loghttp/params_test.go
  44. 5
      pkg/loghttp/query.go
  45. 3
      pkg/loghttp/query_test.go
  46. 3
      pkg/loghttp/series_test.go
  47. 3
      pkg/loghttp/tail.go
  48. 3
      pkg/loghttp/tail_test.go
  49. 5
      pkg/logql/ast.go
  50. 9
      pkg/logql/engine.go
  51. 7
      pkg/logql/engine_test.go
  52. 5
      pkg/logql/evaluator.go
  53. 9
      pkg/logql/expr.y.go
  54. 3
      pkg/logql/marshal/labels.go
  55. 3
      pkg/logql/marshal/legacy/marshal.go
  56. 5
      pkg/logql/marshal/legacy/marshal_test.go
  57. 3
      pkg/logql/marshal/marshal.go
  58. 9
      pkg/logql/marshal/marshal_test.go
  59. 7
      pkg/logql/marshal/query.go
  60. 3
      pkg/logql/metrics.go
  61. 3
      pkg/logql/range_vector.go
  62. 5
      pkg/logql/range_vector_test.go
  63. 3
      pkg/logql/stats/grpc_test.go
  64. 3
      pkg/logql/unmarshal/legacy/unmarshal.go
  65. 3
      pkg/logql/unmarshal/legacy/unmarshal_test.go
  66. 3
      pkg/logql/unmarshal/unmarshal.go
  67. 3
      pkg/logql/unmarshal/unmarshal_test.go
  68. 1
      pkg/promtail/client/batch.go
  69. 3
      pkg/promtail/client/batch_test.go
  70. 5
      pkg/promtail/client/client.go
  71. 5
      pkg/promtail/client/client_test.go
  72. 3
      pkg/promtail/client/config.go
  73. 3
      pkg/promtail/client/fake/client.go
  74. 3
      pkg/promtail/client/multi.go
  75. 3
      pkg/promtail/client/multi_test.go
  76. 3
      pkg/promtail/server/template.go
  77. 3
      pkg/promtail/server/ui/assets_generate.go
  78. 4
      pkg/promtail/targets/journaltarget.go
  79. 3
      pkg/promtail/targets/journaltarget_test.go
  80. 1
      pkg/promtail/targets/journaltargetmanager.go
  81. 3
      pkg/promtail/targets/journaltargetmanager_linux.go
  82. 7
      pkg/promtail/targets/stdin_target_manager.go
  83. 5
      pkg/promtail/targets/stdin_target_manager_test.go
  84. 3
      pkg/promtail/targets/syslogparser/syslogparser_test.go
  85. 11
      pkg/querier/querier_mock_test.go
  86. 9
      pkg/querier/queryrange/codec.go
  87. 3
      pkg/querier/queryrange/codec_test.go
  88. 3
      pkg/querier/queryrange/prometheus.go
  89. 3
      pkg/querier/queryrange/roundtrip.go
  90. 7
      pkg/querier/queryrange/roundtrip_test.go
  91. 3
      pkg/querier/queryrange/split_by_interval.go
  92. 5
      pkg/querier/queryrange/split_by_interval_test.go
  93. 1
      pkg/querier/queryrange/stats.go
  94. 3
      pkg/querier/queryrange/stats_test.go
  95. 3
      pkg/querier/tail.go
  96. 5
      pkg/querier/tail_test.go
  97. 5
      pkg/storage/iterator_test.go
  98. 7
      pkg/storage/util_test.go
  99. 3
      pkg/util/conv.go

@ -40,6 +40,10 @@ output:
# print linter name in the end of issue text, default is true
print-linter-name: true
linters-settings:
goimports:
local-prefixes: github.com/grafana/loki/pkg
linters:
enable:
- deadcode

@ -25,7 +25,7 @@ Please follow the [Loki Helm Chart](./production/helm/README.md).
### Dependency management
We uses [Go modules](https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more) to manage dependencies on external packages.
We use [Go modules](https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more) to manage dependencies on external packages.
This requires a working Go environment with version 1.13 or greater and git installed.
To add or update a new dependency, use the `go get` command:
@ -48,3 +48,23 @@ git commit
```
You have to commit the changes to `go.mod` and `go.sum` before submitting the pull request.
## Coding Standards
### go imports
imports should follow `std libs`, `externals libs` and `local packages` format
Example
```
import (
"fmt"
"math"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
)
```

@ -80,7 +80,7 @@ func printFile(filename string, blockDetails, printLines, storeBlocks bool) {
}
if len(lokiChunk.blocks) > 0 {
fmt.Println("Minimum time (from first block):", time.Unix(0, lokiChunk.blocks[0].minT).In(timezone).Format(format))
fmt.Println("Maximum time (from last block):", time.Unix(0, lokiChunk.blocks[len(lokiChunk.blocks) - 1].maxT).In(timezone).Format(format))
fmt.Println("Maximum time (from last block):", time.Unix(0, lokiChunk.blocks[len(lokiChunk.blocks)-1].maxT).In(timezone).Format(format))
}
if blockDetails {

@ -13,11 +13,12 @@ import (
"github.com/cortexproject/cortex/pkg/util/flagext"
"github.com/docker/docker/daemon/logger"
"github.com/docker/docker/daemon/logger/templates"
"github.com/prometheus/common/model"
"github.com/grafana/loki/pkg/helpers"
"github.com/grafana/loki/pkg/logentry/stages"
"github.com/grafana/loki/pkg/promtail/client"
"github.com/grafana/loki/pkg/promtail/targets"
"github.com/prometheus/common/model"
)
const (

@ -6,11 +6,12 @@ import (
"github.com/docker/docker/daemon/logger"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/grafana/loki/pkg/logentry/stages"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/grafana/loki/pkg/promtail/client"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
)
var jobName = "docker"

@ -8,9 +8,10 @@ import (
"github.com/docker/go-plugins-helpers/sdk"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
_ "github.com/grafana/loki/pkg/build"
"github.com/prometheus/common/version"
"github.com/weaveworks/common/logging"
_ "github.com/grafana/loki/pkg/build"
)
const socketAddress = "/run/docker/plugins/loki.sock"

@ -10,11 +10,12 @@ import (
"time"
"github.com/cortexproject/cortex/pkg/util/flagext"
"github.com/prometheus/common/model"
"github.com/weaveworks/common/logging"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/promtail/client"
lokiflag "github.com/grafana/loki/pkg/util/flagext"
"github.com/prometheus/common/model"
"github.com/weaveworks/common/logging"
)
var defaultClientCfg = client.Config{}

@ -11,9 +11,10 @@ import (
"github.com/prometheus/common/model"
"github.com/cortexproject/cortex/pkg/util/flagext"
"github.com/weaveworks/common/logging"
"github.com/grafana/loki/pkg/promtail/client"
lokiflag "github.com/grafana/loki/pkg/util/flagext"
"github.com/weaveworks/common/logging"
)
type fakeConfig map[string]string

@ -10,10 +10,11 @@ import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/grafana/loki/pkg/promtail/client"
jsoniter "github.com/json-iterator/go"
"github.com/prometheus/common/model"
"github.com/weaveworks/common/logging"
"github.com/grafana/loki/pkg/promtail/client"
)
type loki struct {

@ -9,9 +9,10 @@ import (
"github.com/fluent/fluent-bit-go/output"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
_ "github.com/grafana/loki/pkg/build"
"github.com/prometheus/common/version"
"github.com/weaveworks/common/logging"
_ "github.com/grafana/loki/pkg/build"
)
var (

@ -6,13 +6,14 @@ import (
"os"
"time"
"github.com/prometheus/common/config"
"github.com/prometheus/common/version"
_ "github.com/grafana/loki/pkg/build"
"github.com/grafana/loki/pkg/logcli/client"
"github.com/grafana/loki/pkg/logcli/labelquery"
"github.com/grafana/loki/pkg/logcli/output"
"github.com/grafana/loki/pkg/logcli/query"
"github.com/prometheus/common/config"
"github.com/prometheus/common/version"
"gopkg.in/alecthomas/kingpin.v2"
)

@ -7,15 +7,17 @@ import (
"reflect"
"github.com/go-kit/kit/log/level"
_ "github.com/grafana/loki/pkg/build"
"github.com/grafana/loki/pkg/cfg"
"github.com/grafana/loki/pkg/loki"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/version"
"github.com/weaveworks/common/logging"
"github.com/weaveworks/common/tracing"
_ "github.com/grafana/loki/pkg/build"
"github.com/grafana/loki/pkg/cfg"
"github.com/grafana/loki/pkg/loki"
"github.com/cortexproject/cortex/pkg/util"
"github.com/grafana/loki/pkg/util/validation"
)

@ -13,12 +13,13 @@ import (
"time"
"github.com/gorilla/websocket"
loghttp "github.com/grafana/loki/pkg/loghttp/legacy"
"github.com/grafana/loki/pkg/logproto"
json "github.com/json-iterator/go"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
loghttp "github.com/grafana/loki/pkg/loghttp/legacy"
"github.com/grafana/loki/pkg/logproto"
)
var (

@ -6,6 +6,7 @@ import (
"time"
"github.com/cortexproject/cortex/pkg/chunk"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"

@ -12,10 +12,11 @@ import (
"github.com/stretchr/testify/assert"
"github.com/dustin/go-humanize"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/chunkenc/testdata"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/stretchr/testify/require"
)
var testEncoding = []Encoding{

@ -2,6 +2,7 @@ package distributor
import (
"github.com/cortexproject/cortex/pkg/util/limiter"
"github.com/grafana/loki/pkg/util/validation"
)

@ -4,10 +4,11 @@ import (
"testing"
"github.com/cortexproject/cortex/pkg/util/limiter"
"github.com/grafana/loki/pkg/util/validation"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/util/validation"
)
const (

@ -7,10 +7,11 @@ import (
cortex_client "github.com/cortexproject/cortex/pkg/ingester/client"
cortex_validation "github.com/cortexproject/cortex/pkg/util/validation"
"github.com/weaveworks/common/httpgrpc"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/util"
"github.com/grafana/loki/pkg/util/flagext"
"github.com/weaveworks/common/httpgrpc"
)
type Validator struct {

@ -7,11 +7,12 @@ import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/chunkenc"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func testIteratorForward(t *testing.T, iter iter.EntryIterator, from, through int64) {

@ -7,12 +7,13 @@ import (
cortex_client "github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/cortexproject/cortex/pkg/util/grpcclient"
"github.com/grafana/loki/pkg/logproto"
"github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc"
opentracing "github.com/opentracing/opentracing-go"
"github.com/weaveworks/common/middleware"
"google.golang.org/grpc"
"google.golang.org/grpc/health/grpc_health_v1"
"github.com/grafana/loki/pkg/logproto"
)
// Config for an ingester client.

@ -16,6 +16,7 @@ import (
"github.com/cortexproject/cortex/pkg/chunk"
"github.com/cortexproject/cortex/pkg/util"
"github.com/grafana/loki/pkg/chunkenc"
loki_util "github.com/grafana/loki/pkg/util"
)

@ -8,9 +8,10 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/util"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/grafana/loki/pkg/util"
"github.com/grafana/loki/pkg/chunkenc"
"github.com/grafana/loki/pkg/logproto"

@ -5,9 +5,10 @@ import (
"math"
"testing"
"github.com/grafana/loki/pkg/util/validation"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/util/validation"
)
func TestLimiter_maxStreamsPerUser(t *testing.T) {

@ -9,12 +9,13 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/chunkenc"
"github.com/grafana/loki/pkg/logproto"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/httpgrpc"
"github.com/grafana/loki/pkg/chunkenc"
"github.com/grafana/loki/pkg/logproto"
)
func TestMaxReturnedStreamsErrors(t *testing.T) {

@ -8,11 +8,12 @@ import (
cortex_util "github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/util"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
)
const bufferSizeForTailResponse = 5

@ -6,9 +6,10 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/logproto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/logproto"
)
func TestTailer_sendRaceConditionOnSendWhileClosing(t *testing.T) {

@ -10,13 +10,14 @@ import (
"github.com/cortexproject/cortex/pkg/ring"
"github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/kit/log/level"
"github.com/grafana/loki/pkg/helpers"
"github.com/grafana/loki/pkg/logproto"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/weaveworks/common/user"
"golang.org/x/net/context"
"github.com/grafana/loki/pkg/helpers"
"github.com/grafana/loki/pkg/logproto"
)
var (

@ -18,9 +18,10 @@ import (
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/user"
"golang.org/x/net/context"
"github.com/grafana/loki/pkg/ingester/client"
"github.com/grafana/loki/pkg/logproto"
"golang.org/x/net/context"
)
func TestTransferOut(t *testing.T) {

@ -9,8 +9,9 @@ import (
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/logproto"
"github.com/stretchr/testify/assert"
"github.com/grafana/loki/pkg/logproto"
)
const testSize = 10

@ -11,11 +11,12 @@ import (
"time"
"github.com/gorilla/websocket"
json "github.com/json-iterator/go"
"github.com/prometheus/common/config"
"github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/util"
json "github.com/json-iterator/go"
"github.com/prometheus/common/config"
)
const (

@ -6,6 +6,7 @@ import (
"time"
"github.com/fatih/color"
"github.com/grafana/loki/pkg/loghttp"
)

@ -5,8 +5,9 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/loghttp"
"github.com/stretchr/testify/assert"
"github.com/grafana/loki/pkg/loghttp"
)
func TestDefaultOutput_Format(t *testing.T) {

@ -5,8 +5,9 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/loghttp"
"github.com/stretchr/testify/assert"
"github.com/grafana/loki/pkg/loghttp"
)
func TestJSONLOutput_Format(t *testing.T) {

@ -4,8 +4,9 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/loghttp"
"github.com/stretchr/testify/assert"
"github.com/grafana/loki/pkg/loghttp"
)
func TestRawOutput_Format(t *testing.T) {

@ -10,14 +10,15 @@ import (
"time"
"github.com/fatih/color"
json "github.com/json-iterator/go"
"github.com/prometheus/prometheus/promql"
"github.com/grafana/loki/pkg/logcli/client"
"github.com/grafana/loki/pkg/logcli/output"
"github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/logql/stats"
json "github.com/json-iterator/go"
"github.com/prometheus/prometheus/promql"
)
type streamEntryPair struct {

@ -10,6 +10,7 @@ import (
"github.com/fatih/color"
"github.com/gorilla/websocket"
"github.com/grafana/loki/pkg/logcli/client"
"github.com/grafana/loki/pkg/logcli/output"
"github.com/grafana/loki/pkg/loghttp"

@ -6,10 +6,11 @@ import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/grafana/loki/pkg/promtail/client"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/prometheus/common/model"
"github.com/grafana/loki/pkg/promtail/client"
)
const (

@ -8,12 +8,13 @@ import (
"github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/kit/log"
"github.com/grafana/loki/pkg/promtail/client"
lokiutil "github.com/grafana/loki/pkg/util"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/promtail/client"
lokiutil "github.com/grafana/loki/pkg/util"
)
var testTenantYaml = `

@ -8,10 +8,11 @@ import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/grafana/loki/pkg/util"
lru "github.com/hashicorp/golang-lru"
"github.com/mitchellh/mapstructure"
"github.com/prometheus/common/model"
"github.com/grafana/loki/pkg/util"
)
const (

@ -9,12 +9,13 @@ import (
"github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/kit/log"
lokiutil "github.com/grafana/loki/pkg/util"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
lokiutil "github.com/grafana/loki/pkg/util"
)
var testTimestampYaml = `

@ -7,6 +7,7 @@ import (
"strconv"
"github.com/gorilla/mux"
"github.com/grafana/loki/pkg/logproto"
)

@ -7,8 +7,9 @@ import (
"time"
"github.com/gorilla/mux"
"github.com/grafana/loki/pkg/logproto"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/logproto"
)
func TestParseLabelQuery(t *testing.T) {

@ -6,10 +6,11 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/logproto"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/logproto"
)
func TestHttp_defaultQueryRangeStep(t *testing.T) {

@ -8,10 +8,11 @@ import (
"time"
"unsafe"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql/stats"
json "github.com/json-iterator/go"
"github.com/prometheus/common/model"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql/stats"
)
var (

@ -7,8 +7,9 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/logproto"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/logproto"
)
func TestParseRangeQuery(t *testing.T) {

@ -5,8 +5,9 @@ import (
"net/url"
"testing"
"github.com/grafana/loki/pkg/logproto"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/logproto"
)
func TestParseSeriesQuery(t *testing.T) {

@ -6,8 +6,9 @@ import (
"strconv"
"time"
"github.com/grafana/loki/pkg/logproto"
json "github.com/json-iterator/go"
"github.com/grafana/loki/pkg/logproto"
)
const (

@ -6,8 +6,9 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/logproto"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/logproto"
)
func TestParseTailQuery(t *testing.T) {

@ -9,11 +9,12 @@ import (
"strings"
"time"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
)
// Expr is the root expression which can be a SampleExpr or LogSelectorExpr

@ -8,14 +8,15 @@ import (
"github.com/go-kit/kit/log/level"
"github.com/cortexproject/cortex/pkg/util/spanlogger"
"github.com/grafana/loki/pkg/helpers"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql/stats"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"
"github.com/grafana/loki/pkg/helpers"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql/stats"
)
var (

@ -7,14 +7,15 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql/stats"
json "github.com/json-iterator/go"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql/stats"
)
var testSize = int64(300)

@ -7,11 +7,12 @@ import (
"sort"
"time"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/pkg/errors"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
)
type QueryRangeType string

@ -2,12 +2,11 @@
package logql
import __yyfmt__ "fmt"
import (
"github.com/prometheus/prometheus/pkg/labels"
__yyfmt__ "fmt"
"time"
"github.com/prometheus/prometheus/pkg/labels"
)
type exprSymType struct {
@ -128,7 +127,6 @@ const exprEofCode = 1
const exprErrCode = 2
const exprInitialStackSize = 16
var exprExca = [...]int{
-1, 1,
1, -1,
@ -283,7 +281,6 @@ var exprErrorMessages = [...]struct {
msg string
}{}
/* parser for yacc output */
var (

@ -1,8 +1,9 @@
package marshal
import (
"github.com/grafana/loki/pkg/loghttp"
"github.com/prometheus/prometheus/promql"
"github.com/grafana/loki/pkg/loghttp"
)
// NewLabelSet constructs a Labelset from a promql metric list as a string

@ -7,10 +7,11 @@ import (
"io"
"github.com/gorilla/websocket"
json "github.com/json-iterator/go"
loghttp "github.com/grafana/loki/pkg/loghttp/legacy"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
json "github.com/json-iterator/go"
)
// Note that the below methods directly marshal the values passed in. This is because these objects currently marshal

@ -6,11 +6,12 @@ import (
"testing"
"time"
json "github.com/json-iterator/go"
"github.com/stretchr/testify/require"
loghttp "github.com/grafana/loki/pkg/loghttp/legacy"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
json "github.com/json-iterator/go"
"github.com/stretchr/testify/require"
)
// covers responses from /api/prom/query

@ -8,10 +8,11 @@ import (
"github.com/grafana/loki/pkg/logql"
"github.com/gorilla/websocket"
json "github.com/json-iterator/go"
"github.com/grafana/loki/pkg/loghttp"
legacy "github.com/grafana/loki/pkg/loghttp/legacy"
"github.com/grafana/loki/pkg/logproto"
json "github.com/json-iterator/go"
)
// WriteQueryResponseJSON marshals the promql.Value to v1 loghttp JSON and then

@ -6,14 +6,15 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/loghttp"
legacy "github.com/grafana/loki/pkg/loghttp/legacy"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
json "github.com/json-iterator/go"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/loghttp"
legacy "github.com/grafana/loki/pkg/loghttp/legacy"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
)
// covers responses from /loki/api/v1/query_range and /loki/api/v1/query

@ -3,12 +3,13 @@ package marshal
import (
"fmt"
"github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"
"github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
)
// NewResultValue constructs a ResultValue from a promql.Value

@ -3,9 +3,10 @@ package logql
import (
"github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/kit/log/level"
"github.com/grafana/loki/pkg/logql/stats"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/grafana/loki/pkg/logql/stats"
)
const (

@ -3,9 +3,10 @@ package logql
import (
"sync"
"github.com/grafana/loki/pkg/iter"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"
"github.com/grafana/loki/pkg/iter"
)
// RangeVectorAggregator aggregates samples for a given range of samples.

@ -6,10 +6,11 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/prometheus/prometheus/promql"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
)
var entries = []logproto.Entry{

@ -7,10 +7,11 @@ import (
"net"
"testing"
"github.com/grafana/loki/pkg/logproto"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
"google.golang.org/grpc/test/bufconn"
"github.com/grafana/loki/pkg/logproto"
)
const bufSize = 1024 * 1024

@ -3,8 +3,9 @@ package unmarshal
import (
"io"
"github.com/grafana/loki/pkg/logproto"
json "github.com/json-iterator/go"
"github.com/grafana/loki/pkg/logproto"
)
// DecodePushRequest directly decodes json to a logproto.PushRequest

@ -7,8 +7,9 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/logproto"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/logproto"
)
// covers requests to /api/prom/push

@ -3,9 +3,10 @@ package unmarshal
import (
"io"
json "github.com/json-iterator/go"
"github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logproto"
json "github.com/json-iterator/go"
)
// DecodePushRequest directly decodes json to a logproto.PushRequest

@ -6,8 +6,9 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/logproto"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/logproto"
)
// covers requests to /loki/api/v1/push

@ -5,6 +5,7 @@ import (
"github.com/gogo/protobuf/proto"
"github.com/golang/snappy"
"github.com/grafana/loki/pkg/logproto"
)

@ -5,10 +5,11 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/logproto"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/logproto"
)
func TestBatch_add(t *testing.T) {

@ -18,11 +18,12 @@ import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/grafana/loki/pkg/helpers"
"github.com/grafana/loki/pkg/logproto"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/config"
"github.com/prometheus/common/model"
"github.com/grafana/loki/pkg/helpers"
"github.com/grafana/loki/pkg/logproto"
)
const (

@ -14,12 +14,13 @@ import (
"github.com/cortexproject/cortex/pkg/util"
"github.com/cortexproject/cortex/pkg/util/flagext"
"github.com/grafana/loki/pkg/logproto"
lokiflag "github.com/grafana/loki/pkg/util/flagext"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/testutil"
"github.com/prometheus/common/config"
"github.com/prometheus/common/model"
"github.com/grafana/loki/pkg/logproto"
lokiflag "github.com/grafana/loki/pkg/util/flagext"
)
var (

@ -6,8 +6,9 @@ import (
"github.com/cortexproject/cortex/pkg/util"
"github.com/cortexproject/cortex/pkg/util/flagext"
lokiflag "github.com/grafana/loki/pkg/util/flagext"
"github.com/prometheus/common/config"
lokiflag "github.com/grafana/loki/pkg/util/flagext"
)
// Config describes configuration for a HTTP pusher client.

@ -3,8 +3,9 @@ package fake
import (
"time"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/prometheus/common/model"
"github.com/grafana/loki/pkg/promtail/api"
)
// Client is a fake client used for testing.

@ -5,8 +5,9 @@ import (
"time"
"github.com/go-kit/kit/log"
"github.com/grafana/loki/pkg/util"
"github.com/prometheus/common/model"
"github.com/grafana/loki/pkg/util"
)
// MultiClient is client pushing to one or more loki instances.

@ -11,8 +11,9 @@ import (
"github.com/cortexproject/cortex/pkg/util"
"github.com/cortexproject/cortex/pkg/util/flagext"
"github.com/grafana/loki/pkg/promtail/client/fake"
"github.com/prometheus/common/model"
"github.com/grafana/loki/pkg/promtail/client/fake"
)
func TestNewMulti(t *testing.T) {

@ -10,10 +10,11 @@ import (
template_text "text/template"
"time"
"github.com/grafana/loki/pkg/promtail/server/ui"
"github.com/pkg/errors"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/template"
"github.com/grafana/loki/pkg/promtail/server/ui"
)
// templateOptions is a set of options to render a template.

@ -6,9 +6,10 @@ import (
"log"
"time"
"github.com/grafana/loki/pkg/promtail/server/ui"
"github.com/prometheus/prometheus/pkg/modtimevfs"
"github.com/shurcooL/vfsgen"
"github.com/grafana/loki/pkg/promtail/server/ui"
)
func main() {

@ -18,12 +18,14 @@ import (
"github.com/grafana/loki/pkg/promtail/positions"
"github.com/go-kit/kit/log"
"github.com/grafana/loki/pkg/promtail/scrape"
"github.com/coreos/go-systemd/sdjournal"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/pkg/errors"
"github.com/prometheus/common/model"
"github.com/grafana/loki/pkg/promtail/api"
)
const (

@ -19,8 +19,9 @@ import (
"github.com/grafana/loki/pkg/promtail/scrape"
"github.com/go-kit/kit/log"
"github.com/grafana/loki/pkg/promtail/positions"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/promtail/positions"
)
type mockJournalReader struct {

@ -5,6 +5,7 @@ package targets
import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/grafana/loki/pkg/promtail/positions"
"github.com/grafana/loki/pkg/promtail/scrape"

@ -5,11 +5,12 @@ package targets
import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/grafana/loki/pkg/logentry/stages"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/grafana/loki/pkg/promtail/positions"
"github.com/grafana/loki/pkg/promtail/scrape"
"github.com/prometheus/client_golang/prometheus"
)
// JournalTargetManager manages a series of JournalTargets.

@ -12,13 +12,14 @@ import (
"github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/grafana/loki/pkg/logentry/stages"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/grafana/loki/pkg/promtail/scrape"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/discovery/config"
"github.com/prometheus/prometheus/discovery/targetgroup"
"github.com/grafana/loki/pkg/logentry/stages"
"github.com/grafana/loki/pkg/promtail/api"
"github.com/grafana/loki/pkg/promtail/scrape"
)
// bufferSize is the size of the buffered reader

@ -8,11 +8,12 @@ import (
"testing"
"time"
"github.com/grafana/loki/pkg/logentry/stages"
"github.com/grafana/loki/pkg/promtail/scrape"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v2"
"github.com/grafana/loki/pkg/logentry/stages"
"github.com/grafana/loki/pkg/promtail/scrape"
)
type line struct {

@ -5,9 +5,10 @@ import (
"strings"
"testing"
"github.com/grafana/loki/pkg/promtail/targets/syslogparser"
"github.com/influxdata/go-syslog/v2"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/promtail/targets/syslogparser"
)
func TestParseStream_OctetCounting(t *testing.T) {

@ -11,17 +11,18 @@ import (
"github.com/cortexproject/cortex/pkg/chunk"
cortex_client "github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/cortexproject/cortex/pkg/ring"
"github.com/grafana/loki/pkg/ingester/client"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/util"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"google.golang.org/grpc"
"google.golang.org/grpc/health/grpc_health_v1"
grpc_metadata "google.golang.org/grpc/metadata"
"github.com/grafana/loki/pkg/ingester/client"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/util"
)
// querierClientMock is a mockable version of QuerierClient, used in querier

@ -14,16 +14,17 @@ import (
"github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/cortexproject/cortex/pkg/querier/queryrange"
json "github.com/json-iterator/go"
"github.com/opentracing/opentracing-go"
otlog "github.com/opentracing/opentracing-go/log"
"github.com/weaveworks/common/httpgrpc"
"github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/logql/marshal"
marshal_legacy "github.com/grafana/loki/pkg/logql/marshal/legacy"
"github.com/grafana/loki/pkg/logql/stats"
json "github.com/json-iterator/go"
"github.com/opentracing/opentracing-go"
otlog "github.com/opentracing/opentracing-go/log"
"github.com/weaveworks/common/httpgrpc"
)
var lokiCodec = &codec{}

@ -12,10 +12,11 @@ import (
"github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/cortexproject/cortex/pkg/querier/queryrange"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql/stats"
"github.com/stretchr/testify/require"
)
func init() {

@ -7,10 +7,11 @@ import (
"net/http"
"github.com/cortexproject/cortex/pkg/querier/queryrange"
"github.com/grafana/loki/pkg/logql/stats"
jsoniter "github.com/json-iterator/go"
"github.com/opentracing/opentracing-go"
otlog "github.com/opentracing/opentracing-go/log"
"github.com/grafana/loki/pkg/logql/stats"
)
var jsonStd = jsoniter.ConfigCompatibleWithStandardLibrary

@ -10,9 +10,10 @@ import (
"github.com/cortexproject/cortex/pkg/querier/queryrange"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/grafana/loki/pkg/logql"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/weaveworks/common/httpgrpc"
"github.com/grafana/loki/pkg/logql"
)
// Config is the configuration for the queryrange tripperware

@ -12,14 +12,15 @@ import (
"github.com/cortexproject/cortex/pkg/chunk/cache"
"github.com/cortexproject/cortex/pkg/querier/queryrange"
"github.com/cortexproject/cortex/pkg/util"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/logql/marshal"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/middleware"
"github.com/weaveworks/common/user"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/logql/marshal"
)
var (

@ -6,11 +6,12 @@ import (
"time"
"github.com/cortexproject/cortex/pkg/querier/queryrange"
"github.com/grafana/loki/pkg/logproto"
"github.com/opentracing/opentracing-go"
otlog "github.com/opentracing/opentracing-go/log"
"github.com/weaveworks/common/httpgrpc"
"github.com/weaveworks/common/user"
"github.com/grafana/loki/pkg/logproto"
)
// SplitByIntervalMiddleware creates a new Middleware that splits log requests by a given interval.

@ -9,10 +9,11 @@ import (
"time"
"github.com/cortexproject/cortex/pkg/querier/queryrange"
"github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logproto"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/user"
"github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logproto"
)
func Test_splitQuery(t *testing.T) {

@ -9,6 +9,7 @@ import (
"github.com/cortexproject/cortex/pkg/util"
"github.com/cortexproject/cortex/pkg/util/spanlogger"
"github.com/go-kit/kit/log/level"
"github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/logql/stats"

@ -7,10 +7,11 @@ import (
"time"
"github.com/cortexproject/cortex/pkg/querier/queryrange"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/logql/stats"
"github.com/stretchr/testify/require"
)
func TestStatsMiddleware(t *testing.T) {

@ -7,10 +7,11 @@ import (
"github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/kit/log/level"
"github.com/pkg/errors"
"github.com/grafana/loki/pkg/iter"
loghttp "github.com/grafana/loki/pkg/loghttp/legacy"
"github.com/grafana/loki/pkg/logproto"
"github.com/pkg/errors"
)
const (

@ -5,11 +5,12 @@ import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/iter"
loghttp "github.com/grafana/loki/pkg/loghttp/legacy"
"github.com/grafana/loki/pkg/logproto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const (

@ -6,11 +6,12 @@ import (
"testing"
"time"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/pkg/chunkenc"
"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/stretchr/testify/require"
)
func Test_newBatchChunkIterator(t *testing.T) {

@ -10,13 +10,14 @@ import (
"github.com/cortexproject/cortex/pkg/chunk/cache"
"github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/davecgh/go-spew/spew"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/stretchr/testify/assert"
"github.com/grafana/loki/pkg/chunkenc"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql"
"github.com/grafana/loki/pkg/util"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/stretchr/testify/assert"
)
var fooLabelsWithName = "{foo=\"bar\", __name__=\"log\"}"

@ -7,9 +7,10 @@ import (
"time"
"github.com/cortexproject/cortex/pkg/ingester/client"
"github.com/grafana/loki/pkg/logql"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/grafana/loki/pkg/logql"
)
type byLabel []client.LabelAdapter

Loading…
Cancel
Save