[#371] ir: Add morph cache metrics

Signed-off-by: Airat Arifullin a.arifullin@yadro.com
This commit is contained in:
Airat Arifullin 2023-05-26 12:15:50 +03:00 committed by Evgenii Stratonikov
parent 4f83ab0fb4
commit 90e9247b69
11 changed files with 154 additions and 27 deletions

View file

@ -5,6 +5,7 @@ import (
"fmt"
"math/big"
"strconv"
"time"
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
@ -81,6 +82,13 @@ func (c *Client) NNSHash() (util.Uint160, error) {
return util.Uint160{}, ErrConnectionLost
}
success := false
startedAt := time.Now()
defer func() {
c.cache.metrics.AddNNSContractHashDuration(success, time.Since(startedAt))
}()
nnsHash := c.cache.nns()
if nnsHash == nil {
@ -92,6 +100,7 @@ func (c *Client) NNSHash() (util.Uint160, error) {
c.cache.setNNSHash(cs.Hash)
nnsHash = &cs.Hash
}
success = true
return *nnsHash, nil
}
@ -221,7 +230,14 @@ func (c *Client) SetGroupSignerScope() error {
// contractGroupKey returns public key designating FrostFS contract group.
func (c *Client) contractGroupKey() (*keys.PublicKey, error) {
success := false
startedAt := time.Now()
defer func() {
c.cache.metrics.AddGroupKeyDuration(success, time.Since(startedAt))
}()
if gKey := c.cache.groupKey(); gKey != nil {
success = true
return gKey, nil
}
@ -251,5 +267,7 @@ func (c *Client) contractGroupKey() (*keys.PublicKey, error) {
}
c.cache.setGroupKey(pub)
success = true
return pub, nil
}