-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add basic metrics for sharky (#2759)
- Loading branch information
Showing
2 changed files
with
79 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright 2021 The Swarm Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package sharky | ||
|
||
import ( | ||
m "github.com/ethersphere/bee/pkg/metrics" | ||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
// metrics groups sharky related prometheus counters. | ||
type metrics struct { | ||
TotalWriteCalls prometheus.Counter | ||
TotalWriteCallsErr prometheus.Counter | ||
TotalReadCalls prometheus.Counter | ||
TotalReadCallsErr prometheus.Counter | ||
ShardCount prometheus.Gauge | ||
} | ||
|
||
// newMetrics is a convenient constructor for creating new metrics. | ||
func newMetrics() metrics { | ||
const subsystem = "sharky" | ||
|
||
return metrics{ | ||
TotalWriteCalls: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: m.Namespace, | ||
Subsystem: subsystem, | ||
Name: "total_write_calls", | ||
Help: "The total write calls made.", | ||
}), | ||
TotalWriteCallsErr: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: m.Namespace, | ||
Subsystem: subsystem, | ||
Name: "total_write_calls_err", | ||
Help: "The total write calls ended up with error.", | ||
}), | ||
TotalReadCalls: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: m.Namespace, | ||
Subsystem: subsystem, | ||
Name: "total_read_calls", | ||
Help: "The total read calls made.", | ||
}), | ||
TotalReadCallsErr: prometheus.NewCounter(prometheus.CounterOpts{ | ||
Namespace: m.Namespace, | ||
Subsystem: subsystem, | ||
Name: "total_read_calls_err", | ||
Help: "The total read calls ended up with error.", | ||
}), | ||
ShardCount: prometheus.NewGauge(prometheus.GaugeOpts{ | ||
Namespace: m.Namespace, | ||
Subsystem: subsystem, | ||
Name: "shard_count", | ||
Help: "The number of shards.", | ||
}), | ||
} | ||
} | ||
|
||
// Metrics returns set of prometheus collectors. | ||
func (s *Store) Metrics() []prometheus.Collector { | ||
return m.PrometheusCollectorsFromFields(s.metrics) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters