Skip to content

Commit

Permalink
Merge pull request FeatureBaseDB#3 from alanbernstein/snapshot-stats
Browse files Browse the repository at this point in the history
Snapshot stats
  • Loading branch information
raskle authored Apr 24, 2017
2 parents baafc77 + e0fb322 commit 2e3455e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions fragment.go
Original file line number Diff line number Diff line change
Expand Up @@ -995,15 +995,18 @@ func (f *Fragment) Snapshot() error {
defer f.mu.Unlock()
return f.snapshot()
}
func track(start time.Time, name string, logger *log.Logger) {
func track(start time.Time, message string, stats StatsClient, logger *log.Logger) {
elapsed := time.Since(start)
logger.Printf("%s took %s", name, elapsed)
logger.Printf("%s took %s", message, elapsed)
stats.Histogram("snapshot", elapsed.Seconds())
}

func (f *Fragment) snapshot() error {
logger := f.logger()
logger.Printf("fragment: snapshotting %s/%s/%s/%d", f.db, f.frame, f.view, f.slice)
defer track(time.Now(), fmt.Sprintf("fragment: snapshot complete %s/%s/%s/%d", f.db, f.frame, f.view, f.slice), logger)
completeMessage := fmt.Sprintf("fragment: snapshot complete %s/%s/%s/%d", f.db, f.frame, f.view, f.slice)
start := time.Now()
defer track(start, completeMessage, f.stats, logger)

// Create a temporary file to snapshot to.
snapshotPath := f.path + SnapshotExt
Expand Down

0 comments on commit 2e3455e

Please sign in to comment.