Skip to content

Commit

Permalink
Merge pull request #1 from castai/bump-versions
Browse files Browse the repository at this point in the history
chore: bump go to 1.18, all dependency versions and remove deprecated calls
  • Loading branch information
saumas authored Nov 25, 2022
2 parents 1be6a78 + 6657e8e commit 5a6d58b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 156 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Go 1.16
- name: Setup Go 1.18
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18

- name: Cache Go modules
uses: actions/cache@v2
Expand Down
14 changes: 7 additions & 7 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"time"

Expand Down Expand Up @@ -119,7 +119,7 @@ func (p *Client) Write(ctx context.Context, req *WriteRequest, options ...WriteO
defer httpResp.Body.Close()

if st := httpResp.StatusCode; st/100 != 2 {
msg, _ := ioutil.ReadAll(httpResp.Body)
msg, _ := io.ReadAll(httpResp.Body)
return nil, &WriteError{
err: fmt.Errorf("promwrite: expected status %d, got %d: %s", http.StatusOK, st, string(msg)),
code: st,
Expand All @@ -128,17 +128,17 @@ func (p *Client) Write(ctx context.Context, req *WriteRequest, options ...WriteO
return &WriteResponse{}, nil
}

func toProtoTimeSeries(timeSeries []TimeSeries) []*prompb.TimeSeries {
res := make([]*prompb.TimeSeries, len(timeSeries))
func toProtoTimeSeries(timeSeries []TimeSeries) []prompb.TimeSeries {
res := make([]prompb.TimeSeries, len(timeSeries))
for i, ts := range timeSeries {
labels := make([]*prompb.Label, len(ts.Labels))
labels := make([]prompb.Label, len(ts.Labels))
for j, lb := range ts.Labels {
labels[j] = &prompb.Label{
labels[j] = prompb.Label{
Name: lb.Name,
Value: lb.Value,
}
}
pbTs := &prompb.TimeSeries{
pbTs := prompb.TimeSeries{
Labels: labels,
Samples: []prompb.Sample{{
// Timestamp for remote write should be in milliseconds.
Expand Down
15 changes: 8 additions & 7 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package promwrite_test
import (
"context"
"errors"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
Expand All @@ -24,7 +25,7 @@ func TestClient(t *testing.T) {

receivedWriteRequest := make(chan *prompb.WriteRequest, 1)
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
b, _ := ioutil.ReadAll(req.Body)
b, _ := io.ReadAll(req.Body)
parsed, err := parseWriteRequest(b)
r.NoError(err)
receivedWriteRequest <- parsed
Expand Down Expand Up @@ -75,8 +76,8 @@ func TestClient(t *testing.T) {

res := <-receivedWriteRequest
r.Len(res.Timeseries, 2)
r.Equal(&prompb.TimeSeries{
Labels: []*prompb.Label{
r.Equal(prompb.TimeSeries{
Labels: []prompb.Label{
{
Name: "__name__",
Value: "metric_a",
Expand All @@ -93,8 +94,8 @@ func TestClient(t *testing.T) {
},
},
}, res.Timeseries[0])
r.Equal(&prompb.TimeSeries{
Labels: []*prompb.Label{
r.Equal(prompb.TimeSeries{
Labels: []prompb.Label{
{
Name: "__name__",
Value: "metric_b",
Expand Down Expand Up @@ -161,8 +162,8 @@ func TestClient(t *testing.T) {

res := <-receivedWriteRequest
r.Len(res.Timeseries, 1)
r.Equal(&prompb.TimeSeries{
Labels: []*prompb.Label{
r.Equal(prompb.TimeSeries{
Labels: []prompb.Label{
{
Name: "__name__",
Value: "metric_a",
Expand Down
19 changes: 6 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
module github.com/castai/promwrite

go 1.17
go 1.18

require (
github.com/gogo/protobuf v1.3.2
github.com/golang/snappy v0.0.4
github.com/prometheus/prometheus v2.5.0+incompatible
github.com/stretchr/testify v1.7.0
github.com/prometheus/prometheus v0.40.3
github.com/stretchr/testify v1.8.1
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
golang.org/x/text v0.3.5 // indirect
google.golang.org/genproto v0.0.0-20220204002441-d6cc3cc0770e // indirect
google.golang.org/grpc v1.44.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 5a6d58b

Please sign in to comment.