telemetry_metrics icon indicating copy to clipboard operation
telemetry_metrics copied to clipboard

feat: add console table reporter

Open Gazler opened this issue 3 years ago • 2 comments

The console table reporter will output a table to the console in the format:

      +--------------------------------------------+
      |                 vm.memory                  |
      +-------------+------------+----------+------+
      | Measurement | Type       | Value    | Tags |
      +-------------+------------+----------+------+
      | binary      | last_value | 100 byte | %{}  |
      | total       | counter    | 200      | %{}  |
      +-------------+------------+----------+------+

Currently, if the metric name is too long (the title) then it will be truncated. The following scenarios should probably also be considered:

  1. Long measurement names
  2. Long value names
  3. Large tags
  4. Fit to the terminal width

I'm not entirely sure how to tackle these scenarios, truncating seems like a reasonable solution for 1 and 2. For 3. Perhaps the tags could be rendered over multiple lines for simple values and a warning printed for longer values, such as the Plug.Conn in http requests.

Gazler avatar Oct 02 '20 09:10 Gazler

Codecov Report

Merging #83 into master will decrease coverage by 0.09%. The diff coverage is 96.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #83      +/-   ##
==========================================
- Coverage   97.11%   97.02%   -0.10%     
==========================================
  Files           2        3       +1     
  Lines         104      168      +64     
==========================================
+ Hits          101      163      +62     
- Misses          3        5       +2     
Flag Coverage Δ
#1_10_otp21 97.00% <96.82%> (-0.11%) :arrow_down:
#1_10_otp22 97.00% <96.82%> (-0.11%) :arrow_down:
#1_6_otp19 96.96% <96.82%> (-0.09%) :arrow_down:
#1_6_otp21 96.96% <96.82%> (-0.09%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
lib/telemetry_metrics/console_table_reporter.ex 96.87% <96.87%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c53ce86...c39c9d3. Read the comment docs.

codecov-commenter avatar Oct 02 '20 09:10 codecov-commenter

This looks great! As I mentioned to @Gazler, I am worried that the formatting will get wrecked in different situations though. For example, Phoenix includes the whole conn as metatags and if that's is accidentally included it will mess things up. One option though is to warn and exclude any tag that is not a atom/string/number.

josevalim avatar Oct 02 '20 09:10 josevalim

Closing this per the above. Thank you @Gazler.

josevalim avatar Mar 18 '24 21:03 josevalim