Skip to content

Commit ad22f18

Browse files
committed
few additions
Signed-off-by: Shashank <shashanksingh819@gmail.com>
1 parent 50540f6 commit ad22f18

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

cmd/updater/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ func main() {
163163
})
164164
log.Info("Configured concurrency")
165165

166-
groupUpdater := updater.GCS(ctx, client, opt.groupTimeout, opt.buildTimeout, opt.buildConcurrency, opt.confirm, opt.enableIgnoreSkip)
167-
168166
mets := updater.CreateMetrics(prometheus.NewFactory())
169167

168+
groupUpdater := updater.GCS(ctx, client, mets, opt.groupTimeout, opt.buildTimeout, opt.buildConcurrency, opt.confirm, opt.enableIgnoreSkip)
169+
170170
pubsubClient, err := gpubsub.NewClient(ctx, "", option.WithCredentialsFile(opt.creds))
171171
if err != nil {
172172
logrus.WithError(err).Fatal("Failed to create pubsub client")

pkg/updater/updater.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ const componentName = "updater"
4949

5050
// Metrics holds metrics relevant to the Updater.
5151
type Metrics struct {
52-
UpdateState metrics.Cyclic
53-
DelaySeconds metrics.Duration
54-
MoreCounter metrics.Counter
52+
UpdateState metrics.Cyclic
53+
DelaySeconds metrics.Duration
54+
IncompleteUpdates metrics.Counter
5555
}
5656

5757
// CreateMetrics creates metrics for this controller
5858
func CreateMetrics(factory metrics.Factory) *Metrics {
5959
return &Metrics{
60-
UpdateState: factory.NewCyclic(componentName),
61-
DelaySeconds: factory.NewDuration("delay", "Seconds updater is behind schedule", "component"),
62-
MoreCounter: factory.NewCounter("counter", "number of unread columns"),
60+
UpdateState: factory.NewCyclic(componentName),
61+
DelaySeconds: factory.NewDuration("delay", "Seconds updater is behind schedule", "component"),
62+
IncompleteUpdates: factory.NewCounter("counter", "number of unread columns"),
6363
}
6464
}
6565

@@ -90,7 +90,7 @@ func (mets *Metrics) start() *metrics.CycleReporter {
9090
type GroupUpdater func(parent context.Context, log logrus.FieldLogger, client gcs.Client, tg *configpb.TestGroup, gridPath gcs.Path) (bool, error)
9191

9292
// GCS returns a GCS-based GroupUpdater, which knows how to process result data stored in GCS.
93-
func GCS(poolCtx context.Context, colClient gcs.Client, groupTimeout, buildTimeout time.Duration, concurrency int, write bool, enableIgnoreSkip bool) GroupUpdater {
93+
func GCS(poolCtx context.Context, colClient gcs.Client, mets *Metrics, groupTimeout, buildTimeout time.Duration, concurrency int, write bool, enableIgnoreSkip bool) GroupUpdater {
9494
var readResult *resultReader
9595
if poolCtx == nil {
9696
// TODO(fejta): remove check soon
@@ -107,7 +107,7 @@ func GCS(poolCtx context.Context, colClient gcs.Client, groupTimeout, buildTimeo
107107
defer cancel()
108108
gcsColReader := gcsColumnReader(colClient, buildTimeout, readResult, enableIgnoreSkip)
109109
reprocess := 20 * time.Minute // allow 20m for prow to finish uploading artifacts
110-
return InflateDropAppend(ctx, log, client, tg, gridPath, write, gcsColReader, reprocess)
110+
return InflateDropAppend(ctx, log, client, tg, gridPath, write, gcsColReader, reprocess, mets)
111111
}
112112
}
113113

@@ -732,7 +732,7 @@ func InflateDropAppend(ctx context.Context, alog logrus.FieldLogger, client gcs.
732732
}
733733
if unreadColumns {
734734
log = log.WithField("more", true)
735-
mets.MoreCounter.Add(1)
735+
mets.IncompleteUpdates.Add(1)
736736
}
737737
log.WithFields(logrus.Fields{
738738
"cols": len(grid.Columns),

pkg/updater/updater_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func TestGCS(t *testing.T) {
9595
}
9696
}
9797
}()
98-
updater := GCS(tc.ctx, nil, 0, 0, 0, false, false)
98+
updater := GCS(tc.ctx, nil, nil, 0, 0, 0, false, false)
9999
_, err := updater(ctx, logrus.WithField("case", tc.name), nil, tc.group, gcs.Path{})
100100
switch {
101101
case err != nil:
@@ -2175,6 +2175,7 @@ func TestInflateDropAppend(t *testing.T) {
21752175
!tc.skipWrite,
21762176
colReader,
21772177
tc.reprocess,
2178+
nil, //metric
21782179
)
21792180
switch {
21802181
case err != nil:

0 commit comments

Comments
 (0)