Skip to content

Commit 6f106b2

Browse files
authored
Merge pull request #48 from filecoin-project/feat/metrics-work
Update log lines to support better metric capture for loki
2 parents 965f0d3 + a4610eb commit 6f106b2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

cmd/filecoin-chain-archiver/cmds/create.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,10 @@ var cmdCreate = &cli.Command{
224224

225225
t := export.TimeAtHeight(gtp, confidenceHeight, 30*time.Second)
226226

227-
logger.Infow("snapshot", "snapshot_height", height, "current_height", expected, "confidence_height", confidenceHeight, "run_at", t)
228-
227+
// Snapshots started
228+
logger.Infow("snapshot job started", "snapshot_height", height, "current_height", expected, "confidence_height", confidenceHeight, "run_at", t)
229229
time.Sleep(time.Until(t))
230+
bt := time.Now()
230231

231232
tsk, err := cm.GetTipset(ctx, height)
232233
if err != nil {
@@ -321,14 +322,18 @@ var cmdCreate = &cli.Command{
321322
}
322323
}()
323324

325+
var snapshotSize int64
326+
324327
if flagDiscard {
325328
logger.Infow("discarding output")
326329
io.Copy(ioutil.Discard, r)
330+
snapshotSize = 0
327331

328332
if err := <-errCh; err != nil {
329333
return err
330334
}
331335
} else {
336+
332337
host := u.Hostname()
333338
port := u.Port()
334339
if port == "" {
@@ -359,7 +364,7 @@ var cmdCreate = &cli.Command{
359364
return fmt.Errorf("failed to upload object (%s): %w", fmt.Sprintf("%s%s.car", flagNamePrefix, name), err)
360365
}
361366

362-
logger.Infow("upload",
367+
logger.Infow("snapshot upload",
363368
"bucket", info.Bucket,
364369
"key", info.Key,
365370
"etag", info.ETag,
@@ -369,6 +374,7 @@ var cmdCreate = &cli.Command{
369374
"expiration", info.Expiration,
370375
"expiration_rule_id", info.ExpirationRuleID,
371376
)
377+
snapshotSize = info.Size
372378

373379
if err := <-errCh; err != nil {
374380
return err
@@ -398,7 +404,7 @@ var cmdCreate = &cli.Command{
398404
return fmt.Errorf("failed to write latest", "object", fmt.Sprintf("%slatest", flagNamePrefix), "err", err)
399405
}
400406

401-
logger.Infow("upload",
407+
logger.Infow("latest upload",
402408
"bucket", info.Bucket,
403409
"key", info.Key,
404410
"etag", info.ETag,
@@ -410,7 +416,7 @@ var cmdCreate = &cli.Command{
410416
)
411417
}
412418

413-
logger.Infow("finished", "digiest", fmt.Sprintf("%x", h.Sum(nil)))
419+
logger.Infow("snapshot job finished", "digiest", fmt.Sprintf("%x", h.Sum(nil)), "elapsed", int64(time.Since(bt).Round(time.Second).Seconds()), "size", snapshotSize, "peer", peerID)
414420

415421
return nil
416422
},

0 commit comments

Comments
 (0)