Skip to content

Commit

Permalink
fix(metrics): more duration histogram buckets (#142)
Browse files Browse the repository at this point in the history
* fix(metrics): more duration histogram buckets

Closes #135

* fix: use the same buckets as boxo

Co-authored-by: Daniel Norman <1992255+2color@users.noreply.github.com>

---------

Co-authored-by: Daniel Norman <1992255+2color@users.noreply.github.com>
  • Loading branch information
lidel and 2color authored Jun 11, 2024
1 parent 90c6145 commit 6ff0b51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 3 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ The following emojis are used to highlight certain changes:
* 🛠 - BREAKING CHANGE. Action is required if you use this functionality.
* ✨ - Noteworthy change to be aware of.

## [Unreleased]

### Added

### Changed

### Removed
## [v1.3.1]

### Fixed

- Added more buckets to the duration histogram metric to allow for tracking operations that take longer than 1 minute.

### Security

## [v1.3.0]
Expand Down
5 changes: 4 additions & 1 deletion metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ func registerVersionMetric(version string) {
m.Set(1)
}

// Duration histograms use fixed definition here, as we don't want to break existing buckets if we need to add more.
var defaultDurationHistogramBuckets = []float64{0.05, 0.1, 0.25, 0.5, 1, 2, 5, 10, 30, 60, 120, 240, 480, 960, 1920}

// withHTTPMetrics collects metrics around HTTP request/response count, duration, and size
// per specific handler. Allows us to track them separately for /ipns and /ipfs.
func withHTTPMetrics(handler http.Handler, handlerName string) http.Handler {

opts := prometheus.HistogramOpts{
Namespace: "ipfs",
Subsystem: "http",
Buckets: []float64{0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 30, 60},
Buckets: defaultDurationHistogramBuckets,
ConstLabels: prometheus.Labels{"handler": handlerName},
}

Expand Down

0 comments on commit 6ff0b51

Please sign in to comment.