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

[Wf-Diagnostics] emit metrics from diagnostics workflow #6299

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 9 additions & 1 deletion common/metrics/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,8 @@ const (
ESAnalyzerScope
// AsyncWorkflowConsumerScope is scope used by async workflow consumer
AsyncWorkflowConsumerScope
// DiagnosticsWorkflowScope is scope used by diagnostics workflow
DiagnosticsWorkflowScope

NumWorkerScopes
)
Expand Down Expand Up @@ -1997,6 +1999,7 @@ var ScopeDefs = map[ServiceIdx]map[int]scopeDefinition{
ParentClosePolicyProcessorScope: {operation: "ParentClosePolicyProcessor"},
ESAnalyzerScope: {operation: "ESAnalyzer"},
AsyncWorkflowConsumerScope: {operation: "AsyncWorkflowConsumer"},
DiagnosticsWorkflowScope: {operation: "DiagnosticsWorkflow"},
},
}

Expand Down Expand Up @@ -2670,7 +2673,9 @@ const (
AsyncWorkflowFailureCorruptMsgCount
AsyncWorkflowFailureByFrontendCount
AsyncWorkflowSuccessCount

DiagnosticsWorkflowCount
sankari165 marked this conversation as resolved.
Show resolved Hide resolved
DiagnosticsWorkflowSuccess
DiagnosticsWorkflowExecutionLatency
NumWorkerMetrics
)

Expand Down Expand Up @@ -3346,6 +3351,9 @@ var MetricDefs = map[ServiceIdx]map[int]metricDefinition{
AsyncWorkflowFailureCorruptMsgCount: {metricName: "async_workflow_failure_corrupt_msg", metricType: Counter},
AsyncWorkflowFailureByFrontendCount: {metricName: "async_workflow_failure_by_frontend", metricType: Counter},
AsyncWorkflowSuccessCount: {metricName: "async_workflow_success", metricType: Counter},
DiagnosticsWorkflowCount: {metricName: "diagnostics_workflow_count", metricType: Counter},
DiagnosticsWorkflowSuccess: {metricName: "diagnostics_workflow_success", metricType: Counter},
DiagnosticsWorkflowExecutionLatency: {metricName: "diagnostics_workflow_execution_latency", metricType: Timer},
},
}

Expand Down
7 changes: 7 additions & 0 deletions service/worker/diagnostics/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

"go.uber.org/cadence/workflow"

"github.com/uber/cadence/common/metrics"
"github.com/uber/cadence/common/types"
"github.com/uber/cadence/service/worker/diagnostics/invariants"
)
Expand Down Expand Up @@ -75,6 +76,11 @@ type timeoutRootCauseResult struct {
}

func (w *dw) DiagnosticsWorkflow(ctx workflow.Context, params DiagnosticsWorkflowInput) (*DiagnosticsWorkflowResult, error) {
scope := w.metricsClient.Scope(metrics.DiagnosticsWorkflowScope, metrics.DomainTag(params.Domain))
scope.IncCounter(metrics.DiagnosticsWorkflowCount)
sw := scope.StartTimer(metrics.DiagnosticsWorkflowExecutionLatency)
defer sw.Stop()

var timeoutsResult timeoutDiagnostics
err := workflow.SetQueryHandler(ctx, queryDiagnosticsReport, func() (DiagnosticsWorkflowResult, error) {
return DiagnosticsWorkflowResult{Timeouts: &timeoutsResult}, nil
Expand Down Expand Up @@ -134,6 +140,7 @@ func (w *dw) DiagnosticsWorkflow(ctx workflow.Context, params DiagnosticsWorkflo
}
timeoutsResult.RootCause = timeoutRootCause

scope.IncCounter(metrics.DiagnosticsWorkflowSuccess)
return &DiagnosticsWorkflowResult{Timeouts: &timeoutsResult}, nil
}

Expand Down
5 changes: 3 additions & 2 deletions service/worker/diagnostics/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ func (s *diagnosticsWorkflowTestSuite) SetupTest() {
mockResource := resource.NewTest(s.T(), controller, metrics.Worker)

s.dw = &dw{
svcClient: mockResource.GetSDKClient(),
clientBean: mockResource.ClientBean,
svcClient: mockResource.GetSDKClient(),
clientBean: mockResource.ClientBean,
metricsClient: mockResource.GetMetricsClient(),
}

s.T().Cleanup(func() {
Expand Down
Loading