Skip to content

Commit

Permalink
fix the linter
Browse files Browse the repository at this point in the history
Signed-off-by: hfuss <hayden.fuss@kaleido.io>
  • Loading branch information
onelapahead committed Dec 13, 2024
1 parent 8008940 commit 34ccee1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
10 changes: 10 additions & 0 deletions firefly-common.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
14 changes: 8 additions & 6 deletions pkg/metric/prometheusMetricsManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import (
"github.com/prometheus/client_golang/prometheus"
)

var supportedTypes = []string{"counterVec", "gaugeVec", "histogramVec", "summaryVec"}
const gaugeVec = "gaugeVec"

var supportedTypes = []string{"counterVec", gaugeVec, "histogramVec", "summaryVec"}

const fireflySystemLabelsPrefix = "ff_"
const namespaceLabel = fireflySystemLabelsPrefix + "namespace"
Expand Down Expand Up @@ -109,7 +111,7 @@ func (pmm *prometheusMetricsManager) NewGaugeMetric(ctx context.Context, metricN
}
func (pmm *prometheusMetricsManager) NewGaugeMetricWithLabels(ctx context.Context, metricName string, helpText string, labelNames []string, withDefaultLabels bool) {
pmm.registerMetrics(ctx, regInfo{
Type: "gaugeVec",
Type: gaugeVec,
Name: metricName,
HelpText: helpText,
LabelNames: checkAndUpdateLabelNames(ctx, labelNames, withDefaultLabels),
Expand Down Expand Up @@ -182,7 +184,7 @@ func (pmm *prometheusMetricsManager) registerMetrics(ctx context.Context, mr reg
}, mr.LabelNames),
LabelNames: mr.LabelNames,
}
case "gaugeVec":
case gaugeVec:
pmm.metricsMap[internalMapIndex] = &prometheusMetric{
Metric: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: pmm.namespace,
Expand Down Expand Up @@ -232,7 +234,7 @@ func (pmm *prometheusMetricsManager) DecGaugeMetric(ctx context.Context, metricN
}

func (pmm *prometheusMetricsManager) SetGaugeMetricWithLabels(ctx context.Context, metricName string, number float64, labels map[string]string, defaultLabels *FireflyDefaultLabels) {
m, ok := pmm.metricsMap[metricName+"_gaugeVec"]
m, ok := pmm.metricsMap[metricName+"_"+gaugeVec]
if !ok {
log.L(ctx).Warnf("metric with name: '%s' and type: '%s' is not found", metricName, "gaugeVec")
} else {
Expand All @@ -243,7 +245,7 @@ func (pmm *prometheusMetricsManager) SetGaugeMetricWithLabels(ctx context.Contex
}

func (pmm *prometheusMetricsManager) IncGaugeMetricWithLabels(ctx context.Context, metricName string, labels map[string]string, defaultLabels *FireflyDefaultLabels) {
m, ok := pmm.metricsMap[metricName+"_gaugeVec"]
m, ok := pmm.metricsMap[metricName+"_"+gaugeVec]
if !ok {
log.L(ctx).Warnf("metric with name: '%s' and type: '%s' is not found", metricName, "gaugeVec")
} else {
Expand All @@ -254,7 +256,7 @@ func (pmm *prometheusMetricsManager) IncGaugeMetricWithLabels(ctx context.Contex
}

func (pmm *prometheusMetricsManager) DecGaugeMetricWithLabels(ctx context.Context, metricName string, labels map[string]string, defaultLabels *FireflyDefaultLabels) {
m, ok := pmm.metricsMap[metricName+"_gaugeVec"]
m, ok := pmm.metricsMap[metricName+"_"+gaugeVec]
if !ok {
log.L(ctx).Warnf("metric with name: '%s' and type: '%s' is not found", metricName, "gaugeVec")
} else {
Expand Down

0 comments on commit 34ccee1

Please sign in to comment.