mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? Add metrics for dataloss events that containe workflowID, runID and namespaceID. This metric will only be emitted if config `system.enableDataLossMetrics` is enabled. ## Why? To find affected workflow runs if there are any dataloss errors. ## How did you test it? - [x] built - [ ] run locally and tested manually - [ ] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s)
27 lines
629 B
Go
27 lines
629 B
Go
package persistence
|
|
|
|
import (
|
|
"go.temporal.io/server/common/metrics"
|
|
)
|
|
|
|
const (
|
|
WorkflowIDTagName = "workflow_id"
|
|
RunIDTagName = "run_id"
|
|
ErrorTagName = "error"
|
|
)
|
|
|
|
// EmitDataLossMetric emits a data loss metric for DataLoss errors
|
|
func EmitDataLossMetric(
|
|
handler metrics.Handler,
|
|
namespaceName, workflowID, runID, source string,
|
|
err error,
|
|
) {
|
|
metrics.DataLossCounter.With(handler).Record(1,
|
|
metrics.NamespaceTag(namespaceName),
|
|
metrics.StringTag(WorkflowIDTagName, workflowID),
|
|
metrics.StringTag(RunIDTagName, runID),
|
|
metrics.OperationTag(source),
|
|
metrics.StringTag(ErrorTagName, err.Error()),
|
|
)
|
|
}
|