Skip to content

Commit 5851fb2

Browse files
authored
Add custom on chain target prom, specify container name for blockchains (#2122)
add custom on-chain-metrics target for both local and Dockerized version, add container name field for blockchains
1 parent 267df19 commit 5851fb2

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

framework/.changeset/v0.10.24.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- On chain metrics scrape targets
2+
- Allow to specify custom names for blockchain containers

framework/components/blockchain/blockchain.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ const (
3434
// Input is a blockchain network configuration params
3535
type Input struct {
3636
// Common EVM fields
37-
Type string `toml:"type" validate:"required,oneof=anvil geth besu solana aptos tron sui ton" envconfig:"net_type"`
38-
Image string `toml:"image"`
39-
PullImage bool `toml:"pull_image"`
40-
Port string `toml:"port"`
37+
Type string `toml:"type" validate:"required,oneof=anvil geth besu solana aptos tron sui ton" envconfig:"net_type"`
38+
Image string `toml:"image"`
39+
PullImage bool `toml:"pull_image"`
40+
Port string `toml:"port"`
41+
ContainerName string `toml:"container_name"`
4142
// Not applicable to Solana, ws port for Solana is +1 of port
4243
WSPort string `toml:"port_ws"`
4344
ChainID string `toml:"chain_id"`

framework/components/blockchain/containers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ const (
2424

2525
func baseRequest(in *Input, useWS ExposeWs) testcontainers.ContainerRequest {
2626
containerName := framework.DefaultTCName("blockchain-node")
27+
if in.ContainerName != "" {
28+
containerName = in.ContainerName
29+
}
2730
bindPort := fmt.Sprintf("%s/tcp", in.Port)
2831
exposedPorts := []string{bindPort}
2932
if useWS {

framework/observability/compose/conf/prometheus.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ global:
22
scrape_interval: 10s
33

44
scrape_configs:
5+
- job_name: 'on-chain-metrics'
6+
metrics_path: /on-chain-metrics
7+
scrape_interval: 2s
8+
static_configs:
9+
- targets: [ 'host.docker.internal:9112', '172.17.0.1:9112']
510
- job_name: 'otel-collector'
611
scrape_interval: 10s
712
static_configs:

0 commit comments

Comments
 (0)