Commit 6ed8dcda by Troy Sankey Committed by GitHub

Merge pull request #14479 from edx/pwnage101/update-custom-metrics-docstrings

improve docstrings for newrelic_custom_metrics middleware
parents 9be31918 cb122fc0
...@@ -9,6 +9,12 @@ example: ...@@ -9,6 +9,12 @@ example:
There is no need to do anything else. The metrics are automatically cleared There is no need to do anything else. The metrics are automatically cleared
before the next request. before the next request.
We try to keep track of our custom metrics at:
https://openedx.atlassian.net/wiki/display/PERF/Custom+Metrics+in+New+Relic
TODO: supply additional public functions for storing strings and booleans.
""" """
from newrelic_custom_metrics import middleware from newrelic_custom_metrics import middleware
...@@ -16,19 +22,22 @@ from newrelic_custom_metrics import middleware ...@@ -16,19 +22,22 @@ from newrelic_custom_metrics import middleware
def accumulate(name, value): def accumulate(name, value):
""" """
Queue up a custom New Relic metric for the current request. At the end of Accumulate custom New Relic metric for the current request.
the request, the newrelic_custom_metrics middleware will batch report all
queued metrics to NR.
Q: What style of names should I use? The named metric is accumulated by a numerical amount using the sum. All
A: Metric names should be comma delimited, becoming more specific from left metrics are queued up in the request_cache for this request. At the end of
to right. the request, the newrelic_custom_metrics middleware will batch report all
queued accumulated metrics to NR.
Q: What type can values be?
A: numbers only. Arguments:
name (str): The metric name. It should be period-delimited, and
Q: What happens when I call this multiple times with the same name? increase in specificty from left to right. For example:
A: Like-named metrics will be accumulated using the sum. 'xb_user_state.get_many.num_items'.
value (number): The amount to accumulate into the named metric. When
accumulate() is called multiple times for a given metric name
during a request, the sum of the values for each call is reported
for that metric. For metrics which don't make sense to accumulate,
make sure to only call this function once during a request.
""" """
middleware.NewRelicCustomMetrics.accumulate_metric(name, value) middleware.NewRelicCustomMetrics.accumulate_metric(name, value)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment