Skip to content

Commit

Permalink
Update frontend poller metrics to include tasklist tag (uber#6237)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaddoll authored Aug 20, 2024
1 parent 2d7b7d4 commit 44353d6
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 50 deletions.
2 changes: 1 addition & 1 deletion common/metrics/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (m *metricsScope) RecordHistogramValue(id int, value float64) {
}

func (m *metricsScope) Tagged(tags ...Tag) Scope {
domainTagged := false
domainTagged := m.isDomainTagged
tagMap := make(map[string]string, len(tags))
for _, tag := range tags {
if isDomainTagged(tag) {
Expand Down
12 changes: 11 additions & 1 deletion service/frontend/templates/metered.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
{{- $nonDomainSpecificAPIs := list "Health" "DeprecateDomain" "DescribeDomain" "ListDomains" "RegisterDomain" "UpdateDomain" "GetSearchAttributes" "GetClusterInfo"}}
{{- $domainIDAPIs := list "RecordActivityTaskHeartbeat" "RespondActivityTaskCanceled" "RespondActivityTaskCompleted" "RespondActivityTaskFailed" "RespondDecisionTaskCompleted" "RespondDecisionTaskFailed" "RespondQueryTaskCompleted"}}
{{- $queryTaskTokenAPIs := list "RespondQueryTaskCompleted"}}
{{- $pollerAPIs := list "PollForActivityTask" "PollForDecisionTask"}}

{{- $interfaceName := .Interface.Name}}
{{- $interfaceType := .Interface.Type}}
Expand Down Expand Up @@ -81,10 +82,19 @@ func (h *{{$decorator}}) {{$method.Declaration}} {
{{- end}}
{{- $domainMetricTag = printf "metrics.DomainTag(%s)" $domain}}
{{- end}}
scope := h.metricsClient.Scope({{$scope}}).Tagged({{$domainMetricTag}}).Tagged(metrics.GetContextTags(ctx)...)
{{- if has $method.Name $pollerAPIs}}
scope := common.NewPerTaskListScope({{(index $method.Params 1).Name}}.Domain, {{(index $method.Params 1).Name}}.TaskList.GetName(), {{(index $method.Params 1).Name}}.TaskList.GetKind(), h.metricsClient, {{$scope}}).Tagged(metrics.GetContextTags(ctx)...)
scope.IncCounter(metrics.CadenceRequestsPerTaskList)
sw := scope.StartTimer(metrics.CadenceLatencyPerTaskList)
defer sw.Stop()
swPerDomain := h.metricsClient.Scope({{$scope}}).Tagged(append(metrics.GetContextTags(ctx), {{$domainMetricTag}})...).StartTimer(metrics.CadenceLatency)
defer swPerDomain.Stop()
{{- else}}
scope := h.metricsClient.Scope({{$scope}}).Tagged(append(metrics.GetContextTags(ctx), {{$domainMetricTag}})...)
scope.IncCounter(metrics.CadenceRequests)
sw := scope.StartTimer(metrics.CadenceLatency)
defer sw.Stop()
{{- end}}
logger := h.logger.WithTags(tags...)

{{$method.ResultsNames}} = h.handler.{{$method.Call}}
Expand Down
Loading

0 comments on commit 44353d6

Please sign in to comment.