Skip to content

Commit

Permalink
few additions
Browse files Browse the repository at this point in the history
Signed-off-by: Shashank <[email protected]>
  • Loading branch information
moki1202 committed Mar 2, 2023
1 parent 50540f6 commit ad22f18
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cmd/updater/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ func main() {
})
log.Info("Configured concurrency")

groupUpdater := updater.GCS(ctx, client, opt.groupTimeout, opt.buildTimeout, opt.buildConcurrency, opt.confirm, opt.enableIgnoreSkip)

mets := updater.CreateMetrics(prometheus.NewFactory())

groupUpdater := updater.GCS(ctx, client, mets, opt.groupTimeout, opt.buildTimeout, opt.buildConcurrency, opt.confirm, opt.enableIgnoreSkip)

pubsubClient, err := gpubsub.NewClient(ctx, "", option.WithCredentialsFile(opt.creds))
if err != nil {
logrus.WithError(err).Fatal("Failed to create pubsub client")
Expand Down
18 changes: 9 additions & 9 deletions pkg/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ const componentName = "updater"

// Metrics holds metrics relevant to the Updater.
type Metrics struct {
UpdateState metrics.Cyclic
DelaySeconds metrics.Duration
MoreCounter metrics.Counter
UpdateState metrics.Cyclic
DelaySeconds metrics.Duration
IncompleteUpdates metrics.Counter
}

// CreateMetrics creates metrics for this controller
func CreateMetrics(factory metrics.Factory) *Metrics {
return &Metrics{
UpdateState: factory.NewCyclic(componentName),
DelaySeconds: factory.NewDuration("delay", "Seconds updater is behind schedule", "component"),
MoreCounter: factory.NewCounter("counter", "number of unread columns"),
UpdateState: factory.NewCyclic(componentName),
DelaySeconds: factory.NewDuration("delay", "Seconds updater is behind schedule", "component"),
IncompleteUpdates: factory.NewCounter("counter", "number of unread columns"),
}
}

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

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

Expand Down Expand Up @@ -732,7 +732,7 @@ func InflateDropAppend(ctx context.Context, alog logrus.FieldLogger, client gcs.
}
if unreadColumns {
log = log.WithField("more", true)
mets.MoreCounter.Add(1)
mets.IncompleteUpdates.Add(1)
}
log.WithFields(logrus.Fields{
"cols": len(grid.Columns),
Expand Down
3 changes: 2 additions & 1 deletion pkg/updater/updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestGCS(t *testing.T) {
}
}
}()
updater := GCS(tc.ctx, nil, 0, 0, 0, false, false)
updater := GCS(tc.ctx, nil, nil, 0, 0, 0, false, false)
_, err := updater(ctx, logrus.WithField("case", tc.name), nil, tc.group, gcs.Path{})
switch {
case err != nil:
Expand Down Expand Up @@ -2175,6 +2175,7 @@ func TestInflateDropAppend(t *testing.T) {
!tc.skipWrite,
colReader,
tc.reprocess,
nil, //metric
)
switch {
case err != nil:
Expand Down

0 comments on commit ad22f18

Please sign in to comment.