@@ -218,25 +218,34 @@ class Metric {
218218 * reset() is called, or when applyDelta() is called with a non-zero value.
219219 */
220220class Gauge {
221+ #metric;
222+ #value;
223+
224+ /**
225+ * @param {Metric } metric The metric to report to.
226+ */
227+ constructor ( metric ) {
228+ if ( ! ( metric instanceof Metric ) ) {
229+ throw new ERR_INVALID_ARG_TYPE ( 'metric' , [ 'Metric' ] , metric ) ;
230+ }
231+ this . #metric = metric ;
232+ this . #value = 0 ;
233+ }
234+
221235 /**
222236 * The metric to report to.
223237 * @property {Metric } metric
224238 */
239+ get metric ( ) {
240+ return this . #metric;
241+ }
225242
226243 /**
227244 * The value of the gauge.
228245 * @property {number } value
229246 */
230-
231- /**
232- * @param {Metric } metric The metric to report to.
233- */
234- constructor ( metric ) {
235- if ( ! ( metric instanceof Metric ) ) {
236- throw new ERR_INVALID_ARG_TYPE ( 'metric' , [ 'Metric' ] , metric ) ;
237- }
238- this . metric = metric ;
239- this . value = 0 ;
247+ get value ( ) {
248+ return this . #value;
240249 }
241250
242251 /**
@@ -245,18 +254,9 @@ class Gauge {
245254 * @param {object } [meta] Additional metadata to include with the report.
246255 */
247256 reset ( value = 0 , meta ) {
248- this . value = value ;
257+ this . # value = value ;
249258 this . metric . report ( value , meta ) ;
250259 }
251-
252- /**
253- * Apply a delta to the gauge.
254- * @param {number } value The delta to apply to the gauge.
255- * @param {object } [meta] Additional metadata to include with the report.
256- */
257- applyDelta ( value , meta ) {
258- this . reset ( this . value + value , meta ) ;
259- }
260260}
261261
262262/**
@@ -276,7 +276,7 @@ class Counter extends Gauge {
276276 n = 1 ;
277277 }
278278
279- this . applyDelta ( n , meta ) ;
279+ this . reset ( this . value + n , meta ) ;
280280 }
281281
282282 /**
@@ -292,7 +292,7 @@ class Counter extends Gauge {
292292 n = 1 ;
293293 }
294294
295- this . applyDelta ( - n , meta ) ;
295+ this . reset ( this . value + - n , meta ) ;
296296 }
297297}
298298
0 commit comments