Skip to content

Commit a241744

Browse files
authored
Merge pull request #74 from nvaatstra/s3-snapshot-metrics
S3 snapshot metrics
2 parents 1e12340 + 59fc0e6 commit a241744

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.19
55
require (
66
github.com/CrowdStrike/csproto v0.23.1
77
github.com/PowerDNS/lmdb-go v1.9.0
8-
github.com/PowerDNS/simpleblob v0.2.5
8+
github.com/PowerDNS/simpleblob v0.2.7
99
github.com/bufbuild/buf v0.56.0
1010
github.com/c2h5oh/datasize v0.0.0-20200825124411-48ed595a09d2
1111
github.com/gogo/protobuf v1.3.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ github.com/PowerDNS/go-tlsconfig v0.0.0-20221101135152-0956853b28df h1:WMUClevRP
5757
github.com/PowerDNS/go-tlsconfig v0.0.0-20221101135152-0956853b28df/go.mod h1:aKP0MVHWl7U3ruSXqAmzsoVVFm8HhYIpOmm1MwkDyDY=
5858
github.com/PowerDNS/lmdb-go v1.9.0 h1:pvdI8lzdeAfWJdkXc3XPZXCewX508awqfe5yMjSKNTE=
5959
github.com/PowerDNS/lmdb-go v1.9.0/go.mod h1:5beHlX2aYqXfMBI0+BBX3LDhV3YGHU5JgoDsirAFPlA=
60-
github.com/PowerDNS/simpleblob v0.2.5 h1:JI3pGI8KyzDXDL75ae5QPCw5588X6z6/nBzehiCe2TE=
61-
github.com/PowerDNS/simpleblob v0.2.5/go.mod h1:demorqIrYIbxW3wsU5SS5NufPyGseDW+xofeQZw4w3o=
60+
github.com/PowerDNS/simpleblob v0.2.7 h1:eslNYitaaaOgIqZdYWnMH1nJIc6HApIvBs63zzKBYQE=
61+
github.com/PowerDNS/simpleblob v0.2.7/go.mod h1:demorqIrYIbxW3wsU5SS5NufPyGseDW+xofeQZw4w3o=
6262
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
6363
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
6464
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=

syncer/receiver/metrics.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,20 @@ var (
6363
Help: "Number of bytes downloaded successfully",
6464
},
6565
)
66-
// TODO: add total space used by all snapshots
66+
metricSnapshotsStorageCount = prometheus.NewGaugeVec(
67+
prometheus.GaugeOpts{
68+
Name: "lightningstream_receiver_snapshots_in_storage_count",
69+
Help: "Number of snapshots in storage",
70+
},
71+
[]string{"lmdb"},
72+
)
73+
metricSnapshotsStorageBytes = prometheus.NewGaugeVec(
74+
prometheus.GaugeOpts{
75+
Name: "lightningstream_receiver_snapshots_in_storage_bytes",
76+
Help: "Number of bytes occupied by snapshots in storage",
77+
},
78+
[]string{"lmdb"},
79+
)
6780
)
6881

6982
func init() {
@@ -74,4 +87,6 @@ func init() {
7487
prometheus.MustRegister(metricSnapshotsLoadFailed)
7588
prometheus.MustRegister(metricSnapshotsListFailed)
7689
prometheus.MustRegister(metricSnapshotsLoadBytes)
90+
prometheus.MustRegister(metricSnapshotsStorageCount)
91+
prometheus.MustRegister(metricSnapshotsStorageBytes)
7792
}

syncer/receiver/receiver.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ func (r *Receiver) RunOnce(ctx context.Context, includingOwn bool) error {
164164
return fmt.Errorf("list snapshots: %w", err)
165165
}
166166

167+
// Update snapshot metrics
168+
metricSnapshotsStorageCount.WithLabelValues(r.lmdbname).Set(float64(ls.Len()))
169+
metricSnapshotsStorageBytes.WithLabelValues(r.lmdbname).Set(float64(ls.Size()))
170+
167171
// Signal success to health tracker
168172
r.storageListHealth.AddSuccess()
169173

0 commit comments

Comments
 (0)