Skip to content

Commit a795835

Browse files
Bryce Andersonjenkins
Bryce Anderson
authored and
jenkins
committed
util-stats: Deprecate methods on the MetricBuilder API
Problem We use MetricBuilder as or source-of-truth representation of a metrics identity. However, it also has a `StatsReceiver` as a field that kind of messes up this clean representation. Solution Deprecate the `statsReceiver` field and remove the metric instantiation methods. Differential Revision: https://phabricator.twitter.biz/D862244
1 parent f069723 commit a795835

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.rst

+7
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ Breaking API Changes
4242

4343
* util-core: The `c.t.util.Responder` trait has been removed. ``PHAB_ID=D824830``
4444

45+
Deprecations
46+
~~~~~~~~~~~~
47+
48+
* util-stats: Deprecated methods on `MetricBuilder` for directly instantiating metrics so that we can
49+
eventually remove the `statsReceiever` field from `MetricBuilder` and let it just be the source of
50+
truth for defining a metric. ``PHAB_ID=D862244``
51+
4552
22.1.0
4653
------
4754

util-stats/src/main/scala/com/twitter/finagle/stats/MetricBuilder.scala

+5
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ class MetricBuilder private (
182182
val percentiles: IndexedSeq[Double],
183183
val isStandard: Boolean,
184184
val metricType: MetricType,
185+
@deprecated("Being removed to make MetricBuilder strictly a metric definition.", "2022-03-28")
185186
val statsReceiver: StatsReceiver)
186187
extends Metadata {
187188

@@ -306,6 +307,7 @@ class MetricBuilder private (
306307
* Produce a counter as described by the builder inside the underlying StatsReceiver.
307308
* @return the counter created.
308309
*/
310+
@deprecated("Use the StatsReceiver interface for instantiation.", "2022-03-28")
309311
@varargs
310312
final def counter(name: String*): Counter = {
311313
this.statsReceiver.validateMetricType(this, CounterType)
@@ -316,6 +318,7 @@ class MetricBuilder private (
316318
* Produce a gauge as described by the builder inside the underlying StatsReceiver.
317319
* @return the gauge created.
318320
*/
321+
@deprecated("Use the StatsReceiver interface for instantiation.", "2022-03-28")
319322
final def gauge(name: String*)(f: => Float): Gauge = {
320323
this.statsReceiver.validateMetricType(this, GaugeType)
321324
this.statsReceiver.addGauge(this.withName(name: _*))(f)
@@ -326,6 +329,7 @@ class MetricBuilder private (
326329
* This API is for Java compatibility
327330
* @return the gauge created.
328331
*/
332+
@deprecated("Use the StatsReceiver interface for instantiation.", "2022-03-28")
329333
@varargs
330334
final def gauge(f: Supplier[Float], name: String*): Gauge = {
331335
this.statsReceiver.validateMetricType(this, GaugeType)
@@ -336,6 +340,7 @@ class MetricBuilder private (
336340
* Produce a histogram as described by the builder inside the underlying StatsReceiver.
337341
* @return the histogram created.
338342
*/
343+
@deprecated("Use the StatsReceiver interface for instantiation.", "2022-03-28")
339344
@varargs
340345
final def histogram(name: String*): Stat = {
341346
this.statsReceiver.validateMetricType(this, HistogramType)

0 commit comments

Comments
 (0)