Handle conflicts (#244) * Handle conflicts * Update go mod file versions * Make lint changes Disassociate block number from the indexer object Update ipld-eth-db ref Refactor builder code to make it reusable Use prefix comparison for account selective statediffing Update builder unit tests Add mode to write to CSV files in statediff file writer (#249) * Change file writing mode to csv files * Implement writer interface for file indexer * Implement option for csv or sql in file mode * Close files in CSV writer * Add tests for CSV file mode * Implement CSV file for watched addresses * Separate test configs for CSV and SQL * Refactor common code for file indexer tests Update indexer to include block hash in receipts and logs (#256) * Update indexer to include block hash in receipts and logs * Upgrade ipld-eth-db image in docker-compose to run tests Use watched addresses from direct indexing params by default while serving statediff APIs (#262) * Use watched addresses from direct indexing params in statediff APIs by default * Avoid using indexer object when direct indexing is off * Add nil check before accessing watched addresses from direct indexing params
95 lines
3.4 KiB
Go
95 lines
3.4 KiB
Go
// VulcanizeDB
|
|
// Copyright © 2021 Vulcanize
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
package dump
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/ethereum/go-ethereum/metrics"
|
|
)
|
|
|
|
const (
|
|
namespace = "statediff"
|
|
)
|
|
|
|
// Build a fully qualified metric name
|
|
func metricName(subsystem, name string) string {
|
|
if name == "" {
|
|
return ""
|
|
}
|
|
parts := []string{namespace, name}
|
|
if subsystem != "" {
|
|
parts = []string{namespace, subsystem, name}
|
|
}
|
|
// Prometheus uses _ but geth metrics uses / and replaces
|
|
return strings.Join(parts, "/")
|
|
}
|
|
|
|
type indexerMetricsHandles struct {
|
|
// The total number of processed blocks
|
|
blocks metrics.Counter
|
|
// The total number of processed transactions
|
|
transactions metrics.Counter
|
|
// The total number of processed receipts
|
|
receipts metrics.Counter
|
|
// The total number of processed logs
|
|
logs metrics.Counter
|
|
// The total number of access list entries processed
|
|
accessListEntries metrics.Counter
|
|
// Time spent waiting for free postgres tx
|
|
tFreePostgres metrics.Timer
|
|
// Postgres transaction commit duration
|
|
tPostgresCommit metrics.Timer
|
|
// Header processing time
|
|
tHeaderProcessing metrics.Timer
|
|
// Uncle processing time
|
|
tUncleProcessing metrics.Timer
|
|
// Tx and receipt processing time
|
|
tTxAndRecProcessing metrics.Timer
|
|
// State, storage, and code combined processing time
|
|
tStateStoreCodeProcessing metrics.Timer
|
|
}
|
|
|
|
func RegisterIndexerMetrics(reg metrics.Registry) indexerMetricsHandles {
|
|
ctx := indexerMetricsHandles{
|
|
blocks: metrics.NewCounter(),
|
|
transactions: metrics.NewCounter(),
|
|
receipts: metrics.NewCounter(),
|
|
logs: metrics.NewCounter(),
|
|
accessListEntries: metrics.NewCounter(),
|
|
tFreePostgres: metrics.NewTimer(),
|
|
tPostgresCommit: metrics.NewTimer(),
|
|
tHeaderProcessing: metrics.NewTimer(),
|
|
tUncleProcessing: metrics.NewTimer(),
|
|
tTxAndRecProcessing: metrics.NewTimer(),
|
|
tStateStoreCodeProcessing: metrics.NewTimer(),
|
|
}
|
|
subsys := "indexer"
|
|
reg.Register(metricName(subsys, "blocks"), ctx.blocks)
|
|
reg.Register(metricName(subsys, "transactions"), ctx.transactions)
|
|
reg.Register(metricName(subsys, "receipts"), ctx.receipts)
|
|
reg.Register(metricName(subsys, "logs"), ctx.logs)
|
|
reg.Register(metricName(subsys, "access_list_entries"), ctx.accessListEntries)
|
|
reg.Register(metricName(subsys, "t_free_postgres"), ctx.tFreePostgres)
|
|
reg.Register(metricName(subsys, "t_postgres_commit"), ctx.tPostgresCommit)
|
|
reg.Register(metricName(subsys, "t_header_processing"), ctx.tHeaderProcessing)
|
|
reg.Register(metricName(subsys, "t_uncle_processing"), ctx.tUncleProcessing)
|
|
reg.Register(metricName(subsys, "t_tx_receipt_processing"), ctx.tTxAndRecProcessing)
|
|
reg.Register(metricName(subsys, "t_state_store_code_processing"), ctx.tStateStoreCodeProcessing)
|
|
return ctx
|
|
}
|