Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: traces block height and timestamp for InfluxDB #1062

Merged
merged 9 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,9 @@ func (cs *State) finalizeCommit(height int64) {
// must be called before we update state
cs.recordMetrics(height, block)

// trace some metadata about the block
schema.WriteBlock(cs.traceClient, block.Header.Height, block.Header.Time)

// NewHeightStep!
cs.updateToState(stateCopy)

Expand Down
22 changes: 22 additions & 0 deletions pkg/trace/schema/consensus.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package schema

import (
"time"

cstypes "github.com/tendermint/tendermint/consensus/types"
"github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/pkg/trace"
Expand All @@ -12,6 +14,7 @@ func ConsensusTables() []string {
return []string{
RoundStateTable,
BlockPartsTable,
BlockTable,
}
}

Expand Down Expand Up @@ -81,3 +84,22 @@ func WriteBlockPart(
TransferTypeFieldKey: transferType,
})
}

const (
// BlockTable is the name of the table that stores metadata about consensus blocks.
// following schema:
//
// | time | height | timestamp |
BlockTable = "consensus_block_time"

// TimestampFieldKey is the name of the field that stores the time at which
// the block is proposed.
TimestampFieldKey = "timestamp"
)

func WriteBlock(client *trace.Client, height int64, blockTimestamp time.Time) {
client.WritePoint(BlockTable, map[string]interface{}{
HeightFieldKey: height,
TimestampFieldKey: blockTimestamp,
})
}
Loading