-
Notifications
You must be signed in to change notification settings - Fork 813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a metric for hosts not being found in resolver #5414
Changes from 2 commits
cfed43c
04f5d9f
21e70b4
e9749c5
2a7024f
13c8752
862df48
c54ed77
73e7e33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ package membership | |
import ( | ||
"errors" | ||
"fmt" | ||
"github.com/uber/cadence/common/metrics" | ||
"sync/atomic" | ||
|
||
"github.com/uber/cadence/common" | ||
|
@@ -80,7 +81,8 @@ type ( | |
|
||
// MultiringResolver uses ring-per-service for membership information | ||
type MultiringResolver struct { | ||
status int32 | ||
metrics metrics.Client | ||
status int32 | ||
|
||
provider PeerProvider | ||
rings map[string]*ring | ||
|
@@ -92,20 +94,23 @@ var _ Resolver = (*MultiringResolver)(nil) | |
func NewResolver( | ||
provider PeerProvider, | ||
logger log.Logger, | ||
metrics metrics.Client, | ||
) (*MultiringResolver, error) { | ||
return NewMultiringResolver(service.List, provider, logger.WithTags(tag.ComponentServiceResolver)), nil | ||
return NewMultiringResolver(service.List, provider, logger.WithTags(tag.ComponentServiceResolver), metrics), nil | ||
} | ||
|
||
// NewMultiringResolver creates hashrings for all services | ||
func NewMultiringResolver( | ||
services []string, | ||
provider PeerProvider, | ||
logger log.Logger, | ||
metrics metrics.Client, | ||
) *MultiringResolver { | ||
rpo := &MultiringResolver{ | ||
status: common.DaemonStatusInitialized, | ||
provider: provider, | ||
rings: make(map[string]*ring), | ||
metrics: metrics, | ||
} | ||
|
||
for _, s := range services { | ||
|
@@ -193,6 +198,7 @@ func (rpo *MultiringResolver) Unsubscribe(service string, name string) error { | |
func (rpo *MultiringResolver) Members(service string) ([]HostInfo, error) { | ||
ring, err := rpo.getRing(service) | ||
if err != nil { | ||
rpo.metrics.Scope(metrics.ResolverHostNotFoundScope).IncCounter(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it better to move to LookupByAddress() which calls There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, you're right, I was being a bit hurried and this doesn't make sense |
||
return nil, err | ||
} | ||
return ring.Members(), nil | ||
|
@@ -208,6 +214,7 @@ func (rpo *MultiringResolver) LookupByAddress(service, address string) (HostInfo | |
return m, nil | ||
} | ||
} | ||
rpo.metrics.Scope(metrics.ResolverHostNotFoundScope).IncCounter(1) | ||
return HostInfo{}, errors.New("host not found") | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
package membership | ||
|
||
import ( | ||
"github.com/uber/cadence/common/metrics" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. imports are messed up |
||
"testing" | ||
|
||
"github.com/golang/mock/gomock" | ||
|
@@ -136,5 +137,6 @@ func newTestResolver(t *testing.T) (*MultiringResolver, *MockPeerProvider) { | |
testServices, | ||
pp, | ||
log.NewNoop(), | ||
metrics.NewNoopMetricsClient(), | ||
), pp | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imports are messed up.