Skip to content

Commit

Permalink
Merge pull request #5 from axieinfinity/bugfix/metrics
Browse files Browse the repository at this point in the history
Added flag to turn on / off prometheus
  • Loading branch information
ssscrom committed Aug 26, 2022
2 parents ae2dfff + 91e0bf1 commit affff8f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions adapters/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Prometheus struct {
PushURL string `default:"localhost:9091" envconfig:"PUSH_URL"`
PushJob string `default:"sm-bridge-v2" envconfig:"PUSH_JOB"`
PushInterval int `default:"15" envconfig:"PUSH_INTERVAl"`
TurnOn bool `envconfig:"PROMETHEUS_TURN_ON"`
}

func New() (*Config, error) {
Expand Down
14 changes: 9 additions & 5 deletions controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ package internal
import (
"context"
"errors"
"github.com/axieinfinity/bridge-contracts"
"github.com/axieinfinity/bridge-core/metrics"
"github.com/axieinfinity/bridge-core/stores"
"github.com/axieinfinity/bridge-core/utils"
"strings"
"sync"
"sync/atomic"
"time"

bridge_contracts "github.com/axieinfinity/bridge-contracts"
"github.com/axieinfinity/bridge-core/adapters"
"github.com/axieinfinity/bridge-core/metrics"
"github.com/axieinfinity/bridge-core/stores"
"github.com/axieinfinity/bridge-core/utils"

"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -101,7 +103,9 @@ func New(cfg *Config, db *gorm.DB, helpers utils.Utils) (*Controller, error) {
hasSubscriptionType: make(map[string]map[int]bool),
}

metrics.RunPusher(ctx)
if adapters.AppConfig.Prometheus.TurnOn {
metrics.RunPusher(ctx)
}

c.isClosed.Store(false)
if helpers != nil {
Expand Down

0 comments on commit affff8f

Please sign in to comment.