+4
carstore/bs.go
+4
carstore/bs.go
···
645
offset += nw
646
}
647
648
path, err := cs.writeNewShardFile(ctx, user, seq, buf.Bytes())
649
if err != nil {
650
return nil, fmt.Errorf("failed to write shard file: %w", err)
651
}
652
653
shard := CarShard{
654
Root: models.DbCID{CID: root},
···
659
Rev: rev,
660
}
661
662
if err := cs.putShard(ctx, &shard, brefs, rmcids, false); err != nil {
663
return nil, err
664
}
665
666
return buf.Bytes(), nil
667
}
···
645
offset += nw
646
}
647
648
+
start := time.Now()
649
path, err := cs.writeNewShardFile(ctx, user, seq, buf.Bytes())
650
if err != nil {
651
return nil, fmt.Errorf("failed to write shard file: %w", err)
652
}
653
+
writeShardFileDuration.Observe(time.Since(start).Seconds())
654
655
shard := CarShard{
656
Root: models.DbCID{CID: root},
···
661
Rev: rev,
662
}
663
664
+
start = time.Now()
665
if err := cs.putShard(ctx, &shard, brefs, rmcids, false); err != nil {
666
return nil, err
667
}
668
+
writeShardMetadataDuration.Observe(time.Since(start).Seconds())
669
670
return buf.Bytes(), nil
671
}
+18
carstore/metrics.go
+18
carstore/metrics.go
···
···
1
+
package carstore
2
+
3
+
import (
4
+
"github.com/prometheus/client_golang/prometheus"
5
+
"github.com/prometheus/client_golang/prometheus/promauto"
6
+
)
7
+
8
+
var writeShardFileDuration = promauto.NewHistogram(prometheus.HistogramOpts{
9
+
Name: "carstore_write_shard_file_duration",
10
+
Help: "Duration of writing shard file to disk",
11
+
Buckets: prometheus.ExponentialBuckets(0.001, 2, 15),
12
+
})
13
+
14
+
var writeShardMetadataDuration = promauto.NewHistogram(prometheus.HistogramOpts{
15
+
Name: "carstore_write_shard_metadata_duration",
16
+
Help: "Duration of writing shard metadata to DB",
17
+
Buckets: prometheus.ExponentialBuckets(0.001, 2, 15),
18
+
})