Skip to content

Commit

Permalink
single import of jsoniter in logql subpackages (#3544)
Browse files Browse the repository at this point in the history
  • Loading branch information
alrs authored Mar 26, 2021
1 parent 54bc146 commit b5930d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 3 additions & 4 deletions pkg/logql/marshal/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/grafana/loki/pkg/logql"

"github.com/gorilla/websocket"
json "github.com/json-iterator/go"
jsoniter "github.com/json-iterator/go"

"github.com/grafana/loki/pkg/loghttp"
Expand All @@ -33,7 +32,7 @@ func WriteQueryResponseJSON(v logql.Result, w io.Writer) error {
},
}

return json.NewEncoder(w).Encode(q)
return jsoniter.NewEncoder(w).Encode(q)
}

// WriteLabelResponseJSON marshals a logproto.LabelResponse to v1 loghttp JSON
Expand All @@ -44,7 +43,7 @@ func WriteLabelResponseJSON(l logproto.LabelResponse, w io.Writer) error {
Data: l.GetValues(),
}

return json.NewEncoder(w).Encode(v1Response)
return jsoniter.NewEncoder(w).Encode(v1Response)
}

// WebsocketWriter knows how to write message to a websocket connection.
Expand Down Expand Up @@ -78,7 +77,7 @@ func WriteSeriesResponseJSON(r logproto.SeriesResponse, w io.Writer) error {
adapter.Data = append(adapter.Data, series.GetLabels())
}

return json.NewEncoder(w).Encode(adapter)
return jsoniter.NewEncoder(w).Encode(adapter)
}

// This struct exists primarily because we can't specify a repeated map in proto v3.
Expand Down
3 changes: 1 addition & 2 deletions pkg/logql/unmarshal/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"io"
"unsafe"

json "github.com/json-iterator/go"
jsoniter "github.com/json-iterator/go"

"github.com/grafana/loki/pkg/loghttp"
Expand All @@ -15,7 +14,7 @@ import (
func DecodePushRequest(b io.Reader, r *logproto.PushRequest) error {
var request loghttp.PushRequest

if err := json.NewDecoder(b).Decode(&request); err != nil {
if err := jsoniter.NewDecoder(b).Decode(&request); err != nil {
return err
}
*r = NewPushRequest(request)
Expand Down

0 comments on commit b5930d6

Please sign in to comment.