Skip to content

Commit

Permalink
Merge pull request #726 from rqlite/legacy-metrics
Browse files Browse the repository at this point in the history
Count number of legacy commands unmarshaled
  • Loading branch information
otoolep committed Jan 5, 2021
2 parents 10a24cf + 8cb88d7 commit f9b6eb8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion store/store.go
Expand Up @@ -67,6 +67,7 @@ const (
numRestores = "num_restores"
numUncompressedCommands = "num_uncompressed_commands"
numCompressedCommands = "num_compressed_commands"
numLegacyCommands = "num_legacy_commands"
)

// BackupFormat represents the format of database backup.
Expand All @@ -90,6 +91,7 @@ func init() {
stats.Add(numRestores, 0)
stats.Add(numUncompressedCommands, 0)
stats.Add(numCompressedCommands, 0)
stats.Add(numLegacyCommands, 0)
}

// ClusterState defines the possible Raft states the current node can be in
Expand Down Expand Up @@ -855,8 +857,11 @@ func (s *Store) Apply(l *raft.Log) interface{} {

if err := legacy.Unmarshal(l.Data, &c); err != nil {
if err2 := command.Unmarshal(l.Data, &c); err2 != nil {
panic(fmt.Sprintf("failed to unmarshal cluster command: %s (legacy unmarshal: %s)", err2.Error(), err.Error()))
panic(fmt.Sprintf("failed to unmarshal cluster command: %s (legacy unmarshal: %s)",
err2.Error(), err.Error()))
}
} else {
stats.Add(numLegacyCommands, 1)
}

switch c.Type {
Expand Down

0 comments on commit f9b6eb8

Please sign in to comment.