-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from vulcanize/metrics
Metrics
- Loading branch information
Showing
13 changed files
with
468 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package cmd | ||
|
||
import ( | ||
ind "github.com/ethereum/go-ethereum/statediff/indexer" | ||
"github.com/ethereum/go-ethereum/statediff/indexer/node" | ||
"github.com/ethereum/go-ethereum/statediff/indexer/postgres" | ||
"github.com/ethereum/go-ethereum/trie" | ||
"github.com/spf13/viper" | ||
|
||
sd "github.com/vulcanize/eth-statediff-service/pkg" | ||
"github.com/vulcanize/eth-statediff-service/pkg/prom" | ||
) | ||
|
||
func createStateDiffService() (sd.IService, error) { | ||
logWithCommand.Info("Loading statediff service parameters") | ||
path := viper.GetString("leveldb.path") | ||
ancientPath := viper.GetString("leveldb.ancient") | ||
if path == "" || ancientPath == "" { | ||
logWithCommand.Fatal("require a valid eth leveldb primary datastore path and ancient datastore path") | ||
} | ||
|
||
nodeInfo := GetEthNodeInfo() | ||
config, err := chainConfig(nodeInfo.ChainID) | ||
if err != nil { | ||
logWithCommand.Fatal(err) | ||
} | ||
|
||
// create leveldb reader | ||
logWithCommand.Info("Creating leveldb reader") | ||
conf := sd.ReaderConfig{ | ||
TrieConfig: &trie.Config{ | ||
Cache: viper.GetInt("cache.trie"), | ||
Journal: "", | ||
Preimages: false, | ||
}, | ||
ChainConfig: config, | ||
Path: path, | ||
AncientPath: ancientPath, | ||
DBCacheSize: viper.GetInt("cache.database"), | ||
} | ||
lvlDBReader, err := sd.NewLvlDBReader(conf) | ||
if err != nil { | ||
logWithCommand.Fatal(err) | ||
} | ||
|
||
// create statediff service | ||
logWithCommand.Info("Creating statediff service") | ||
db, err := setupPostgres(nodeInfo) | ||
if err != nil { | ||
logWithCommand.Fatal(err) | ||
} | ||
indexer, err := ind.NewStateDiffIndexer(config, db) | ||
if err != nil { | ||
logWithCommand.Fatal(err) | ||
} | ||
return sd.NewStateDiffService(lvlDBReader, indexer, viper.GetUint("statediff.workers")) | ||
} | ||
|
||
func setupPostgres(nodeInfo node.Info) (*postgres.DB, error) { | ||
params := GetDBParams() | ||
db, err := postgres.NewDB(postgres.DbConnectionString(params), GetDBConfig(), nodeInfo) | ||
if err != nil { | ||
return nil, err | ||
} | ||
prom.RegisterDBCollector(params.Name, db.DB) | ||
return db, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,9 @@ | |
[cache] | ||
database = 1024 | ||
trie = 1024 | ||
|
||
[prom] | ||
metrics = true | ||
http = true | ||
addr = "localhost" | ||
port = "8889" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
global: | ||
scrape_interval: 10s | ||
|
||
scrape_configs: | ||
- job_name: 'eth-statediff-service' | ||
static_configs: | ||
- targets: ['localhost:8100'] |
Oops, something went wrong.