Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Solace Direct Messaging Scaler #6546

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

alfonso-chacon
Copy link

@alfonso-chacon alfonso-chacon commented Feb 12, 2025

New Solace Direct Messaging Scaler Added

Checklist

Fixes #

Relates to #
[#6545] (#6545) - Issue
[#1537] (kedacore/keda-docs#1537) - Documentation

Signed-off-by: Alfonso Chacón <[email protected]>
Signed-off-by: Alfonso Chacón <[email protected]>
Signed-off-by: Alfonso Chacón <[email protected]>
…scarded messages while scaling up

Signed-off-by: Alfonso Chacón <[email protected]>
- Added Configuration validations
- Variables Refactor
- Multiple URLs
- Remove commented blocks

Signed-off-by: Alfonso Chacón <[email protected]>
Signed-off-by: Alfonso Chacón <[email protected]>
* Code Cleanup - CodeQL/StaticChecks
Signed-off-by: Alfonso Chacón <[email protected]>
* Code cleanup /golangci-lint
Signed-off-by: Alfonso Chacón <[email protected]>
Signed-off-by: Alfonso Chacón <[email protected]>
@alfonso-chacon alfonso-chacon marked this pull request as ready for review February 13, 2025 04:27
@alfonso-chacon alfonso-chacon requested a review from a team as a code owner February 13, 2025 04:27
return meta, nil
}

// Interface required method!!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Interface required method!!

Comment on lines +381 to +432
if s.configuration.AggregatedClientTxByteRateTarget > 0 {
metricName := kedautil.NormalizeString(fmt.Sprintf("solace-dm-%s-%s", clientNamePattern, aggregatedClientTxByteRateTargetMetricName))
externalMetric := &v2.ExternalMetricSource{
Metric: v2.MetricIdentifier{
Name: GenerateMetricNameWithIndex(triggerIndex, metricName),
},
Target: GetMetricTarget(s.metricType, s.configuration.AggregatedClientTxByteRateTarget),
}
metricSpec := v2.MetricSpec{External: externalMetric, Type: solaceDMExternalMetricType}
metricSpecList = append(metricSpecList, metricSpec)
}
//
// Target Client AverageTxByteRate
if s.configuration.AggregatedClientAverageTxByteRateTarget > 0 {
metricName := kedautil.NormalizeString(fmt.Sprintf("solace-dm-%s-%s", clientNamePattern, aggregatedClientAverageTxByteRateTargetMetricName))
externalMetric := &v2.ExternalMetricSource{
Metric: v2.MetricIdentifier{
Name: GenerateMetricNameWithIndex(triggerIndex, metricName),
},
Target: GetMetricTarget(s.metricType, s.configuration.AggregatedClientAverageTxByteRateTarget),
}
metricSpec := v2.MetricSpec{External: externalMetric, Type: solaceDMExternalMetricType}
metricSpecList = append(metricSpecList, metricSpec)
}
//
// Target Client TxMsgRate
if s.configuration.AggregatedClientTxMsgRateTarget > 0 {
metricName := kedautil.NormalizeString(fmt.Sprintf("solace-dm-%s-%s", clientNamePattern, aggregatedClientTxMsgRateTargetMetricName))
externalMetric := &v2.ExternalMetricSource{
Metric: v2.MetricIdentifier{
Name: GenerateMetricNameWithIndex(triggerIndex, metricName),
},
Target: GetMetricTarget(s.metricType, s.configuration.AggregatedClientTxMsgRateTarget),
}
metricSpec := v2.MetricSpec{External: externalMetric, Type: solaceDMExternalMetricType}
metricSpecList = append(metricSpecList, metricSpec)
}
//
// Target Client AverageTxMsgRate
if s.configuration.AggregatedClientAverageTxMsgRateTarget > 0 {
metricName := kedautil.NormalizeString(fmt.Sprintf("solace-dm-%s-%s", clientNamePattern, aggregatedClientAverageTxMsgRateTargetMetricName))
externalMetric := &v2.ExternalMetricSource{
Metric: v2.MetricIdentifier{
Name: GenerateMetricNameWithIndex(triggerIndex, metricName),
},
Target: GetMetricTarget(s.metricType, s.configuration.AggregatedClientAverageTxMsgRateTarget),
}
metricSpec := v2.MetricSpec{External: externalMetric, Type: solaceDMExternalMetricType}
metricSpecList = append(metricSpecList, metricSpec)
}

return metricSpecList
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's unify this code just calculating the metricName and the value for the target with the ifs and unifying the other code:

Suggested change
if s.configuration.AggregatedClientTxByteRateTarget > 0 {
metricName := kedautil.NormalizeString(fmt.Sprintf("solace-dm-%s-%s", clientNamePattern, aggregatedClientTxByteRateTargetMetricName))
externalMetric := &v2.ExternalMetricSource{
Metric: v2.MetricIdentifier{
Name: GenerateMetricNameWithIndex(triggerIndex, metricName),
},
Target: GetMetricTarget(s.metricType, s.configuration.AggregatedClientTxByteRateTarget),
}
metricSpec := v2.MetricSpec{External: externalMetric, Type: solaceDMExternalMetricType}
metricSpecList = append(metricSpecList, metricSpec)
}
//
// Target Client AverageTxByteRate
if s.configuration.AggregatedClientAverageTxByteRateTarget > 0 {
metricName := kedautil.NormalizeString(fmt.Sprintf("solace-dm-%s-%s", clientNamePattern, aggregatedClientAverageTxByteRateTargetMetricName))
externalMetric := &v2.ExternalMetricSource{
Metric: v2.MetricIdentifier{
Name: GenerateMetricNameWithIndex(triggerIndex, metricName),
},
Target: GetMetricTarget(s.metricType, s.configuration.AggregatedClientAverageTxByteRateTarget),
}
metricSpec := v2.MetricSpec{External: externalMetric, Type: solaceDMExternalMetricType}
metricSpecList = append(metricSpecList, metricSpec)
}
//
// Target Client TxMsgRate
if s.configuration.AggregatedClientTxMsgRateTarget > 0 {
metricName := kedautil.NormalizeString(fmt.Sprintf("solace-dm-%s-%s", clientNamePattern, aggregatedClientTxMsgRateTargetMetricName))
externalMetric := &v2.ExternalMetricSource{
Metric: v2.MetricIdentifier{
Name: GenerateMetricNameWithIndex(triggerIndex, metricName),
},
Target: GetMetricTarget(s.metricType, s.configuration.AggregatedClientTxMsgRateTarget),
}
metricSpec := v2.MetricSpec{External: externalMetric, Type: solaceDMExternalMetricType}
metricSpecList = append(metricSpecList, metricSpec)
}
//
// Target Client AverageTxMsgRate
if s.configuration.AggregatedClientAverageTxMsgRateTarget > 0 {
metricName := kedautil.NormalizeString(fmt.Sprintf("solace-dm-%s-%s", clientNamePattern, aggregatedClientAverageTxMsgRateTargetMetricName))
externalMetric := &v2.ExternalMetricSource{
Metric: v2.MetricIdentifier{
Name: GenerateMetricNameWithIndex(triggerIndex, metricName),
},
Target: GetMetricTarget(s.metricType, s.configuration.AggregatedClientAverageTxMsgRateTarget),
}
metricSpec := v2.MetricSpec{External: externalMetric, Type: solaceDMExternalMetricType}
metricSpecList = append(metricSpecList, metricSpec)
}
return metricSpecList
metricName := ""
target := 1
if s.configuration.AggregatedClientTxByteRateTarget > 0 {
metricName : kedautil.NormalizeString(fmt.Sprintf("solace-dm-%s-%s", clientNamePattern, aggregatedClientTxByteRateTargetMetricName))
target = s.configuration.AggregatedClientTxByteRateTarget
}
//
// Target Client AverageTxByteRate
if s.configuration.AggregatedClientAverageTxByteRateTarget > 0 {
metricName = kedautil.NormalizeString(fmt.Sprintf("solace-dm-%s-%s", clientNamePattern, aggregatedClientAverageTxByteRateTargetMetricName))
target = s.configuration.AggregatedClientAverageTxByteRateTarget
}
//
// Target Client TxMsgRate
if s.configuration.AggregatedClientTxMsgRateTarget > 0 {
metricName = kedautil.NormalizeString(fmt.Sprintf("solace-dm-%s-%s", clientNamePattern, aggregatedClientTxMsgRateTargetMetricName))
target = s.configuration.AggregatedClientTxMsgRateTarget
}
//
// Target Client AverageTxMsgRate
if s.configuration.AggregatedClientAverageTxMsgRateTarget > 0 {
metricName = kedautil.NormalizeString(fmt.Sprintf("solace-dm-%s-%s", clientNamePattern, aggregatedClientAverageTxMsgRateTargetMetricName))
target = s.configuration.AggregatedClientAverageTxMsgRateTarget
}
externalMetric := &v2.ExternalMetricSource{
Metric: v2.MetricIdentifier{
Name: GenerateMetricNameWithIndex(triggerIndex, metricName),
},
Target: GetMetricTarget(s.metricType, target),
}
metricSpec := v2.MetricSpec{External: externalMetric, Type: solaceDMExternalMetricType}
metricSpecList = append(metricSpecList, metricSpec)
return metricSpecList

return metricSpecList
}

// Interface required method!!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Interface required method!!

return []external_metrics.ExternalMetricValue{}, false, err
}

s.logger.Info(fmt.Sprintf("Metrics: '%s'", metricValues))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move to debug

Suggested change
s.logger.Info(fmt.Sprintf("Metrics: '%s'", metricValues))
s.logger.V(1).Info(fmt.Sprintf("Metrics: '%s'", metricValues))

return []external_metrics.ExternalMetricValue{metric}, true, nil
}

// Interface required method!!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Interface required method!!

@JorTurFer
Copy link
Member

JorTurFer commented Feb 14, 2025

/run-e2e solace_dm
Update: You can check the progress here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants