forked from TrueCloudLab/frostfs-node
WIP: Morph: Add unit tests #2
5 changed files with 17 additions and 8 deletions
|
@ -30,8 +30,6 @@ const (
|
|||
)
|
||||
|
||||
func initMorphComponents(ctx context.Context, c *cfg) {
|
||||
var err error
|
||||
|
||||
addresses := morphconfig.RPCEndpoint(c.appCfg)
|
||||
|
||||
// Morph client stable-sorts endpoints by priority. Shuffle here to randomize
|
||||
|
@ -50,6 +48,7 @@ func initMorphComponents(ctx context.Context, c *cfg) {
|
|||
c.internalErr <- errors.New("morph connection has been lost")
|
||||
}),
|
||||
client.WithSwitchInterval(morphconfig.SwitchInterval(c.appCfg)),
|
||||
client.WithMorphCacheMetrics(metrics.NewNodeMorphCacheMetrics()),
|
||||
)
|
||||
if err != nil {
|
||||
c.log.Info(logs.FrostFSNodeFailedToCreateNeoRPCClient,
|
||||
|
|
|
@ -12,6 +12,7 @@ const (
|
|||
innerRingSubsystem = "ir"
|
||||
innerRingLabelSuccess = "success"
|
||||
innerRingLabelType = "type"
|
||||
innerRingNamespace = "frostfs_ir"
|
||||
)
|
||||
|
||||
// InnerRingServiceMetrics contains metrics collected by inner ring.
|
||||
|
@ -26,19 +27,19 @@ type InnerRingServiceMetrics struct {
|
|||
func NewInnerRingMetrics() *InnerRingServiceMetrics {
|
||||
var (
|
||||
epoch = metrics.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: namespace,
|
||||
Namespace: innerRingNamespace,
|
||||
Subsystem: innerRingSubsystem,
|
||||
Name: "epoch",
|
||||
Help: "Current epoch as seen by inner-ring node.",
|
||||
})
|
||||
health = metrics.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: namespace,
|
||||
Namespace: innerRingNamespace,
|
||||
Subsystem: innerRingSubsystem,
|
||||
Name: "health",
|
||||
Help: "Current inner-ring node state.",
|
||||
})
|
||||
eventDuration = metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Namespace: innerRingNamespace,
|
||||
Subsystem: innerRingSubsystem,
|
||||
Name: "event_duration_seconds",
|
||||
Help: "Duration of processing of inner-ring events",
|
||||
|
@ -49,7 +50,7 @@ func NewInnerRingMetrics() *InnerRingServiceMetrics {
|
|||
epoch: epoch,
|
||||
health: health,
|
||||
eventDuration: eventDuration,
|
||||
morphCacheMetrics: newMorphCacheMetrics(),
|
||||
morphCacheMetrics: newMorphCacheMetrics(innerRingNamespace),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,10 +24,14 @@ type morphCacheMetrics struct {
|
|||
|
||||
var _ MorphCacheMetrics = (*morphCacheMetrics)(nil)
|
||||
|
||||
func newMorphCacheMetrics() *morphCacheMetrics {
|
||||
func NewNodeMorphCacheMetrics() MorphCacheMetrics {
|
||||
return newMorphCacheMetrics(namespace)
|
||||
}
|
||||
|
||||
func newMorphCacheMetrics(ns string) *morphCacheMetrics {
|
||||
return &morphCacheMetrics{
|
||||
methodDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Namespace: namespace,
|
||||
Namespace: ns,
|
||||
Subsystem: mcSubsystem,
|
||||
Name: "request_duration_seconds",
|
||||
Help: "Morph cache request process duration",
|
||||
|
|
|
@ -68,6 +68,7 @@ func defaultConfig() *cfg {
|
|||
signer: &transaction.Signer{
|
||||
Scopes: transaction.Global,
|
||||
},
|
||||
morphCacheMetrics: &morphmetrics.NoopMorphCacheMetrics{},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,3 +15,7 @@ func (NoopRegister) IncSwitchCount() {
|
|||
func (NoopRegister) SetLastBlock(uint32) {}
|
||||
func (NoopRegister) IncNotificationCount(string) {}
|
||||
func (NoopRegister) ObserveInvoke(string, string, string, bool, time.Duration) {}
|
||||
|
||||
type NoopMorphCacheMetrics struct{}
|
||||
|
||||
func (m *NoopMorphCacheMetrics) AddMethodDuration(string, bool, time.Duration) {}
|
||||
|
|
Loading…
Reference in a new issue