Skip to content

Commit

Permalink
fix: create batch failures should not count toward upload error
Browse files Browse the repository at this point in the history
  • Loading branch information
istae committed Oct 2, 2023
1 parent 8017852 commit c7273bf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
32 changes: 25 additions & 7 deletions pkg/check/smoke/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,35 @@ import (
)

type metrics struct {
UploadErrors prometheus.Counter
UploadAttempts prometheus.Counter
DownloadErrors prometheus.Counter
DownloadMismatch prometheus.Counter
DownloadAttempts prometheus.Counter
UploadDuration prometheus.Histogram
DownloadDuration prometheus.Histogram
BatchCreateErrors prometheus.Counter
BatchCreateAttempts prometheus.Counter
UploadErrors prometheus.Counter
UploadAttempts prometheus.Counter
DownloadErrors prometheus.Counter
DownloadMismatch prometheus.Counter
DownloadAttempts prometheus.Counter
UploadDuration prometheus.Histogram
DownloadDuration prometheus.Histogram
}

func newMetrics(subsystem string) metrics {
return metrics{
BatchCreateAttempts: prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "batch_create_attemps",

Check failure on line 26 in pkg/check/smoke/metrics.go

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

`attemps` is a misspelling of `attempts` (misspell)
Help: "Number of batch create attemps.",

Check failure on line 27 in pkg/check/smoke/metrics.go

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

`attemps` is a misspelling of `attempts` (misspell)
},
),
BatchCreateErrors: prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "batch_create_errors",
Help: "Total errors encountered while creating batches.",
},
),
UploadAttempts: prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: m.Namespace,
Expand Down
11 changes: 6 additions & 5 deletions pkg/check/smoke/smoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,21 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int
case <-time.After(o.TxOnErrWait):
}

c.metrics.UploadAttempts.Inc()

txCtx, txCancel = context.WithTimeout(ctx, o.UploadTimeout)

c.metrics.BatchCreateAttempts.Inc()
batchID := batches.Get(txName)
if batchID == "" {
batchID, err = clients[txName].CreatePostageBatch(txCtx, o.PostageAmount, o.PostageDepth, "load-test", true)
batchID, err = clients[txName].CreatePostageBatch(context.Background(), o.PostageAmount, o.PostageDepth, "load-test", true)
if err != nil {
c.logger.Errorf("create new batch: %v", err)
c.metrics.BatchCreateErrors.Inc()
continue
}
batches.Store(txName, batchID)
}

txCtx, txCancel = context.WithTimeout(ctx, o.UploadTimeout)

c.metrics.UploadAttempts.Inc()
address, txDuration, err = test.upload(txCtx, txName, txData, batchID)
if err != nil {
c.metrics.UploadErrors.Inc()
Expand Down

0 comments on commit c7273bf

Please sign in to comment.