instana / ruby-sensor

💎 Ruby Distributed Tracing & Metrics Sensor for Instana
https://www.instana.com/
MIT License
26 stars 25 forks source link

fix: Change unit of memory to match the UI #289

Closed Ferenc- closed 1 year ago

Ferenc- commented 1 year ago

Problem: The UI in rubyRuntimePlatform/Dashboard/Content.js uses the formatter: kiloBytesTwoDecimalPlaces for displaying the value in plugins.rubyRuntimePlatform.dashboard.memory.

Which essentially treats the unit of the value as a Kilobyte, This has not changed in a long long time. In the ruby-sensor however in c49f7dfe191f1cc3c0278042ddb76cbc5ff31181 things have changed, the rss value propagation has been separated on the two mainly supported platforms darwin and linux . The orignal code previous to c49f7dfe191f1cc3c0278042ddb76cbc5ff31181 was converting the rss value to kibibyte on the top level, before sending the metrics.

After c49f7dfe191f1cc3c0278042ddb76cbc5ff31181, for host agents (non-serverless), the rss for darwin is read in byte and then immediately converted to kibibyte, but for linux the rss is read in number of pages, and converted to bytes instead of kibibyte with the 4096 byte page constant. And the top level conversion was removed. This left the MacOS reporting in kibibyte while Linux reporting in bytes.

This commit restores the original top level conversion, and makes sure that before the conversion everything is in bytes on both OS, this aligns with ruby_process.rb , which is still used for serverless, and also keeps the values in bytes and only converts them before sending.