forked from TrueCloudLab/frostfs-node
[#17] Add morph client metrics
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
parent
90e9247b69
commit
4887f489a1
11 changed files with 182 additions and 15 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/metrics"
|
||||
morphmetrics "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/metrics"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||
lru "github.com/hashicorp/golang-lru/v2"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
|
@ -32,6 +33,8 @@ type cfg struct {
|
|||
|
||||
logger *logger.Logger // logging component
|
||||
|
||||
metrics morphmetrics.Register
|
||||
|
||||
waitInterval time.Duration
|
||||
|
||||
signer *transaction.Signer
|
||||
|
@ -60,6 +63,7 @@ func defaultConfig() *cfg {
|
|||
return &cfg{
|
||||
dialTimeout: defaultDialTimeout,
|
||||
logger: &logger.Logger{Logger: zap.L()},
|
||||
metrics: morphmetrics.NoopRegister{},
|
||||
waitInterval: defaultWaitInterval,
|
||||
signer: &transaction.Signer{
|
||||
Scopes: transaction.Global,
|
||||
|
@ -80,6 +84,7 @@ func defaultConfig() *cfg {
|
|||
// - signer with the global scope;
|
||||
// - wait interval: 500ms;
|
||||
// - logger: &logger.Logger{Logger: zap.L()}.
|
||||
// - metrics: metrics.NoopRegister
|
||||
//
|
||||
// If desired option satisfies the default value, it can be omitted.
|
||||
// If multiple options of the same config value are supplied,
|
||||
|
@ -109,6 +114,7 @@ func New(ctx context.Context, key *keys.PrivateKey, opts ...Option) (*Client, er
|
|||
cli := &Client{
|
||||
cache: newClientCache(cfg.morphCacheMetrics),
|
||||
logger: cfg.logger,
|
||||
metrics: cfg.metrics,
|
||||
acc: acc,
|
||||
accAddr: accAddr,
|
||||
cfg: *cfg,
|
||||
|
@ -235,6 +241,20 @@ func WithLogger(logger *logger.Logger) Option {
|
|||
}
|
||||
}
|
||||
|
||||
// WithMetrics returns a client constructor option
|
||||
// that specifies the component for reporting metrics.
|
||||
//
|
||||
// Ignores nil value.
|
||||
//
|
||||
// If option not provided, NoopMetrics is used.
|
||||
func WithMetrics(metrics morphmetrics.Register) Option {
|
||||
return func(c *cfg) {
|
||||
if metrics != nil {
|
||||
c.metrics = metrics
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithSigner returns a client constructor option
|
||||
// that specifies the signer and the scope of the transaction.
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue