-
Notifications
You must be signed in to change notification settings - Fork 863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated example for custom metrics and add backwards compatibility warnings and upgrade guide for metrics APIs #2516
Conversation
30dc52a
to
e1339e1
Compare
Codecov Report
@@ Coverage Diff @@
## master #2516 +/- ##
=======================================
Coverage 72.77% 72.77%
=======================================
Files 78 78
Lines 3695 3695
Branches 58 58
=======================================
Hits 2689 2689
Misses 1002 1002
Partials 4 4
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc looks fine but I'm not convinced this is the right BC story
Here are some other options I see
- Keep BC guarantee: for example if old metric API is always a counter then it shouldn't be too hard to make the old function call the new function
- If it's not possible to get BC guarantee (I'd like to understand why this is the case a bit more): then also make sure in code when the old metrics API is called to print a warning once otherwise we'll be maintaining 2 metric APIs in teh future
Regardless of if we go for 1 or 2 it's helpful to explain to users why they should migrate and what are the benefits to them of doing so, one example might be more metric types but worth clarifying this more
docs/metrics.md
Outdated
|
||
## Backwards compatibility warnings | ||
1. Starting [v0.6.1](https://github.com/pytorch/serve/releases/tag/v0.6.1), the `add_metric` API signature changed\ | ||
from [add_metric(name, value, unit, idx=None, dimensions=None)](https://github.com/pytorch/serve/blob/61f1c4182e6e864c9ef1af99439854af3409d325/ts/metrics/metrics_store.py#L184)\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the old metrics were always counters? If that's the case then keeping BC automatically shouldn't be too hard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The prior metrics implementation did not have types
associated with them. The new metrics implementation does add support for MetricTypes.
In addition, while the prior metrics implementation did not have a way to specify metrics and their specifications (name, unit, dimension names and type) in a central configuration file, the new metrics implementation introduced this, as a result which, the semantics of add_metric
method was changed
from: Create a metric object and store in a list to emit
to: Add a metric object consisting only of its specifications (name, unit, dimension names and type) to a metics cache. The dimension values are provided at the time of updating a metric using the add_or_update method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of options to ensure backwards compatibility are as follows:
- Introduce a new method in metric_cache_abstract.py, say
add_metric_bc
which has the same signature as that of the old add_metric API. This method can internally calladd_metric
and thenadd_or_update
on the metric object. The default metric type in this case would becounter
. - Change the name of the new
add_metric
method toadd_metric_to_cache
and reimplement theadd_metric
method to have the same signature as the old implementation. Then, theadd_metric
API can internally calladd_metric_to_cache
method and theadd_or_update
on the metric object.
Please share your thoughts on these approaches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like 2, add_metric_to_cache()
seems more like an internal detail whereas what a user wants to do is add_metric()
. While the semantics do change, the code won't break and that seems like a win
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Draft PR to implement backwards compatibility for add_metric
API: #2525
``` | ||
|
||
- Step 4: Install [mtail](https://github.com/google/mtail/releases) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mention in deprecation note why mtail is no longer needed
cc @duk0011 |
From user perspective, I like option 2 (change the name of the new add_metric method to add_metric_to_cache and reimplement the add_metric method to have the same signature as the old implementation). This will help with version upgrade with backward compatibility. |
Thanks for the feedback @msaroufim and @duk0011
@duk0011 please note the following in addition to the backwards compatibility implemented in #2525:
|
SGTM let's explicitly mention your note when we do the patch release next week |
Description
Provide an updated example to show usage of custom metrics APIs and the
prometheus
metrics mode.Also update metrics documentation to include warnings about backward compatibility with custom metrics APIs in prior versions.
Type of change
Feature/Issue validation/testing