Skip to content

Conversation

@aristidesstaffieri
Copy link
Contributor

Closes #342

What

adds metric collection for state change operations

Why

To support initial deployment and observability

Known limitations

N/A

#342

Checklist

PR Structure

  • It is not possible to break this PR down into smaller PRs.
  • This PR does not mix refactoring changes with feature changes.
  • This PR's title starts with name of package that is most changed in the PR, or all if the changes are broad or impact many packages.

Thoroughness

  • This PR adds tests for the new functionality or fixes.
  • All updated queries have been tested (refer to this check if the data set returned by the updated query is expected to be same as the original one).

Release

  • This is not a breaking change.
  • This is ready to be tested in development.
  • The new functionality is gated with a feature flag if this is not ready for production.

@aristidesstaffieri aristidesstaffieri self-assigned this Oct 24, 2025
)
duration := time.Since(start).Seconds()
m.MetricsService.ObserveDBQueryDuration("INSERT", "state_changes", duration)
m.MetricsService.ObserveStateChangePersistenceDuration(duration)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think we should remove the ObserveStateChangePersistenceDuration since that is basically the same as the ObserveDBQueryDuration for insertion of state changes and is already being tracked in the DB metrics

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed in a831af9

operation = *correctOp
}
// For fee state changes (OperationID == 0), operation remains zero value
buffer.PushStateChange(*dataTx, operation, stateChange)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What makes sense is to track the count of different types of state changes created: category, type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added counts by category in 46eb13f

return nil, fmt.Errorf("batch inserting state changes: %w", err)
}
m.MetricsService.IncDBQuery("INSERT", "state_changes")
m.MetricsService.IncStateChangesPersisted(len(insertedIDs))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THis metric can be moved to the indexer.go file where we should also track the different types and categories of state changes apart from the total state changes created

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved the total to the indexer in 46eb13f

m.MetricsService.ObserveDBQueryDuration("INSERT", "state_changes", duration)
m.MetricsService.ObserveStateChangePersistenceDuration(duration)
if err != nil {
m.MetricsService.IncStateChangePersistenceErrors("insert_error")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also remove this metric since we are already tracking it via the db error metrics:

m.MetricsService.IncDBQueryError("BatchInsert", "state_changes", utils.GetDBErrorType(err))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed in a831af9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add metrics for state change processors

3 participants