Skip to content

Commit

Permalink
Add task queue to worker metrics (#785)
Browse files Browse the repository at this point in the history
* Add task queue to worker metrics

Fixes #784

* Move task queue tag to a higher level
  • Loading branch information
cretz authored Apr 25, 2022
1 parent 4e64c51 commit 7cbd079
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions internal/common/metrics/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ func LocalActivityTags(workflowType, activityType string) map[string]string {
}
}

// TaskQueueTags returns a set of tags for a task queue.
func TaskQueueTags(taskQueue string) map[string]string {
return map[string]string{
TaskQueueTagName: taskQueue,
}
}

// WorkerTags returns a set of tags for workers.
func WorkerTags(workerType string) map[string]string {
return map[string]string{
Expand Down
2 changes: 1 addition & 1 deletion internal/internal_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,7 @@ func NewAggregatedWorker(client *WorkflowClient, taskQueue string, options Worke
ConcurrentWorkflowTaskExecutionSize: options.MaxConcurrentWorkflowTaskExecutionSize,
MaxConcurrentWorkflowTaskQueuePollers: options.MaxConcurrentWorkflowTaskPollers,
Identity: client.identity,
MetricsHandler: client.metricsHandler,
MetricsHandler: client.metricsHandler.WithTags(metrics.TaskQueueTags(taskQueue)),
Logger: client.logger,
EnableLoggingInReplay: options.EnableLoggingInReplay,
UserContext: backgroundActivityContext,
Expand Down
6 changes: 5 additions & 1 deletion test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,11 @@ func (ts *IntegrationTestSuite) TestSlotsAvailableCounter() {
// Try for two seconds
var lastCount float64
for start := time.Now(); time.Since(start) <= 2*time.Second; {
lastCount = ts.metricGauge(metrics.WorkerTaskSlotsAvailable, "worker_type", "ActivityWorker")
lastCount = ts.metricGauge(
metrics.WorkerTaskSlotsAvailable,
"worker_type", "ActivityWorker",
"task_queue", ts.taskQueueName,
)
if lastCount == expected {
return
}
Expand Down

0 comments on commit 7cbd079

Please sign in to comment.