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

Refactor metrics with domain tag #2386

Merged
merged 3 commits into from
Aug 14, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions service/history/timerQueueActiveProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,17 +430,17 @@ ExpireActivityTimers:
}
}

domainEntry, err := t.shard.GetDomainCache().GetDomainByID(msBuilder.GetExecutionInfo().DomainID)
metricScopeWithDomainTag, err := t.getMetricScopeWithDomainTag(
metrics.TimerActiveTaskActivityTimeoutScope,
msBuilder.GetExecutionInfo().DomainID)
if err != nil {
return &workflow.InternalServiceError{Message: "unable to get domain from cache by domainID."}
return err
}

switch timeoutType {
case workflow.TimeoutTypeScheduleToClose:
{
t.metricsClient.Scope(metrics.TimerActiveTaskActivityTimeoutScope).
Tagged(metrics.DomainTag(domainEntry.GetInfo().Name)).
IncCounter(metrics.ScheduleToCloseTimeoutCounter)
metricScopeWithDomainTag.IncCounter(metrics.ScheduleToCloseTimeoutCounter)
if _, err := msBuilder.AddActivityTaskTimedOutEvent(ai.ScheduleID, ai.StartedID, timeoutType, ai.Details); err != nil {
return err
}
Expand All @@ -449,9 +449,7 @@ ExpireActivityTimers:

case workflow.TimeoutTypeStartToClose:
{
t.metricsClient.Scope(metrics.TimerActiveTaskActivityTimeoutScope).
Tagged(metrics.DomainTag(domainEntry.GetInfo().Name)).
IncCounter(metrics.StartToCloseTimeoutCounter)
metricScopeWithDomainTag.IncCounter(metrics.StartToCloseTimeoutCounter)
if ai.StartedID != common.EmptyEventID {
if _, err := msBuilder.AddActivityTaskTimedOutEvent(ai.ScheduleID, ai.StartedID, timeoutType, ai.Details); err != nil {
return err
Expand All @@ -462,9 +460,7 @@ ExpireActivityTimers:

case workflow.TimeoutTypeHeartbeat:
{
t.metricsClient.Scope(metrics.TimerActiveTaskActivityTimeoutScope).
Tagged(metrics.DomainTag(domainEntry.GetInfo().Name)).
IncCounter(metrics.HeartbeatTimeoutCounter)
metricScopeWithDomainTag.IncCounter(metrics.HeartbeatTimeoutCounter)
if _, err := msBuilder.AddActivityTaskTimedOutEvent(ai.ScheduleID, ai.StartedID, timeoutType, ai.Details); err != nil {
return err
}
Expand All @@ -473,9 +469,7 @@ ExpireActivityTimers:

case workflow.TimeoutTypeScheduleToStart:
{
t.metricsClient.Scope(metrics.TimerActiveTaskActivityTimeoutScope).
Tagged(metrics.DomainTag(domainEntry.GetInfo().Name)).
IncCounter(metrics.ScheduleToStartTimeoutCounter)
metricScopeWithDomainTag.IncCounter(metrics.ScheduleToStartTimeoutCounter)
if ai.StartedID == common.EmptyEventID {
if _, err := msBuilder.AddActivityTaskTimedOutEvent(ai.ScheduleID, ai.StartedID, timeoutType, ai.Details); err != nil {
return err
Expand Down Expand Up @@ -533,26 +527,24 @@ func (t *timerQueueActiveProcessorImpl) processDecisionTimeout(
return nil
}

domainEntry, err := t.shard.GetDomainCache().GetDomainByID(msBuilder.GetExecutionInfo().DomainID)
metricScopeWithDomainTag, err := t.getMetricScopeWithDomainTag(
metrics.TimerActiveTaskDecisionTimeoutScope,
msBuilder.GetExecutionInfo().DomainID)
if err != nil {
return &workflow.InternalServiceError{Message: "unable to get domain from cache by domainID."}
return err
}

scheduleNewDecision := false
switch task.TimeoutType {
case int(workflow.TimeoutTypeStartToClose):
t.metricsClient.Scope(metrics.TimerActiveTaskDecisionTimeoutScope).
Tagged(metrics.DomainTag(domainEntry.GetInfo().Name)).
IncCounter(metrics.StartToCloseTimeoutCounter)
metricScopeWithDomainTag.IncCounter(metrics.StartToCloseTimeoutCounter)
if di.Attempt == task.ScheduleAttempt {
// Add a decision task timeout event.
msBuilder.AddDecisionTaskTimedOutEvent(scheduleID, di.StartedID)
scheduleNewDecision = true
}
case int(workflow.TimeoutTypeScheduleToStart):
t.metricsClient.Scope(metrics.TimerActiveTaskDecisionTimeoutScope).
Tagged(metrics.DomainTag(domainEntry.GetInfo().Name)).
IncCounter(metrics.ScheduleToStartTimeoutCounter)
metricScopeWithDomainTag.IncCounter(metrics.ScheduleToStartTimeoutCounter)
// check if scheduled decision still pending and not started yet
if di.Attempt == task.ScheduleAttempt && di.StartedID == common.EmptyEventID {
_, err := msBuilder.AddDecisionTaskScheduleToStartTimeoutEvent(scheduleID)
Expand Down Expand Up @@ -842,3 +834,12 @@ func (t *timerQueueActiveProcessorImpl) updateWorkflowExecution(

return nil
}

func (t *timerQueueActiveProcessorImpl) getMetricScopeWithDomainTag(scope int, domainID string) (metrics.Scope, error) {
domainEntry, err := t.shard.GetDomainCache().GetDomainByID(domainID)
if err != nil {
return nil, &workflow.InternalServiceError{Message: "unable to get domain from cache by domainID."}
Copy link
Collaborator

@longquanzheng longquanzheng Aug 14, 2019

Choose a reason for hiding this comment

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

Actually we should return this error instead of making a new one. Because the err from domainCache could should have more useful info than this simple text.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make sense. updated

}
return t.metricsClient.Scope(metrics.TimerActiveTaskDecisionTimeoutScope).
Tagged(metrics.DomainTag(domainEntry.GetInfo().Name)), nil
}