Skip to content

Commit

Permalink
Remove unused function from prometheus helper
Browse files Browse the repository at this point in the history
  • Loading branch information
kuskoman committed Mar 24, 2023
1 parent 0a5dc83 commit 31b8bcc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
6 changes: 0 additions & 6 deletions prometheus_helper/prometheus_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ type SimpleDescHelper struct {
Subsystem string
}

// NewDesc creates a new prometheus.Desc with the namespace and subsystem. The help text is set to the name.
func (h *SimpleDescHelper) NewDesc(name string) *prometheus.Desc {
help := name
return prometheus.NewDesc(prometheus.BuildFQName(h.Namespace, h.Subsystem, name), help, nil, nil)
}

// NewDescWithHelp creates a new prometheus.Desc with the namespace and subsystem.
func (h *SimpleDescHelper) NewDescWithHelp(name string, help string) *prometheus.Desc {
return prometheus.NewDesc(prometheus.BuildFQName(h.Namespace, h.Subsystem, name), help, nil, nil)
Expand Down
13 changes: 6 additions & 7 deletions prometheus_helper/prometheus_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ func TestSimpleDescHelper(t *testing.T) {
Subsystem: "test",
}

t.Run("NewDesc", func(t *testing.T) {
desc := helper.NewDesc("metric")
expectedDesc := "Desc{fqName: \"logstash_exporter_test_metric\", help: \"metric\", constLabels: {}, variableLabels: []}"
t.Run("NewDescWithHelp", func(t *testing.T) {
desc := helper.NewDescWithHelp("metric", "help")
expectedDesc := "Desc{fqName: \"logstash_exporter_test_metric\", help: \"help\", constLabels: {}, variableLabels: []}"
if desc.String() != expectedDesc {
t.Errorf("incorrect metric description, expected %s but got %s", expectedDesc, desc.String())
}
})

t.Run("NewDescWithHelp", func(t *testing.T) {
desc := helper.NewDescWithHelp("metric", "help")
expectedDesc := "Desc{fqName: \"logstash_exporter_test_metric\", help: \"help\", constLabels: {}, variableLabels: []}"
t.Run("NewDescWithHelpAndLabel", func(t *testing.T) {
desc := helper.NewDescWithHelpAndLabel("metric", "help", "label")
expectedDesc := "Desc{fqName: \"logstash_exporter_test_metric\", help: \"help\", constLabels: {}, variableLabels: [label]}"
if desc.String() != expectedDesc {
t.Errorf("incorrect metric description, expected %s but got %s", expectedDesc, desc.String())
}
Expand All @@ -42,7 +42,6 @@ func TestExtractFqdnName(t *testing.T) {
metricSubname := "fqdn_metric"

descriptors := []*prometheus.Desc{
helper.NewDesc(metricSubname),
helper.NewDescWithHelp(metricSubname, "help"),
helper.NewDescWithHelpAndLabel(metricSubname, "help", "label"),
}
Expand Down

0 comments on commit 31b8bcc

Please sign in to comment.