@@ -60,40 +60,65 @@ function mixMeta(a, b) {
6060 * Represents a single reported metric.
6161 */
6262class MetricReport {
63+ #type;
64+ #name;
65+ #value;
66+ #meta;
67+ #time;
68+
69+ /**
70+ * Constructs a new metric report.
71+ * @param {string } type The type of metric.
72+ * @param {string } name The name of the metric.
73+ * @param {number } value The value of the metric.
74+ * @param {object } [meta] Additional metadata to include with the report.
75+ */
76+ constructor ( type , name , value , meta ) {
77+ this . #type = type ;
78+ this . #name = name ;
79+ this . #value = value ;
80+ this . #meta = meta ;
81+ this . #time = performance . now ( ) ;
82+ }
83+
6384 /**
6485 * The type of metric.
6586 * @property {string } type
6687 */
88+ get type ( ) {
89+ return this . #type;
90+ }
6791
6892 /**
6993 * The name of the metric.
7094 * @property {string } name
7195 */
96+ get name ( ) {
97+ return this . #name;
98+ }
7299
73100 /**
74101 * The value of the metric.
75102 * @property {number } value
76103 */
104+ get value ( ) {
105+ return this . #value;
106+ }
77107
78108 /**
79109 * Additional metadata to include with the report.
80110 * @property {object } meta
81111 */
112+ get meta ( ) {
113+ return this . #meta;
114+ }
82115
83116 /**
84- * Constructs a new metric report.
85- * @param {string } type The type of metric.
86- * @param {string } name The name of the metric.
87- * @param {number } value The value of the metric.
88- * @param {object } [meta] Additional metadata to include with the report.
117+ * The timestamp of the report.
118+ * @property {number } time
89119 */
90- constructor ( type , name , value , meta ) {
91- this . type = type ;
92- this . name = name ;
93- this . value = value ;
94- this . meta = meta ;
95- this . time = performance . now ( ) ;
96- ObjectFreeze ( this ) ;
120+ get time ( ) {
121+ return this . #time;
97122 }
98123
99124 /**
@@ -179,21 +204,9 @@ class MetricReport {
179204 */
180205class Metric {
181206 #channel;
182-
183- /**
184- * The type of metric.
185- * @property {string } type
186- */
187-
188- /**
189- * The name of the metric.
190- * @property {string } name
191- */
192-
193- /**
194- * Additional metadata to include with the metric.
195- * @property {object } meta
196- */
207+ #type;
208+ #name;
209+ #meta;
197210
198211 /**
199212 * Constructs a new metric.
@@ -212,9 +225,9 @@ class Metric {
212225 throw new ERR_INVALID_ARG_TYPE ( 'meta' , [ 'object' , 'undefined' ] , meta ) ;
213226 }
214227
215- this . type = type ;
216- this . name = name ;
217- this . meta = meta ;
228+ this . # type = type ;
229+ this . # name = name ;
230+ this . # meta = meta ;
218231
219232 // Before acquiring the channel, check if it already exists.
220233 const exists = hasChannel ( this . channelName ) ;
@@ -225,8 +238,30 @@ class Metric {
225238 if ( ! exists && newMetricChannel . hasSubscribers ) {
226239 newMetricChannel . publish ( this ) ;
227240 }
241+ }
228242
229- ObjectFreeze ( this ) ;
243+ /**
244+ * The type of metric.
245+ * @property {string } type
246+ */
247+ get type ( ) {
248+ return this . #type;
249+ }
250+
251+ /**
252+ * The name of the metric.
253+ * @property {string } name
254+ */
255+ get name ( ) {
256+ return this . #name;
257+ }
258+
259+ /**
260+ * Additional metadata to include with the metric.
261+ * @property {object } meta
262+ */
263+ get meta ( ) {
264+ return this . #meta;
230265 }
231266
232267 /**
0 commit comments