Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ying-jeanne committed Sep 29, 2024
1 parent b8300bc commit de6aff8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
## Unreleased

* [ENHANCEMENT] process_collector: Add Platform-Specific Describe for processCollector. #1625

## 1.20.2 / 2024-08-23

* [BUGFIX] promhttp: Unset Content-Encoding header when data is uncompressed. #1596
Expand Down
8 changes: 4 additions & 4 deletions prometheus/process_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,18 @@ func NewProcessCollector(opts ProcessCollectorOpts) Collector {
c.collectFn = c.processCollect
c.describeFn = c.describe
} else {
c.collectFn = c.defaultCollectFn
c.describeFn = c.defaultDescribeFn
c.collectFn = c.errorCollectFn
c.describeFn = c.errorDescribeFn
}

return c
}

func (c *processCollector) defaultCollectFn(ch chan<- Metric) {
func (c *processCollector) errorCollectFn(ch chan<- Metric) {
c.reportError(ch, nil, errors.New("process metrics not supported on this platform"))
}

func (c *processCollector) defaultDescribeFn(ch chan<- *Desc) {
func (c *processCollector) errorDescribeFn(ch chan<- *Desc) {
if c.reportErrors {
ch <- NewInvalidDesc(errors.New("process metrics not supported on this platform"))
}
Expand Down
4 changes: 2 additions & 2 deletions prometheus/process_collector_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ func canCollectProcess() bool {
// in the processCollect method. Any changes to the metrics in processCollect
// (such as adding or removing metrics) should be reflected in this list of descriptors.
func (c *processCollector) processCollect(ch chan<- Metric) {
c.defaultCollect(ch)
c.errorCollectFn(ch)
}

func (c *processCollector) describe(ch chan<- *Desc) {
c.defaultDescribe(ch)
c.errorDescribeFn(ch)
}
4 changes: 2 additions & 2 deletions prometheus/process_collector_wasip1.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ func canCollectProcess() bool {
}

func (c *processCollector) processCollect(ch chan<- Metric) {
c.defaultCollect(ch)
c.errorCollectFn(ch)
}

// describe returns all descriptions of the collector for wasip1.
// Ensure that this list of descriptors is kept in sync with the metrics collected
// in the processCollect method. Any changes to the metrics in processCollect
// (such as adding or removing metrics) should be reflected in this list of descriptors.
func (c *processCollector) describe(ch chan<- *Desc) {
c.defaultDescribe(ch)
c.errorDescribeFn(ch)
}

0 comments on commit de6aff8

Please # to comment.