Skip to content

Commit

Permalink
fix: provider block height indicators label
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanViast committed Nov 8, 2024
1 parent e3f9091 commit 791153d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion pkg/filters/proxies/providerproxy/providerproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,15 @@ func (m *ProviderProxy) reload() {
m.client = client

providerSelectorSpec := selector.ProviderSelectorSpec{
Name: m.spec.BaseSpec.Name(),
Urls: m.spec.Urls,
Interval: m.spec.Interval,
Lag: m.spec.Lag,
}

m.metrics = m.newMetrics()

providerSelector := selector.CreateProviderSelectorByPolicy(m.spec.Policy, providerSelectorSpec, m.super)
providerSelector := selector.CreateProviderSelectorByPolicy(m.spec.Policy, providerSelectorSpec)
m.providerSelector = providerSelector
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

"github.com/ethereum/go-ethereum/core/types"
"github.com/megaease/easegress/v2/pkg/logger"
"github.com/megaease/easegress/v2/pkg/supervisor"
"github.com/megaease/easegress/v2/pkg/util/prometheushelper"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/sync/errgroup"
Expand All @@ -44,7 +43,7 @@ type BlockLagProviderSelector struct {
metrics *metrics
}

func NewBlockLagProviderSelector(spec ProviderSelectorSpec, super *supervisor.Supervisor) ProviderSelector {
func NewBlockLagProviderSelector(spec ProviderSelectorSpec) ProviderSelector {

providers := make([]ProviderWeight, 0)

Expand All @@ -67,7 +66,7 @@ func NewBlockLagProviderSelector(spec ProviderSelectorSpec, super *supervisor.Su
done: make(chan struct{}),
providers: providers,
lag: spec.Lag,
metrics: newMetrics(super),
metrics: newMetrics(spec),
}
ticker := time.NewTicker(intervalDuration)
ps.checkServers()
Expand Down Expand Up @@ -177,9 +176,9 @@ type metrics struct {
ProviderBlockHeight *prometheus.GaugeVec
}

func newMetrics(super *supervisor.Supervisor) *metrics {
func newMetrics(spec ProviderSelectorSpec) *metrics {
commonLabels := prometheus.Labels{
"pipelineName": super.Options().Name,
"pipelineName": spec.Name,
"kind": "BlockLagProviderSelector",
}
prometheusLabels := []string{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ package selector

import (
"time"

"github.com/megaease/easegress/v2/pkg/supervisor"
)

type ProviderSelectorSpec struct {
Name string `json:"name"`
Urls []string `json:"urls"`
Interval string `json:"interval,omitempty" jsonschema:"format=duration"`
Lag uint64 `json:"lag,omitempty" jsonschema:"default=100"`
Expand All @@ -43,10 +42,10 @@ type ProviderSelector interface {
Close()
}

func CreateProviderSelectorByPolicy(policy string, spec ProviderSelectorSpec, super *supervisor.Supervisor) ProviderSelector {
func CreateProviderSelectorByPolicy(policy string, spec ProviderSelectorSpec) ProviderSelector {
switch policy {
case "blockLag":
return NewBlockLagProviderSelector(spec, super)
return NewBlockLagProviderSelector(spec)
case "roundRobin":
return NewRoundRobinProviderSelector(spec)
default:
Expand Down

0 comments on commit 791153d

Please sign in to comment.