> For the complete documentation index, see [llms.txt](https://omalab.gitbook.io/guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://omalab.gitbook.io/guide/engineering-wiki/monitoring-and-alerting/instrumenting-your-models-using-oma-stats.md).

# Instrumenting your models using Oma Stats

OMA::Stats uses StatsD to our Graphite Server. [Here](https://www.evernote.com/l/AAGG7NbeLXROG6tqT76-YIGjaMGQH7YY8X8) is an overview of what the various types of buckets mean.

## StatD metric hierarchy and standards

**Top Level Stats (OMA)**

* Error stats - 'oma.#{env}.web.error.count, instrumented with helper log\_ux\_error
* Slow stats - "oma.#{env}.web.slow\.count", instrumented with helper log\_ux\_slow
* Confusing stats - "oma.#{env}.web.confusing.count", instrumented with helper log\_ux\_confusing

**Top Level Hierarchy**

* Performance stats - default logs for every page load is: 'oma.#{env}.web.performance.\*'
* User stats - default logs for user experience is: 'oma.#{env}.web.user.\*
* Routing stats - errors with bad paths, etc: 'oma.#{env}.web.routing.\*
* Error stats - when we get an error: oma.#{env}.web.error.\*

Every front end request is logged in StatsD for its timing. In addition, there is an overview bucket that shows performance by environment as well that is logged on every request. This is so we can describe an overall UX for our customers.

This tracking is in the oma.stats

## Logging User Experience

When a user experiences something slow, or an error, we should bulk up these statistics. The buckets are:

* Slow queries = "user.#{user.id}.ux.slow
* Error messages = "user.#{user.id}.ux.error

There are helpers implemented in oma's application\_controller that help with this. Just use the term:

* log\_ux\_slow
* log\_ux\_error
* log\_ux\_confusing

The goal is to have the user experience improve to where the user does not experience any of these items.
