@@ -247,5 +247,82 @@ class UpDownCounter : public SynchronousInstrument
247247  }
248248};
249249
250+ #if  OPENTELEMETRY_ABI_VERSION_NO >= 2
251+ /*  A Gauge instrument that records values. */ 
252+ template  <class  T >
253+ class  Gauge  : public  SynchronousInstrument 
254+ {
255+ 
256+ public: 
257+   /* *
258+    * Record a value 
259+    * 
260+    * @param value The measurement value. May be positive, negative or zero. 
261+    */  
262+   virtual  void  Record (T value) noexcept  = 0;
263+ 
264+   /* *
265+    * Record a value 
266+    * 
267+    * @param value The measurement value. May be positive, negative or zero. 
268+    * @param context The explicit context to associate with this measurement. 
269+    */  
270+   virtual  void  Record (T value, const  context::Context &context) noexcept  = 0;
271+ 
272+   /* *
273+    * Record a value with a set of attributes. 
274+    * 
275+    * @param value The measurement value. May be positive, negative or zero. 
276+    * @param attributes A set of attributes to associate with the value. 
277+    */  
278+ 
279+   virtual  void  Record (T value, const  common::KeyValueIterable &attributes) noexcept  = 0;
280+ 
281+   /* *
282+    * Record a value with a set of attributes. 
283+    * 
284+    * @param value The measurement value. May be positive, negative or zero. 
285+    * @param attributes A set of attributes to associate with the value. 
286+    * @param context The explicit context to associate with this measurement. 
287+    */  
288+   virtual  void  Record (T value,
289+                       const  common::KeyValueIterable &attributes,
290+                       const  context::Context &context) noexcept  = 0;
291+ 
292+   template  <class  U ,
293+             nostd::enable_if_t <common::detail::is_key_value_iterable<U>::value> * = nullptr >
294+   void  Record (T value, const  U &attributes) noexcept 
295+   {
296+     this ->Record (value, common::KeyValueIterableView<U>{attributes});
297+   }
298+ 
299+   template  <class  U ,
300+             nostd::enable_if_t <common::detail::is_key_value_iterable<U>::value> * = nullptr >
301+   void  Record (T value, const  U &attributes, const  context::Context &context) noexcept 
302+   {
303+     this ->Record (value, common::KeyValueIterableView<U>{attributes}, context);
304+   }
305+ 
306+   void  Record (T value,
307+               std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
308+                   attributes) noexcept 
309+   {
310+     this ->Record (value, nostd::span<const  std::pair<nostd::string_view, common::AttributeValue>>{
311+                             attributes.begin (), attributes.end ()});
312+   }
313+ 
314+   void  Record (
315+       T value,
316+       std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes,
317+       const  context::Context &context) noexcept 
318+   {
319+     this ->Record (value,
320+                  nostd::span<const  std::pair<nostd::string_view, common::AttributeValue>>{
321+                      attributes.begin (), attributes.end ()},
322+                  context);
323+   }
324+ };
325+ #endif 
326+ 
250327}  //  namespace metrics
251328OPENTELEMETRY_END_NAMESPACE
0 commit comments