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

Bump github.com/prometheus/prometheus #3074

Merged
merged 1 commit into from
Apr 30, 2021
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
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ require (
github.com/pquerna/cachecontrol v0.1.0 // indirect
github.com/prometheus/client_golang v1.10.0
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.20.0
github.com/prometheus/prometheus v1.8.2-0.20210217141258-a6be548dbc17
github.com/prometheus/common v0.23.0
github.com/prometheus/prometheus v1.8.2-0.20210430082741-2a4b8e12bbf2
github.com/rs/cors v1.7.0
github.com/shirou/gopsutil v3.21.3+incompatible
github.com/soheilhy/cmux v0.1.5
Expand All @@ -43,9 +43,9 @@ require (
go.opencensus.io v0.23.0
go.uber.org/atomic v1.7.0
go.uber.org/zap v1.16.0
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa
golang.org/x/sys v0.0.0-20210324051608-47abb6519492
golang.org/x/text v0.3.6
google.golang.org/genproto v0.0.0-20210302174412-5ede27ff9881
google.golang.org/genproto v0.0.0-20210312152112-fc591d9ea70f
google.golang.org/grpc v1.37.0
google.golang.org/protobuf v1.26.0
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
Expand Down
143 changes: 84 additions & 59 deletions go.sum

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions receiver/prometheusreceiver/internal/ocastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"sync/atomic"

"github.com/prometheus/prometheus/pkg/exemplar"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/scrape"
"github.com/prometheus/prometheus/storage"
Expand Down Expand Up @@ -94,12 +95,12 @@ type noopAppender struct{}

var errAlreadyStopped = errors.New("already stopped")

func (*noopAppender) Add(labels.Labels, int64, float64) (uint64, error) {
func (*noopAppender) Append(uint64, labels.Labels, int64, float64) (uint64, error) {
return 0, errAlreadyStopped
}

func (*noopAppender) AddFast(uint64, int64, float64) error {
return errAlreadyStopped
func (*noopAppender) AppendExemplar(ref uint64, l labels.Labels, e exemplar.Exemplar) (uint64, error) {
return 0, errAlreadyStopped
}

func (*noopAppender) Commit() error {
Expand Down
8 changes: 2 additions & 6 deletions receiver/prometheusreceiver/internal/ocastore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,13 @@ func TestOcaStore(t *testing.T) {
}

func TestNoopAppender(t *testing.T) {
if _, err := noop.Add(labels.FromStrings("t", "v"), 1, 1); err == nil {
if _, err := noop.Append(0, labels.FromStrings("t", "v"), 1, 1); err == nil {
t.Error("expecting error from Add method of noopApender")
}
if _, err := noop.Add(labels.FromStrings("t", "v"), 1, 1); err == nil {
if _, err := noop.Append(0, labels.FromStrings("t", "v"), 1, 1); err == nil {
t.Error("expecting error from Add method of noopApender")
}

if err := noop.AddFast(0, 1, 1); err == nil {
t.Error("expecting error from AddFast method of noopApender")
}

if err := noop.Commit(); err == nil {
t.Error("expecting error from Commit method of noopApender")
}
Expand Down
9 changes: 7 additions & 2 deletions receiver/prometheusreceiver/internal/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1"
resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/exemplar"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/storage"
"go.uber.org/zap"
Expand Down Expand Up @@ -92,8 +93,8 @@ func newTransaction(ctx context.Context, jobsMap *JobsMap, useStartTimeMetric bo
// ensure *transaction has implemented the storage.Appender interface
var _ storage.Appender = (*transaction)(nil)

// Add always returns 0 to disable label caching.
func (tr *transaction) Add(ls labels.Labels, t int64, v float64) (uint64, error) {
// Append always returns 0 to disable label caching.
func (tr *transaction) Append(ref uint64, ls labels.Labels, t int64, v float64) (uint64, error) {
// Important, must handle. prometheus will still try to feed the appender some data even if it failed to
// scrape the remote target, if the previous scrape was success and some data were cached internally
// in our case, we don't need these data, simply drop them shall be good enough. more details:
Expand All @@ -116,6 +117,10 @@ func (tr *transaction) Add(ls labels.Labels, t int64, v float64) (uint64, error)
return 0, tr.metricBuilder.AddDataPoint(ls, t, v)
}

func (tr *transaction) AppendExemplar(ref uint64, l labels.Labels, e exemplar.Exemplar) (uint64, error) {
return 0, nil
}

// AddFast always returns error since caching is not supported by Add() function.
func (tr *transaction) AddFast(_ uint64, _ int64, _ float64) error {
return storage.ErrNotFound
Expand Down
10 changes: 5 additions & 5 deletions receiver/prometheusreceiver/internal/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func Test_transaction(t *testing.T) {
t.Run("Add One No Target", func(t *testing.T) {
nomc := consumertest.NewNop()
tr := newTransaction(context.Background(), nil, true, "", rn, ms, nomc, testLogger)
if _, got := tr.Add(badLabels, time.Now().Unix()*1000, 1.0); got == nil {
if _, got := tr.Append(0, badLabels, time.Now().Unix()*1000, 1.0); got == nil {
t.Errorf("expecting error from Add() but got nil")
}
})
Expand All @@ -93,7 +93,7 @@ func Test_transaction(t *testing.T) {
t.Run("Add One Job not found", func(t *testing.T) {
nomc := consumertest.NewNop()
tr := newTransaction(context.Background(), nil, true, "", rn, ms, nomc, testLogger)
if _, got := tr.Add(jobNotFoundLb, time.Now().Unix()*1000, 1.0); got == nil {
if _, got := tr.Append(0, jobNotFoundLb, time.Now().Unix()*1000, 1.0); got == nil {
t.Errorf("expecting error from Add() but got nil")
}
})
Expand All @@ -104,7 +104,7 @@ func Test_transaction(t *testing.T) {
t.Run("Add One Good", func(t *testing.T) {
sink := new(consumertest.MetricsSink)
tr := newTransaction(context.Background(), nil, true, "", rn, ms, sink, testLogger)
if _, got := tr.Add(goodLabels, time.Now().Unix()*1000, 1.0); got != nil {
if _, got := tr.Append(0, goodLabels, time.Now().Unix()*1000, 1.0); got != nil {
t.Errorf("expecting error == nil from Add() but got: %v\n", got)
}
tr.metricBuilder.startTime = 1.0 // set to a non-zero value
Expand Down Expand Up @@ -134,7 +134,7 @@ func Test_transaction(t *testing.T) {
t.Run("Error when start time is zero", func(t *testing.T) {
sink := new(consumertest.MetricsSink)
tr := newTransaction(context.Background(), nil, true, "", rn, ms, sink, testLogger)
if _, got := tr.Add(goodLabels, time.Now().Unix()*1000, 1.0); got != nil {
if _, got := tr.Append(0, goodLabels, time.Now().Unix()*1000, 1.0); got != nil {
t.Errorf("expecting error == nil from Add() but got: %v\n", got)
}
tr.metricBuilder.startTime = 0 // zero value means the start time metric is missing
Expand All @@ -149,7 +149,7 @@ func Test_transaction(t *testing.T) {
t.Run("Drop NaN value", func(t *testing.T) {
sink := new(consumertest.MetricsSink)
tr := newTransaction(context.Background(), nil, true, "", rn, ms, sink, testLogger)
if _, got := tr.Add(goodLabels, time.Now().Unix()*1000, math.NaN()); got != nil {
if _, got := tr.Append(0, goodLabels, time.Now().Unix()*1000, math.NaN()); got != nil {
t.Errorf("expecting error == nil from Add() but got: %v\n", got)
}
if got := tr.Commit(); got != nil {
Expand Down
3 changes: 2 additions & 1 deletion receiver/prometheusreceiver/metrics_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1"
metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1"
resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1"
gokitlog "github.com/go-kit/kit/log"
"github.com/golang/protobuf/ptypes/wrappers"
promcfg "github.com/prometheus/prometheus/config"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -164,7 +165,7 @@ func setupMockPrometheus(tds ...*testData) (*mockPrometheus, *promcfg.Config, er
}

cfgStr := strings.ReplaceAll(string(cfg), srvPlaceHolder, u.Host)
pCfg, err := promcfg.Load(cfgStr)
pCfg, err := promcfg.Load(cfgStr, false, gokitlog.NewNopLogger())
return mp, pCfg, err
}

Expand Down