-
Notifications
You must be signed in to change notification settings - Fork 805
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
Refactor frontend API handler and use generated code to emit metrics #5639
Conversation
e394dea
to
11e23e1
Compare
Pull Request Test Coverage Report for Build 018d5dcb-1dcd-4c0d-b966-8acfb4c243d2
💛 - Coveralls |
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.
overall - looks good and separating logic from metering/profiling makes it easier to follow the code.
@@ -228,17 +226,12 @@ func (wh *WorkflowHandler) Health(ctx context.Context) (*types.HealthStatus, err | |||
// acts as a sandbox and provides isolation for all resources within the domain. All resources belongs to exactly one | |||
// domain. | |||
func (wh *WorkflowHandler) RegisterDomain(ctx context.Context, registerRequest *types.RegisterDomainRequest) (retError error) { | |||
defer func() { log.CapturePanic(recover(), wh.GetLogger(), &retError) }() |
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.
Do we have a global panic handler somewhere? I think handling panic is not part of metering.
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.
no, we don't. we can create a separate one later if we need that
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.
FYI: Panics in YARPC handlers are automatically caught and returned/logged as an error. This ensures that your process continues to run.
As of YARPC v1.43, YARPC now includes a metrics counter for panics.
So we can delete this completely.
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.
that's good to know
} | ||
|
||
func (h *apiHandler) CountWorkflowExecutions(ctx context.Context, cp1 *types.CountWorkflowExecutionsRequest) (cp2 *types.CountWorkflowExecutionsResponse, err error) { | ||
defer func() { log.CapturePanic(recover(), h.logger, &err) }() |
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.
this looks much better
tags := []tag.Tag{tag.WorkflowHandlerName("{{$method.Name}}")} | ||
{{- $scope := printf "metrics.Frontend%sScope" $method.Name}} | ||
{{- $domainMetricTag := "metrics.DomainUnknownTag()"}} | ||
{{- if not (has $method.Name $nonDomainSpecificAPIs) }} |
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.
not a problem with this PR, but the fact that this there are ... kind of groupings and yet it's annoyingly hard to match them out makes me feel like we should maybe separate them out more at a struct / interface level in the future.
this is fine, but I worry that in future templating like this will get messy beyond the pont of being readable
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.
Significantly tidier, nice!
What changed?
Why?
Tidy the messy code and make it maintainable
How did you test it?
unit tests
Potential risks
Release notes
Documentation Changes