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

Update frontend poller metrics to include tasklist tag #6237

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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))
Comment on lines 122 to 124
Copy link
Member

Choose a reason for hiding this comment

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

aaah. yeah, this makes sense - otherwise we'd lose the value when we make a cached scope with a domain tag. 👍

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
Loading