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

Move to jsoniter instead of default json package #1249

Merged
merged 2 commits into from
Dec 2, 2019
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
7 changes: 3 additions & 4 deletions pkg/canary/reader/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package reader

import (
"encoding/base64"
"encoding/json"
"fmt"
"io"
"io/ioutil"
Expand All @@ -14,12 +13,12 @@ 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"
cyriltovena marked this conversation as resolved.
Show resolved Hide resolved
"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 (
Expand Down
8 changes: 3 additions & 5 deletions pkg/logcli/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package client

import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"log"
Expand All @@ -11,13 +10,12 @@ import (
"strings"
"time"

"github.com/gorilla/websocket"
"github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/util"

"github.com/gorilla/websocket"
json "github.com/json-iterator/go"
"github.com/prometheus/common/config"

"github.com/grafana/loki/pkg/logproto"
)

const (
Expand Down
9 changes: 4 additions & 5 deletions pkg/logcli/query/query.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
package query

import (
"encoding/json"
"fmt"
"log"
"sort"
"strings"
"time"

"github.com/fatih/color"
"github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logql"
"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"
json "github.com/json-iterator/go"
"github.com/prometheus/prometheus/promql"
)

type streamEntryPair struct {
Expand Down
4 changes: 1 addition & 3 deletions pkg/logentry/stages/json.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package stages

import (
"encoding/json"
//"encoding/json"
//"fmt"
"reflect"
"time"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/jmespath/go-jmespath"
json "github.com/json-iterator/go"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
"github.com/prometheus/common/model"
Expand Down
2 changes: 1 addition & 1 deletion pkg/loghttp/query.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package loghttp

import (
"encoding/json"
"errors"
"fmt"
"net/http"
"strconv"
"time"

"github.com/grafana/loki/pkg/logproto"
json "github.com/json-iterator/go"
"github.com/prometheus/common/model"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/loghttp/tail.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package loghttp

import (
"encoding/json"
"fmt"
"net/http"
"strconv"
"time"

"github.com/grafana/loki/pkg/logproto"
json "github.com/json-iterator/go"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/logql/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package logql

import (
"context"
"encoding/json"
"fmt"
"testing"
"time"

"github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto"
json "github.com/json-iterator/go"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"
"github.com/stretchr/testify/assert"
Expand Down
3 changes: 1 addition & 2 deletions pkg/logql/marshal/legacy/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
package marshal

import (
"encoding/json"
"fmt"
"io"

"github.com/gorilla/websocket"
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/prometheus/prometheus/promql"
)

Expand Down
6 changes: 3 additions & 3 deletions pkg/logql/marshal/legacy/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package marshal

import (
"bytes"
"encoding/json"
"log"
"testing"
"time"

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"
)

Expand Down Expand Up @@ -37,7 +37,7 @@ var queryTests = []struct {
"entries":[
{
"ts": "2019-09-13T18:32:22.380001319Z",
"line": "super line"
"line": "super line"
}
]
}
Expand Down Expand Up @@ -95,7 +95,7 @@ var tailTests = []struct {
"entries": [
{
"ts": "2019-09-13T18:32:22.380001319Z",
"line": "super line"
"line": "super line"
}
]
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/logql/marshal/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
package marshal

import (
"encoding/json"
"io"

"github.com/gorilla/websocket"
"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"
"github.com/prometheus/prometheus/promql"
)

Expand Down
8 changes: 3 additions & 5 deletions pkg/logql/marshal/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ package marshal

import (
"bytes"
"encoding/json"
"testing"
"time"

"github.com/grafana/loki/pkg/loghttp"
legacy "github.com/grafana/loki/pkg/loghttp/legacy"

"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"

"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"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/logql/unmarshal/legacy/unmarshal.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package unmarshal

import (
"encoding/json"
"io"

"github.com/grafana/loki/pkg/logproto"
json "github.com/json-iterator/go"
)

// DecodePushRequest directly decodes json to a logproto.PushRequest
Expand Down
3 changes: 1 addition & 2 deletions pkg/logql/unmarshal/unmarshal.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package unmarshal

import (
"encoding/json"
"io"

"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
Expand Down
2 changes: 1 addition & 1 deletion pkg/promtail/api/entry_parser.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package api

import (
"encoding/json"
"fmt"
"regexp"
"strings"
"time"

json "github.com/json-iterator/go"
"github.com/prometheus/common/model"
)

Expand Down