@@ -144,6 +144,47 @@ public LongCounterMetricInstrument registerLongCounter(String name,
144144 }
145145 }
146146
147+ /**
148+ * Registers a new Long Up Down Counter metric instrument.
149+ *
150+ * @param name the name of the metric
151+ * @param description a description of the metric
152+ * @param unit the unit of measurement for the metric
153+ * @param requiredLabelKeys a list of required label keys
154+ * @param optionalLabelKeys a list of optional label keys
155+ * @param enableByDefault whether the metric should be enabled by default
156+ * @return the newly created LongUpDownCounterMetricInstrument
157+ * @throws IllegalStateException if a metric with the same name already exists
158+ */
159+ public LongUpDownCounterMetricInstrument registerLongUpDownCounter (String name ,
160+ String description ,
161+ String unit ,
162+ List <String > requiredLabelKeys ,
163+ List <String > optionalLabelKeys ,
164+ boolean enableByDefault ) {
165+ checkArgument (!Strings .isNullOrEmpty (name ), "missing metric name" );
166+ checkNotNull (description , "description" );
167+ checkNotNull (unit , "unit" );
168+ checkNotNull (requiredLabelKeys , "requiredLabelKeys" );
169+ checkNotNull (optionalLabelKeys , "optionalLabelKeys" );
170+ synchronized (lock ) {
171+ if (registeredMetricNames .contains (name )) {
172+ throw new IllegalStateException ("Metric with name " + name + " already exists" );
173+ }
174+ int index = nextAvailableMetricIndex ;
175+ if (index + 1 == metricInstruments .length ) {
176+ resizeMetricInstruments ();
177+ }
178+ LongUpDownCounterMetricInstrument instrument = new LongUpDownCounterMetricInstrument (
179+ index , name , description , unit , requiredLabelKeys , optionalLabelKeys ,
180+ enableByDefault );
181+ metricInstruments [index ] = instrument ;
182+ registeredMetricNames .add (name );
183+ nextAvailableMetricIndex += 1 ;
184+ return instrument ;
185+ }
186+ }
187+
147188 /**
148189 * Registers a new Double Histogram metric instrument.
149190 *
0 commit comments