Skip to content

Commit

Permalink
feat(templates): adding timer metric to the patch templates (#64)
Browse files Browse the repository at this point in the history
adding timer metric to the patch templates
  • Loading branch information
Jacobbrewer1 authored Jan 16, 2025
1 parent 9a6d20c commit 27a7adb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions templates/_update.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ func (m *{{ $struct }}) Patch(db DB, newT *{{ $struct }}) error {
return errors.New("new {{ .Name }} is nil")
}

t := prometheus.NewTimer(DatabaseLatency.WithLabelValues("patch_" + {{ $struct }}TableName))
defer t.ObserveDuration()

res, err := patcher.NewDiffSQLPatch(m, newT, patcher.WithTable({{ $struct | structify -}}TableName))
if err != nil {
return fmt.Errorf("new diff sql patch: %w", err)
Expand Down

0 comments on commit 27a7adb

Please sign in to comment.