Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(metrics): more duration histogram buckets #142

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading