Skip to content

Commit

Permalink
Rename metrics and description
Browse files Browse the repository at this point in the history
  • Loading branch information
arunvelsriram committed May 15, 2021
1 parent c546759 commit cdee8c0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 32 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ By default `sftp-exporter` looks for a config file named `sftp-exporter.yaml` in
```
# HELP sftp_filesystem_free_space_bytes Free space in the filesystem containing the path
# TYPE sftp_filesystem_free_space_bytes gauge
sftp_filesystem_free_space_bytes{path="/upload1"} 1.4941843456e+10
sftp_filesystem_free_space_bytes{path="/upload2"} 1.4941843456e+10
sftp_filesystem_free_space_bytes{path="/upload1"} 7.370901504e+10
sftp_filesystem_free_space_bytes{path="/upload2"} 7.370901504e+10
# HELP sftp_filesystem_total_space_bytes Total space in the filesystem containing the path
# TYPE sftp_filesystem_total_space_bytes gauge
sftp_filesystem_total_space_bytes{path="/upload1"} 6.2725623808e+10
sftp_filesystem_total_space_bytes{path="/upload2"} 6.2725623808e+10
# HELP sftp_objects_count_total Total number of objects in the path
# TYPE sftp_objects_count_total gauge
sftp_objects_count_total{path="/upload1"} 6
sftp_objects_count_total{path="/upload2"} 5
# HELP sftp_objects_size_total_bytes Total size of all objects in the path
# TYPE sftp_objects_size_total_bytes gauge
sftp_objects_size_total_bytes{path="/upload1"} 6.86033e+06
sftp_objects_size_total_bytes{path="/upload2"} 6.885284e+06
sftp_filesystem_total_space_bytes{path="/upload1"} 8.4281810944e+10
sftp_filesystem_total_space_bytes{path="/upload2"} 8.4281810944e+10
# HELP sftp_objects_available Number of objects in the path
# TYPE sftp_objects_available gauge
sftp_objects_available{path="/upload1"} 1
sftp_objects_available{path="/upload2"} 3
# HELP sftp_objects_total_size_bytes Total size of all the objects in the path
# TYPE sftp_objects_total_size_bytes gauge
sftp_objects_total_size_bytes{path="/upload1"} 312
sftp_objects_total_size_bytes{path="/upload2"} 2337
# HELP sftp_up Tells if exporter is able to connect to SFTP
# TYPE sftp_up gauge
sftp_up 1
Expand Down
10 changes: 4 additions & 6 deletions pkg/collector/sftp_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,16 @@ var (
nil,
)

// TODO: Rename this metric and re-evaluate implementation
objectCount = prometheus.NewDesc(
prometheus.BuildFQName(c.Namespace, "", "objects_count_total"),
"Total number of objects in the path",
prometheus.BuildFQName(c.Namespace, "", "objects_available"),
"Number of objects in the path",
[]string{"path"},
nil,
)

// TODO: Rename this metric and re-evaluate implementation
objectSize = prometheus.NewDesc(
prometheus.BuildFQName(c.Namespace, "", "objects_size_total_bytes"),
"Total size of all objects in the path",
prometheus.BuildFQName(c.Namespace, "", "objects_total_size_bytes"),
"Total size of all the objects in the path",
[]string{"path"},
nil,
)
Expand Down
28 changes: 14 additions & 14 deletions pkg/collector/sftp_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ func (s *SFTPCollectorSuite) TestSFTPCollectorDescribe() {

objectCount := <-ch
s.Equal(
`Desc{fqName: "sftp_objects_count_total", `+
`help: "Total number of objects in the path", constLabels: {}, variableLabels: [path]}`,
`Desc{fqName: "sftp_objects_available", `+
`help: "Number of objects in the path", constLabels: {}, variableLabels: [path]}`,
objectCount.String(),
)

objectSize := <-ch
s.Equal(
`Desc{fqName: "sftp_objects_size_total_bytes", `+
`help: "Total size of all objects in the path", constLabels: {}, variableLabels: [path]}`,
`Desc{fqName: "sftp_objects_total_size_bytes", `+
`help: "Total size of all the objects in the path", constLabels: {}, variableLabels: [path]}`,
objectSize.String(),
)
}
Expand Down Expand Up @@ -280,7 +280,7 @@ func (s *SFTPCollectorSuite) TestSFTPCollectorCollectShouldWriteObjectMetrics()
objectCount1 := <-ch
desc = objectCount1.Desc()
_ = objectCount1.Write(metric)
s.Equal(`Desc{fqName: "sftp_objects_count_total", help: "Total number of objects in the path", `+
s.Equal(`Desc{fqName: "sftp_objects_available", help: "Number of objects in the path", `+
`constLabels: {}, variableLabels: [path]}`, desc.String())
s.Equal(3.0, metric.GetGauge().GetValue())
s.Equal("path", metric.GetLabel()[0].GetName())
Expand All @@ -289,7 +289,7 @@ func (s *SFTPCollectorSuite) TestSFTPCollectorCollectShouldWriteObjectMetrics()
objectSize1 := <-ch
desc = objectSize1.Desc()
_ = objectSize1.Write(metric)
s.Equal(`Desc{fqName: "sftp_objects_size_total_bytes", help: "Total size of all objects in the path", `+
s.Equal(`Desc{fqName: "sftp_objects_total_size_bytes", help: "Total size of all the objects in the path", `+
`constLabels: {}, variableLabels: [path]}`, desc.String())
s.Equal(4.0, metric.GetGauge().GetValue())
s.Equal("path", metric.GetLabel()[0].GetName())
Expand All @@ -298,7 +298,7 @@ func (s *SFTPCollectorSuite) TestSFTPCollectorCollectShouldWriteObjectMetrics()
objectCount2 := <-ch
desc = objectCount2.Desc()
_ = objectCount2.Write(metric)
s.Equal(`Desc{fqName: "sftp_objects_count_total", help: "Total number of objects in the path", `+
s.Equal(`Desc{fqName: "sftp_objects_available", help: "Number of objects in the path", `+
`constLabels: {}, variableLabels: [path]}`, desc.String())
s.Equal(1.0, metric.GetGauge().GetValue())
s.Equal("path", metric.GetLabel()[0].GetName())
Expand All @@ -307,7 +307,7 @@ func (s *SFTPCollectorSuite) TestSFTPCollectorCollectShouldWriteObjectMetrics()
objectSize2 := <-ch
desc = objectSize2.Desc()
_ = objectSize2.Write(metric)
s.Equal(`Desc{fqName: "sftp_objects_size_total_bytes", help: "Total size of all objects in the path", `+
s.Equal(`Desc{fqName: "sftp_objects_total_size_bytes", help: "Total size of all the objects in the path", `+
`constLabels: {}, variableLabels: [path]}`, desc.String())
s.Equal(10.0, metric.GetGauge().GetValue())
s.Equal("path", metric.GetLabel()[0].GetName())
Expand Down Expand Up @@ -335,14 +335,14 @@ func (s *SFTPCollectorSuite) TestSFTPCollectorCollectShouldNotWriteObjectMetrics
}()

m1 := <-ch
s.NotContains(m1.Desc().String(), "objects_count_total")
s.NotContains(m1.Desc().String(), "objects_size_total_bytes")
s.NotContains(m1.Desc().String(), "objects_available")
s.NotContains(m1.Desc().String(), "objects_total_size_bytes")
m2 := <-ch
s.NotContains(m2.Desc().String(), "objects_count_total")
s.NotContains(m2.Desc().String(), "objects_size_total_bytes")
s.NotContains(m2.Desc().String(), "objects_available")
s.NotContains(m2.Desc().String(), "objects_total_size_bytes")
m3 := <-ch
s.NotContains(m3.Desc().String(), "objects_count_total")
s.NotContains(m3.Desc().String(), "objects_size_total_bytes")
s.NotContains(m3.Desc().String(), "objects_available")
s.NotContains(m3.Desc().String(), "objects_total_size_bytes")
close(ch)

<-done
Expand Down

0 comments on commit cdee8c0

Please sign in to comment.