You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by "freak82 (via GitHub)" <gi...@apache.org> on 2024/05/14 09:43:33 UTC

[I] Question about the new `Metrics` stats interface [trafficserver]

freak82 opened a new issue, #11349:
URL: https://github.com/apache/trafficserver/issues/11349

   Hi there,
   
   I'm developing an ATS plugin for our company.
   
   According to [this page](https://docs.trafficserver.apache.org/en/latest/developer-guide/api/functions/TSStat.en.html), I should use the new APIs from `Metrics.h`. Correct me if I misunderstood the Note.
   
   I glanced over the functionality in the `Metrics.h` and checked its usage inside the ATS core. I think, I understood how to use it.
   ```
   // define the counter
   ts::Metrics::Counter::AtomicType *counter_name;
   ...
   // create/register the counter
   counter_name = ts::Metrics::Counter::createPtr("the-name-of-the-counter");
   ...
   // use the counter
   ts::Metrics::Counter::increment(counter_name);
   ```
   
   However, I'm wondering about the future binary compatibility. 
   So far, all of the other APIs are C functions and opaque types/pointers to hide the actual implementation.
   However, this new functionality exposes lots of implementation details in the header file along with the `Metrics` data member.
   Now if I use this functionality and for example:
   - my plugin is built against ATS version 10
   - ATS version 12 introduces some changes in the `Metrics` functionality which change the implementation of some of the inline functions and/or the data members of `Metrics`.
   It seems to me, that In the above scenario the plugin may experience some UB (Undefined Behavior) effects if run along ATS version 12.
   
   Did I misunderstood something? 
   Or there is no guarantee for binary compatibility between the ATS versions and I should always rebuild the plugins against the currently used ATS version?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Question about the new `Metrics` stats interface [trafficserver]

Posted by "freak82 (via GitHub)" <gi...@apache.org>.
freak82 commented on issue #11349:
URL: https://github.com/apache/trafficserver/issues/11349#issuecomment-2121782128

   Thank you all for the clarifications.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Question about the new `Metrics` stats interface [trafficserver]

Posted by "freak82 (via GitHub)" <gi...@apache.org>.
freak82 closed issue #11349: Question about the new `Metrics` stats interface
URL: https://github.com/apache/trafficserver/issues/11349


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Question about the new `Metrics` stats interface [trafficserver]

Posted by "zwoop (via GitHub)" <gi...@apache.org>.
zwoop commented on issue #11349:
URL: https://github.com/apache/trafficserver/issues/11349#issuecomment-2121360353

   The common use case, using these APIs rather than the old APIs in ts.h (which also uses the new Metrics under the hood) would be
   
   ```
   auto  id1  = ts::Metrics::Counter::create(name);
   auto  id2  = ts::Metrics::Gauge::create(name);
   ```
   
   If you want the pointer, you can get it from the id, e.g.
   
   ```
       auto ptr1 = ts::Metrics::Counter::lookup(id1, nullptr);
       auto ptr2 = ts::Metrics::Gauge::lookup(id2, nullptr);
   ```
   
   or, you can also create them directly with createPtr() as above, e.g.
   
   ```
   auto  ptr1 = ts::Metrics::Counter::createPtr(name);
   auto  ptr2  = ts::Metrics::Gauge::createPtr(name);
   ```
   
   Note that the lookup() functionalities requires locking around the lookup tables etc., so are not a good idea to do in critical code. The ID can be used to access the metric directly though, without locks, such as
   
   ```
       static auto &instance = ts::Metrics::instance();
   
       instance[id1].increment();
       instance[id2].decrement(5);
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Question about the new `Metrics` stats interface [trafficserver]

Posted by "bryancall (via GitHub)" <gi...@apache.org>.
bryancall commented on issue #11349:
URL: https://github.com/apache/trafficserver/issues/11349#issuecomment-2121343362

   We require rebuilding plugin for new major version releases of ATS.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org