Files
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

120 lines
5.2 KiB
Go

package workflow
import (
enumspb "go.temporal.io/api/enums/v1"
enumsspb "go.temporal.io/server/api/enums/v1"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/persistence"
"go.temporal.io/server/common/tqid"
"go.temporal.io/server/service/history/configs"
)
func emitWorkflowHistoryStats(
metricsHandler metrics.Handler,
namespace namespace.Name,
state enumsspb.WorkflowExecutionState,
historySize int,
historyCount int,
) {
handler := metricsHandler.WithTags(metrics.NamespaceTag(namespace.String()))
executionScope := handler.WithTags(metrics.OperationTag(metrics.ExecutionStatsScope))
metrics.HistorySize.With(executionScope).Record(int64(historySize))
metrics.HistoryCount.With(executionScope).Record(int64(historyCount))
if state == enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED {
completionScope := handler.WithTags(metrics.OperationTag(metrics.WorkflowCompletionStatsScope))
metrics.HistorySize.With(completionScope).Record(int64(historySize))
metrics.HistoryCount.With(completionScope).Record(int64(historyCount))
}
}
func emitMutableStateStatus(
metricsHandler metrics.Handler,
stats *persistence.MutableStateStatistics,
) {
if stats == nil {
return
}
batchHandler := metricsHandler.StartBatch("mutable_state_status")
defer batchHandler.Close()
metrics.MutableStateSize.With(batchHandler).Record(int64(stats.TotalSize))
metrics.ExecutionInfoSize.With(batchHandler).Record(int64(stats.ExecutionInfoSize))
metrics.ExecutionStateSize.With(batchHandler).Record(int64(stats.ExecutionStateSize))
metrics.ActivityInfoSize.With(batchHandler).Record(int64(stats.ActivityInfoSize))
metrics.ActivityInfoCount.With(batchHandler).Record(int64(stats.ActivityInfoCount))
metrics.TotalActivityCount.With(batchHandler).Record(stats.TotalActivityCount)
metrics.TimerInfoSize.With(batchHandler).Record(int64(stats.TimerInfoSize))
metrics.TimerInfoCount.With(batchHandler).Record(int64(stats.TimerInfoCount))
metrics.TotalUserTimerCount.With(batchHandler).Record(stats.TotalUserTimerCount)
metrics.ChildInfoSize.With(batchHandler).Record(int64(stats.ChildInfoSize))
metrics.ChildInfoCount.With(batchHandler).Record(int64(stats.ChildInfoCount))
metrics.TotalChildExecutionCount.With(batchHandler).Record(stats.TotalChildExecutionCount)
metrics.RequestCancelInfoSize.With(batchHandler).Record(int64(stats.RequestCancelInfoSize))
metrics.RequestCancelInfoCount.With(batchHandler).Record(int64(stats.RequestCancelInfoCount))
metrics.TotalRequestCancelExternalCount.With(batchHandler).Record(stats.TotalRequestCancelExternalCount)
metrics.SignalInfoSize.With(batchHandler).Record(int64(stats.SignalInfoSize))
metrics.SignalInfoCount.With(batchHandler).Record(int64(stats.SignalInfoCount))
metrics.TotalSignalExternalCount.With(batchHandler).Record(stats.TotalSignalExternalCount)
metrics.SignalRequestIDSize.With(batchHandler).Record(int64(stats.SignalRequestIDSize))
metrics.SignalRequestIDCount.With(batchHandler).Record(int64(stats.SignalRequestIDCount))
metrics.TotalSignalCount.With(batchHandler).Record(stats.TotalSignalCount)
metrics.BufferedEventsSize.With(batchHandler).Record(int64(stats.BufferedEventsSize))
metrics.BufferedEventsCount.With(batchHandler).Record(int64(stats.BufferedEventsCount))
metrics.ChasmTotalSize.With(batchHandler).Record(int64(stats.ChasmTotalSize))
if stats.HistoryStatistics != nil {
metrics.HistorySize.With(batchHandler).Record(int64(stats.HistoryStatistics.SizeDiff))
metrics.HistoryCount.With(batchHandler).Record(int64(stats.HistoryStatistics.CountDiff))
}
for category, taskCount := range stats.TaskCountByCategory {
metrics.TaskCount.With(batchHandler).Record(int64(taskCount), metrics.TaskCategoryTag(category))
}
}
func emitWorkflowCompletionStats(
metricsHandler metrics.Handler,
namespace namespace.Name,
namespaceState string,
taskQueue string,
status enumspb.WorkflowExecutionStatus,
config *configs.Config,
) {
handler := GetPerTaskQueueFamilyScope(metricsHandler, namespace, taskQueue, config,
metrics.OperationTag(metrics.WorkflowCompletionStatsScope),
metrics.NamespaceStateTag(namespaceState),
)
switch status {
case enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED:
metrics.WorkflowSuccessCount.With(handler).Record(1)
case enumspb.WORKFLOW_EXECUTION_STATUS_CANCELED:
metrics.WorkflowCancelCount.With(handler).Record(1)
case enumspb.WORKFLOW_EXECUTION_STATUS_FAILED:
metrics.WorkflowFailedCount.With(handler).Record(1)
case enumspb.WORKFLOW_EXECUTION_STATUS_TIMED_OUT:
metrics.WorkflowTimeoutCount.With(handler).Record(1)
case enumspb.WORKFLOW_EXECUTION_STATUS_TERMINATED:
metrics.WorkflowTerminateCount.With(handler).Record(1)
case enumspb.WORKFLOW_EXECUTION_STATUS_CONTINUED_AS_NEW:
metrics.WorkflowContinuedAsNewCount.With(handler).Record(1)
}
}
func GetPerTaskQueueFamilyScope(
handler metrics.Handler,
namespaceName namespace.Name,
taskQueueFamily string,
config *configs.Config,
tags ...metrics.Tag,
) metrics.Handler {
return metrics.GetPerTaskQueueFamilyScope(handler,
namespaceName.String(),
tqid.UnsafeTaskQueueFamily(namespaceName.String(), taskQueueFamily),
config.BreakdownMetricsByTaskQueue(namespaceName.String(), taskQueueFamily, enumspb.TASK_QUEUE_TYPE_WORKFLOW),
tags...,
)
}