Fix cache and metrics environments in fly (#490)
This commit is contained in:
parent
c3d418a084
commit
fc28528e0d
|
@ -1,4 +1,4 @@
|
|||
ENVIRONMENT=production
|
||||
ENVIRONMENT=production-mainnet
|
||||
NAMESPACE=wormscan
|
||||
NAME=wormscan-fly
|
||||
REPLICAS=5
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
ENVIRONMENT=staging
|
||||
ENVIRONMENT=staging-mainnet
|
||||
NAMESPACE=wormscan
|
||||
NAME=wormscan-fly
|
||||
REPLICAS=3
|
||||
|
|
|
@ -67,6 +67,11 @@ spec:
|
|||
configMapKeyRef:
|
||||
name: config
|
||||
key: redis-uri
|
||||
- name: REDIS_PREFIX
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: config
|
||||
key: redis-prefix
|
||||
- name: MAX_HEALTH_TIME_SECONDS
|
||||
value: "{{ .MAX_HEALTH_TIME_SECONDS }}"
|
||||
- name: ALERT_API_KEY
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package metrics
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
sdk "github.com/wormhole-foundation/wormhole/sdk/vaa"
|
||||
|
@ -20,14 +18,13 @@ type PrometheusMetrics struct {
|
|||
}
|
||||
|
||||
// NewPrometheusMetrics returns a new instance of PrometheusMetrics.
|
||||
func NewPrometheusMetrics(environment string, p2pNetwork string) *PrometheusMetrics {
|
||||
metricsEnviroment := getMetricsEnviroment(environment, p2pNetwork)
|
||||
func NewPrometheusMetrics(environment string) *PrometheusMetrics {
|
||||
vaaReceivedCount := promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "vaa_count_by_chain",
|
||||
Help: "Total number of vaa by chain",
|
||||
ConstLabels: map[string]string{
|
||||
"environment": metricsEnviroment,
|
||||
"environment": environment,
|
||||
"service": serviceName,
|
||||
},
|
||||
}, []string{"chain", "type"})
|
||||
|
@ -37,7 +34,7 @@ func NewPrometheusMetrics(environment string, p2pNetwork string) *PrometheusMetr
|
|||
Name: "vaa_total",
|
||||
Help: "Total number of vaa from Gossip network",
|
||||
ConstLabels: map[string]string{
|
||||
"environment": metricsEnviroment,
|
||||
"environment": environment,
|
||||
"service": serviceName,
|
||||
},
|
||||
})
|
||||
|
@ -47,7 +44,7 @@ func NewPrometheusMetrics(environment string, p2pNetwork string) *PrometheusMetr
|
|||
Name: "observation_count_by_chain",
|
||||
Help: "Total number of observation by chain",
|
||||
ConstLabels: map[string]string{
|
||||
"environment": metricsEnviroment,
|
||||
"environment": environment,
|
||||
"service": serviceName,
|
||||
},
|
||||
}, []string{"chain", "type"})
|
||||
|
@ -57,7 +54,7 @@ func NewPrometheusMetrics(environment string, p2pNetwork string) *PrometheusMetr
|
|||
Name: "observation_total",
|
||||
Help: "Total number of observation from Gossip network",
|
||||
ConstLabels: map[string]string{
|
||||
"environment": metricsEnviroment,
|
||||
"environment": environment,
|
||||
"service": serviceName,
|
||||
},
|
||||
})
|
||||
|
@ -67,7 +64,7 @@ func NewPrometheusMetrics(environment string, p2pNetwork string) *PrometheusMetr
|
|||
Name: "heartbeat_count_by_guardian",
|
||||
Help: "Total number of heartbeat by guardian",
|
||||
ConstLabels: map[string]string{
|
||||
"environment": metricsEnviroment,
|
||||
"environment": environment,
|
||||
"service": serviceName,
|
||||
},
|
||||
}, []string{"guardian_node", "type"})
|
||||
|
@ -77,7 +74,7 @@ func NewPrometheusMetrics(environment string, p2pNetwork string) *PrometheusMetr
|
|||
Name: "governor_config_count_by_guardian",
|
||||
Help: "Total number of governor config by guardian",
|
||||
ConstLabels: map[string]string{
|
||||
"environment": metricsEnviroment,
|
||||
"environment": environment,
|
||||
"service": serviceName,
|
||||
},
|
||||
}, []string{"guardian_node", "type"})
|
||||
|
@ -87,7 +84,7 @@ func NewPrometheusMetrics(environment string, p2pNetwork string) *PrometheusMetr
|
|||
Name: "governor_status_count_by_guardian",
|
||||
Help: "Total number of governor status by guardian",
|
||||
ConstLabels: map[string]string{
|
||||
"environment": metricsEnviroment,
|
||||
"environment": environment,
|
||||
"service": serviceName,
|
||||
},
|
||||
}, []string{"guardian_node", "type"})
|
||||
|
@ -102,14 +99,6 @@ func NewPrometheusMetrics(environment string, p2pNetwork string) *PrometheusMetr
|
|||
}
|
||||
}
|
||||
|
||||
// getMetricsEnviroment returns the enviroment to use in metrics.
|
||||
func getMetricsEnviroment(enviroment, p2pPNetwork string) string {
|
||||
if enviroment == "production" {
|
||||
return fmt.Sprintf("%s-%s", enviroment, p2pPNetwork)
|
||||
}
|
||||
return enviroment
|
||||
}
|
||||
|
||||
// IncVaaFromGossipNetwork increases the number of vaa received by chain from Gossip network.
|
||||
func (m *PrometheusMetrics) IncVaaFromGossipNetwork(chain sdk.ChainID) {
|
||||
m.vaaReceivedCount.WithLabelValues(chain.String(), "gossip").Inc()
|
||||
|
|
17
fly/main.go
17
fly/main.go
|
@ -175,15 +175,19 @@ func newVAANotifierFunc(isLocal bool, logger *zap.Logger) processor.VAANotifyFun
|
|||
}
|
||||
|
||||
redisUri, err := getenv("REDIS_URI")
|
||||
prefix := strings.ToLower(config.GetPrefix())
|
||||
if err != nil {
|
||||
logger.Fatal("could not create vaa notifier ", zap.Error(err))
|
||||
}
|
||||
|
||||
logger.Info("using redis notifier", zap.String("prefix", prefix))
|
||||
redisPrefix, err := getenv("REDIS_PREFIX")
|
||||
if err != nil {
|
||||
logger.Fatal("could not create vaa notifier ", zap.Error(err))
|
||||
}
|
||||
|
||||
logger.Info("using redis notifier", zap.String("prefix", redisPrefix))
|
||||
client := redis.NewClient(&redis.Options{Addr: redisUri})
|
||||
|
||||
return notifier.NewLastSequenceNotifier(client, prefix).Notify
|
||||
return notifier.NewLastSequenceNotifier(client, redisPrefix).Notify
|
||||
}
|
||||
|
||||
func newAlertClient() (alert.AlertClient, error) {
|
||||
|
@ -197,12 +201,12 @@ func newAlertClient() (alert.AlertClient, error) {
|
|||
return alert.NewAlertService(alertConfig, flyAlert.LoadAlerts)
|
||||
}
|
||||
|
||||
func newMetrics(enviroment string, p2pNetwork *config.P2pNetworkConfig) metrics.Metrics {
|
||||
func newMetrics(enviroment string) metrics.Metrics {
|
||||
metricsEnabled := config.GetMetricsEnabled()
|
||||
if !metricsEnabled {
|
||||
return metrics.NewDummyMetrics()
|
||||
}
|
||||
return metrics.NewPrometheusMetrics(enviroment, p2pNetwork.Enviroment)
|
||||
return metrics.NewPrometheusMetrics(enviroment)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -245,7 +249,8 @@ func main() {
|
|||
logger.Fatal("could not create alert client", zap.Error(err))
|
||||
}
|
||||
|
||||
metrics := newMetrics(config.GetEnviroment(), p2pNetworkConfig)
|
||||
// new metrics client
|
||||
metrics := newMetrics(config.GetEnviroment())
|
||||
|
||||
// Setup DB
|
||||
uri := os.Getenv("MONGODB_URI")
|
||||
|
|
Loading…
Reference in New Issue