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