mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Add stats to snapshot
This commit is contained in:
parent
579b381c12
commit
0e5ba0c56f
1 changed files with 14 additions and 5 deletions
19
fragment.go
19
fragment.go
|
|
@ -995,15 +995,11 @@ func (f *Fragment) Snapshot() error {
|
|||
defer f.mu.Unlock()
|
||||
return f.snapshot()
|
||||
}
|
||||
func track(start time.Time, name string, logger *log.Logger) {
|
||||
elapsed := time.Since(start)
|
||||
logger.Printf("%s took %s", name, elapsed)
|
||||
}
|
||||
|
||||
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)
|
||||
start := time.Now()
|
||||
|
||||
// Create a temporary file to snapshot to.
|
||||
snapshotPath := f.path + SnapshotExt
|
||||
|
|
@ -1039,6 +1035,19 @@ func (f *Fragment) snapshot() error {
|
|||
// Reset operation count.
|
||||
f.opN = 0
|
||||
|
||||
elapsed := time.Since(start)
|
||||
message := fmt.Sprintf("fragment: snapshot complete %s/%s/%s/%d", f.db, f.frame, f.view, f.slice)
|
||||
logger.Printf("%s took %s", message, elapsed)
|
||||
|
||||
statsTags := []string{
|
||||
"db:" + f.db,
|
||||
"frame:" + f.frame,
|
||||
"view:" + f.view,
|
||||
fmt.Sprintf("slice:%d", f.slice),
|
||||
}
|
||||
stats := f.stats.WithTags(statsTags...)
|
||||
stats.Count("snapshot.count", 1)
|
||||
stats.Histogram("snapshot.duration", elapsed.Seconds())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue