Skip to content
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

Add metrics to AccessControlledHandler #3145

Merged
merged 4 commits into from
Mar 27, 2020
Merged

Add metrics to AccessControlledHandler #3145

merged 4 commits into from
Mar 27, 2020

Conversation

vancexu
Copy link
Contributor

@vancexu vancexu commented Mar 27, 2020

What changed?
Add metrics to AccessControlledHandler

Why?
For monitoring authorization status

How did you test it?
Unit test

Potential risks
No risk

@vancexu vancexu requested review from venkat1109 and a team March 27, 2020 01:25
@coveralls
Copy link

coveralls commented Mar 27, 2020

Coverage Status

Coverage decreased (-0.3%) to 67.142% when pulling 6fb698a on authmetrics into a933ae0 on master.

@@ -121,11 +121,15 @@ func (a *AccessControlledWorkflowHandler) DeprecateDomain(
request *shared.DeprecateDomainRequest,
) error {

scope := a.GetResource().GetMetricsClient().
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use getMetricsScopeWithDomain here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request in XXXDomain APIs are not domainGetter, so hard to reuse. But I make it a function to some some lines.

}

// getMetricsScopeWithDomain return metrics scope with domain tag
func (a *AccessControlledWorkflowHandler) getMetricsScopeWithDomain(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just making the following method a utility method that takes in a metrics client instead of duplicating the code

// startRequestProfileWithDomain initiates recording of request metrics and returns a domain tagged scope
func (wh *WorkflowHandler) startRequestProfileWithDomain(scope int, d domainGetter) (metrics.Scope, metrics.Stopwatch) {
	var metricsScope metrics.Scope
	if d != nil {
		metricsScope = wh.GetMetricsClient().Scope(scope).Tagged(metrics.DomainTag(d.GetDomain()))
	} else {
		metricsScope = wh.GetMetricsClient().Scope(scope).Tagged(metrics.DomainUnknownTag())
	}
	sw := metricsScope.StartTimer(metrics.CadenceLatency)
	metricsScope.IncCounter(metrics.CadenceRequests)
	return metricsScope, sw
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

Copy link
Contributor

@andrewjdawson2016 andrewjdawson2016 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits but feel free to ignore.

@vancexu vancexu merged commit 882f680 into master Mar 27, 2020
@vancexu vancexu deleted the authmetrics branch March 27, 2020 18:59
vancexu added a commit that referenced this pull request May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants