Files
tasks/common/persistence/metrics.go
Prathyush PVandGitHub 5a0785bc4c Add metrics for data loss events (#8310)
## 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)
2025-09-19 09:44:47 -07:00

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()),
)
}