Files
tasks/common/metrics/task_queues.go
Alex ShtinandGitHub 8e8f1b0f7c Remove license header from every file (#7689)
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.

## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
2025-05-01 18:50:21 -07:00

93 lines
2.5 KiB
Go

package metrics
import (
"strconv"
"go.temporal.io/server/common/tqid"
)
const (
omitted = "__omitted__"
normal = "__normal__"
sticky = "__sticky__"
)
// GetPerTaskQueueFamilyScope returns "namespace" and "taskqueue" tags. "taskqueue" will be "__omitted__" if
// taskQueueBreakdown is false.
func GetPerTaskQueueFamilyScope(
handler Handler,
namespaceName string,
taskQueueFamily *tqid.TaskQueueFamily,
taskQueueBreakdown bool,
tags ...Tag,
) Handler {
metricTaskQueueName := omitted
if taskQueueBreakdown {
metricTaskQueueName = taskQueueFamily.Name()
}
tags = append(tags, NamespaceTag(namespaceName), UnsafeTaskQueueTag(metricTaskQueueName))
return handler.WithTags(tags...)
}
// GetPerTaskQueueScope returns GetPerTaskQueueFamilyScope plus the "task_type" tag.
func GetPerTaskQueueScope(
handler Handler,
namespaceName string,
taskQueue *tqid.TaskQueue,
taskQueueBreakdown bool,
tags ...Tag,
) Handler {
return GetPerTaskQueueFamilyScope(handler, namespaceName, taskQueue.Family(), taskQueueBreakdown,
append(tags, TaskQueueTypeTag(taskQueue.TaskType()))...)
}
// GetPerTaskQueuePartitionIDScope is similar to GetPerTaskQueuePartitionTypeScope, except that the partition tag will
// hold the normal partition ID if partitionIDBreakdown is true.
func GetPerTaskQueuePartitionIDScope(
handler Handler,
namespaceName string,
partition tqid.Partition,
taskQueueBreakdown bool,
partitionIDBreakdown bool,
tags ...Tag,
) Handler {
var value string
if partition == nil {
value = unknownValue
} else if normalPartition, ok := partition.(*tqid.NormalPartition); ok {
if partitionIDBreakdown {
value = strconv.Itoa(normalPartition.PartitionId())
} else {
value = normal
}
} else {
value = sticky
}
return GetPerTaskQueueScope(handler, namespaceName, partition.TaskQueue(), taskQueueBreakdown,
append(tags, PartitionTag(value))...)
}
// GetPerTaskQueuePartitionTypeScope returns GetPerTaskQueueScope scope plus a "partition" tag which
// can be "__normal__", "__sticky__", or "_unknown_".
func GetPerTaskQueuePartitionTypeScope(
handler Handler,
namespaceName string,
partition tqid.Partition,
taskQueueBreakdown bool,
tags ...Tag,
) Handler {
var value string
if partition == nil {
value = unknownValue
} else if _, ok := partition.(*tqid.NormalPartition); ok {
value = normal
} else {
value = sticky
}
return GetPerTaskQueueScope(handler, namespaceName, partition.TaskQueue(), taskQueueBreakdown,
append(tags, PartitionTag(value))...)
}