Skip to content

Commit

Permalink
Update metricName to externalMetricName (internally) in artemis and r…
Browse files Browse the repository at this point in the history
…abbit

Signed-off-by: jorturfer <jorge_turrado@hotmail.es>
  • Loading branch information
JorTurFer committed Oct 6, 2021
1 parent 7491aa3 commit 7a9b018
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions pkg/scalers/artemis_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type artemisMetadata struct {
restAPITemplate string
queueLength int
corsHeader string
metricName string
externalMetricName string
}

//revive:enable:var-naming
Expand Down Expand Up @@ -151,10 +151,10 @@ func parseArtemisMetadata(config *ScalerConfig) (*artemisMetadata, error) {
return nil, fmt.Errorf("password cannot be empty")
}

meta.metricName = kedautil.NormalizeString(fmt.Sprintf("%s-%s-%s", "artemis", meta.brokerName, meta.queueName))
meta.externalMetricName = kedautil.NormalizeString(fmt.Sprintf("%s-%s-%s", "artemis", meta.brokerName, meta.queueName))

// Update metricName with the index
meta.metricName = GenerateMetricNameWithIndex(config, meta.metricName)
meta.externalMetricName = GenerateMetricNameWithIndex(config, meta.externalMetricName)

return &meta, nil
}
Expand Down Expand Up @@ -221,7 +221,7 @@ func (s *artemisScaler) GetMetricSpecForScaling() []v2beta2.MetricSpec {
targetMetricValue := resource.NewQuantity(int64(s.metadata.queueLength), resource.DecimalSI)
externalMetric := &v2beta2.ExternalMetricSource{
Metric: v2beta2.MetricIdentifier{
Name: s.metadata.metricName,
Name: s.metadata.externalMetricName,
},
Target: v2beta2.MetricTarget{
Type: v2beta2.AverageValueMetricType,
Expand Down
34 changes: 17 additions & 17 deletions pkg/scalers/rabbitmq_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ type rabbitMQScaler struct {
}

type rabbitMQMetadata struct {
queueName string
mode string // QueueLength or MessageRate
value int // trigger value (queue length or publish/sec. rate)
host string // connection string for either HTTP or AMQP protocol
protocol string // either http or amqp protocol
vhostName *string // override the vhost from the connection info
useRegex bool // specify if the queueName contains a rexeg
operation string // specify the operation to apply in case of multiples queues
metricName string // custom metric name for trigger
timeout time.Duration // custom http timeout for a specific trigger
queueName string
mode string // QueueLength or MessageRate
value int // trigger value (queue length or publish/sec. rate)
host string // connection string for either HTTP or AMQP protocol
protocol string // either http or amqp protocol
vhostName *string // override the vhost from the connection info
useRegex bool // specify if the queueName contains a rexeg
operation string // specify the operation to apply in case of multiples queues
externalMetricName string // external metric name for trigger
timeout time.Duration // custom http timeout for a specific trigger
}

type queueInfo struct {
Expand Down Expand Up @@ -212,19 +212,19 @@ func parseRabbitMQMetadata(config *ScalerConfig) (*rabbitMQMetadata, error) {
return nil, fmt.Errorf("unable to parse trigger: %s", err)
}

// Resolve metricName
// Resolve externalMetricName
if val, ok := config.TriggerMetadata["metricName"]; ok {
meta.metricName = kedautil.NormalizeString(fmt.Sprintf("%s-%s", "rabbitmq", url.QueryEscape(val)))
meta.externalMetricName = kedautil.NormalizeString(fmt.Sprintf("%s-%s", "rabbitmq", url.QueryEscape(val)))
} else {
if meta.mode == rabbitModeQueueLength {
meta.metricName = kedautil.NormalizeString(fmt.Sprintf("%s-%s", "rabbitmq", url.QueryEscape(meta.queueName)))
meta.externalMetricName = kedautil.NormalizeString(fmt.Sprintf("%s-%s", "rabbitmq", url.QueryEscape(meta.queueName)))
} else {
meta.metricName = kedautil.NormalizeString(fmt.Sprintf("%s-%s", "rabbitmq-rate", url.QueryEscape(meta.queueName)))
meta.externalMetricName = kedautil.NormalizeString(fmt.Sprintf("%s-%s", "rabbitmq-rate", url.QueryEscape(meta.queueName)))
}
}

// Update metricName with the index
meta.metricName = GenerateMetricNameWithIndex(config, meta.metricName)
// Update externalMetricName with the index
meta.externalMetricName = GenerateMetricNameWithIndex(config, meta.externalMetricName)

// Resolve timeout
if val, ok := config.TriggerMetadata["timeout"]; ok {
Expand Down Expand Up @@ -436,7 +436,7 @@ func (s *rabbitMQScaler) GetMetricSpecForScaling() []v2beta2.MetricSpec {

externalMetric := &v2beta2.ExternalMetricSource{
Metric: v2beta2.MetricIdentifier{
Name: s.metadata.metricName,
Name: s.metadata.externalMetricName,
},
Target: v2beta2.MetricTarget{
Type: v2beta2.AverageValueMetricType,
Expand Down

0 comments on commit 7a9b018

Please sign in to comment.