Edit Order Notification Monitoring Code¶
Metric Monitoring (i.e. Datadog)¶
This code handles all metrics that would want to be monitored using the monitoring service Datadog or similar.
Metrics can be added with add_metric(s) as well as being passed as an input_metrics list when the MetricManager class is initialised. With these added metrics a counter can be incremented which sends all the metrics once it reaches certain values. The send_single_metric function is not related to the counter and will send the metric immediately. It can have any metric name, it can be already added as a metric or be a brand new, separate metric.
Check metrics should be set rather than incremented, as they can only be between 0-3 (0 is ok, 1 is warning, 2 is critical, 3 is unknown). However, it should also be used with send_single_metric outside of loops/counters, e.g. check of 2 sent on an error.
Count metrics would usually be added metrics that use the increment_metric(s) function so that certain important values within the app are counted and then monitored in Datadog (or similar) every multiple specified.
It is also recommended to use send_all_added_metrics at the end of the process to give the final results of each metric.