Skip to content

Commit 75da6fa

Browse files
authored
Merge pull request #128 from zhongwencool/fix-typo
v1.8.6
1 parent 3c18c88 commit 75da6fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3700
-380
lines changed

.github/workflows/erlang.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,14 @@ jobs:
2626
rebar3-version: ${{matrix.rebar3}}
2727
- name: quality checks
2828
run: rebar3 check
29+
- name: test coverage
30+
run: |
31+
epmd -daemon
32+
rebar3 as test do eunit, covertool generate
33+
- name: Upload coverage reports to Codecov
34+
if: matrix.otp == '28'
35+
uses: codecov/codecov-action@v5
36+
with:
37+
token: ${{ secrets.CODECOV_TOKEN }}
38+
slug: zhongwencool/observer_cli
39+
files: _build/test/covertool/*.covertool.xml

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ log/
1818
.erlang.mk
1919

2020
xrefr
21+
AGENTS.md

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
# observer_cli
44

55
[![Build Status](https://github.com/zhongwencool/observer_cli/workflows/ci/badge.svg)](https://github.com/zhongwencool/observer_cli/actions)
6+
[![codecov](https://codecov.io/gh/zhongwencool/observer_cli/branch/main/graph/badge.svg)](https://codecov.io/gh/zhongwencool/observer_cli)
67
[![GitHub tag](https://img.shields.io/github/tag/zhongwencool/observer_cli.svg)](https://github.com/zhongwencool/observer_cli)
78
[![MIT License](https://img.shields.io/hexpm/l/observer_cli.svg)](https://hex.pm/packages/observer_cli)
89
[![Hex.pm Version](https://img.shields.io/hexpm/v/observer_cli.svg)](https://hex.pm/packages/observer_cli)
910
[![Hex.pm Downloads](https://img.shields.io/hexpm/dt/observer_cli.svg)](https://hex.pm/packages/observer_cli)
1011
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/observer_cli/)
1112

12-
Observer CLI is a library to be dropped into any beam nodes, to be used to assist DevOps people diagnose problems in production nodes. Based on [recon](https://github.com/ferd/recon).
13+
Observer CLI is a library to be dropped into any BEAM nodes, to be used to help DevOps people diagnose problems in production nodes. Based on [recon](https://github.com/ferd/recon).
1314

1415
<img src="https://github.com/zhongwencool/observer_cli/raw/main/docs/images/home.png" width="100%" alt="Home"> </img>
1516

@@ -28,7 +29,7 @@ Observer CLI is a library to be dropped into any beam nodes, to be used to assis
2829
%% rebar.config
2930
{deps, [observer_cli]}
3031
%% erlang.mk
31-
dep_observer_cli = hex 1.8.5
32+
dep_observer_cli = hex 1.8.6
3233
```
3334

3435
### Elixir
@@ -53,6 +54,7 @@ dep_observer_cli = hex 1.8.5
5354
rebar3 shell
5455
1> observer_cli:start().
5556
```
57+
Tip: CI uses `rebar3 as ci compile` (warnings are treated as errors).
5658
### Elixir
5759
```elixir
5860
%% mix project
@@ -79,7 +81,7 @@ iex(1)> :observer_cli.start(:'target@host', :'magic_cookie')
7981
<!-- tabs-close -->
8082

8183
> #### exclamation {: .info}
82-
> **ensure observer_cli application been loaded on target node.**
84+
> **ensure the observer_cli application has been loaded on the target node.**
8385
8486
> #### tip {: .tip}
8587
> Pass `{interval, 3000}` (Erlang) or `interval: 3000` (Elixir) to sample every 3 seconds. The minimum refresh interval is 1000 ms.
@@ -100,7 +102,7 @@ iex(1)> :observer_cli.start(:'target@host', :'magic_cookie')
100102

101103
The Home panel provides a comprehensive overview of your Erlang node:
102104

103-
[`erlang:system_info/1`](http://erlang.org/doc/man/erlang.html#system_info-1) returns specified information about the current system by below item. When the ratio is greater than 85%, it becomes red.
105+
[`erlang:system_info/1`](http://erlang.org/doc/man/erlang.html#system_info-1) returns specified information about the current system in the items below. When the ratio is greater than 85%, it becomes red.
104106

105107
| Metric | Source/Limit |
106108
|--------------------|---------------------------|
@@ -109,7 +111,7 @@ The Home panel provides a comprehensive overview of your Erlang node:
109111
| Atom Count | atom_count/atom_limit |
110112

111113
* **process_limit**: `erl +P Number` sets the maximum number of simultaneously existing processes for this system if a Number is passed as value. Valid range for Number is [1024-134217727]. The default value is 262144.
112-
* **port_limit**: `erl +Q Number` sets the maximum number of simultaneously existing ports for this system if a Number is passed as value. Valid range for Number is [1024-134217727]. The default value used is normally 65536. However, if the runtime system is able to determine maximum amount of file descriptors that it is allowed to open and this value is larger than 65536, the chosen value will increased to a value larger or equal to the maximum amount of file descriptors that can be opened.
114+
* **port_limit**: `erl +Q Number` sets the maximum number of simultaneously existing ports for this system if a Number is passed as value. Valid range for Number is [1024-134217727]. The default value used is normally 65536. However, if the runtime system is able to determine maximum amount of file descriptors that it is allowed to open and this value is larger than 65536, the chosen value will be increased to a value larger than or equal to the maximum amount of file descriptors that can be opened.
113115
* **atom_limit**: `erl +t size` sets the maximum number of atoms the virtual machine can handle. Defaults to 1,048,576.
114116

115117
[`ps`](https://man7.org/linux/man-pages/man1/ps.1.html) reports a snapshot of the BEAM OS process and feeds the system panel. Observer CLI samples four columns:
@@ -155,7 +157,7 @@ When looking for high memory usage, for example it's interesting to be able to l
155157

156158
[`recon:proc_count/2`](http://ferd.github.io/recon/recon.html#proc_count-2) and [`recon:proc_window/3`](http://ferd.github.io/recon/recon.html#proc_window-3) are to be used when you require information about processes in a larger sense: biggest consumers of given process `memory`, `reductions`, `binary`, `total_heap_size`, `message_queue_len`, either absolutely or over a sliding time window, respectively.
157159

158-
More detail about sliding time windows see [`recon:proc_window/3`](http://ferd.github.io/recon/recon.html#proc_window-3)
160+
For more detail about sliding time windows, see [`recon:proc_window/3`](http://ferd.github.io/recon/recon.html#proc_window-3)
159161

160162
When an abnormal process is found, enter the suspected process sequence(Integer) then press `Enter` will use [`erlang:process_info/2`](http://erlang.org/doc/man/erlang.html#process_info-2) to show a lot of information available (which is safe to use in production) about processes.
161163

docs/CHANGELOG.md

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
# Changelog
2+
- 1.8.6
3+
- Add external formatter support (dynamic loading/app env) and docs; formatter callback now receives pid.
4+
- Improve State view rendering by fixing redraw timers and infinite-loop edge cases.
5+
- Improve less_client/less_server navigation and status output (F/B commands, last line, row fetching).
6+
- Auto update net_ticktime.
7+
- Fix mix compilation and avoid compiling test/ in release builds.
8+
- Remove recon from included_applications.
9+
10+
- 1.8.5
11+
- Sync default env between mix.exs and .app.src; comment out scheduler_usage default.
12+
- Refactor app stats and command parsing internals; update type specs and configs.
13+
- Update docs and plugin guide; refresh README images/assets.
14+
- CI: drop OTP 24/25 from test matrix.
15+
216
- 1.8.4
3-
- Fix OTP 28 dialzyer warning.
17+
- Fix OTP 28 dialyzer warning.
418
- Use erlang:processes_iterator/0, erlang:process_next/1 to fold processes when OTP 28.
519

620
- 1.8.3
@@ -17,36 +31,36 @@
1731
- 1.8.0
1832
- Support `<Pid` to jump to specific pid.
1933
- Show process's label if it's set with [proc_lib:set_label(Label)](https://www.erlang.org/doc/apps/stdlib/proc_lib.html#set_label/1)
20-
- Show The number of bytes in the output distribution queue on System View. This queue sits between the Erlang code and the port driver, using undocumented function`erlang:dist_get_stat/1`.
21-
- Fix Doc View not show when otp version = 27
34+
- Show the number of bytes in the output distribution queue on System View. This queue sits between the Erlang code and the port driver, using undocumented function `erlang:dist_get_stat/1`.
35+
- Fix Doc View not showing when OTP version = 27
2236

2337
- 1.7.5
2438
- Fix crash when mnesia table with external copies.
2539
Which `mnesia:table_info(TabName, storage_type)` returns tuple `{ext, _, _}`
2640
- Correct the order of the application information; the items Memory and Reductions have been switched.
2741

2842
- 1.7.4
29-
- fix crash when ets:info/1 return undefined.
43+
- fix crash when ets:info/1 returns undefined.
3044
- 1.7.3
3145
- fix system pane exception by `ps` command.
3246
- 1.7.2
3347
- Fix error when inspecting process that monitors via {RegName, Node}.
3448
- 1.7.1
35-
- application view show starting/loading/startPfalse/loaded/started application.
36-
- fixed badarg when staring by rpc and stop by `ctrl+c`.
37-
- fixed mix.exe version error
49+
- application view shows starting/loading/start_p_false/loaded/started application.
50+
- fixed badarg when starting by RPC and stopping with `ctrl+c`.
51+
- fixed mix.exs version error
3852
- 1.7.0
3953
- application view support reductions/memory/process_count sort
4054
- plugin support `{byte, 1024}` to `10.0000 KB`
41-
- plugin support `{percent, 0.1234` to `12.34%`
55+
- plugin support `{percent, 0.1234}` to `12.34%`
4256
- plugin support dig deep process view.
4357
- 1.6.2
44-
- fixed crash when ps command not found on windows.
58+
- fixed crash when ps command not found on Windows.
4559
- 1.6.1
46-
- remove precise opt version
60+
- remove precise OTP version
4761
- 1.6.0
48-
- hidden schedule usage default
49-
- format by erlformat
62+
- hidden scheduler usage default
63+
- format with erlfmt
5064
- add `ps -o pcpu,pmem,rss,vsz` information
5165
- remove recon_alloc:memory/1 from `HOME`(too much cpu usage)
5266
- 1.5.4
@@ -60,44 +74,44 @@
6074
- Bump Recon to 2.5.0
6175
- 1.4.5
6276
- Include a minimal mix.exs build file
63-
- Make sure EXIT message has been clear
77+
- Make sure EXIT message has been cleared
6478
- 1.4.4
6579
- Make sure connection errors can be handled
6680
- 1.4.3
6781
- Bump Recon to 2.4.0
6882
- 1.4.2
69-
- Hidden schedule process bar when core > 100.
83+
- Hidden scheduler process bar when core > 100.
7084
- Allow to compile escript w/ inet6 based distribution.
7185
- Rewrite plugin callback, rename kv_label/0 to attributes/1.
7286
- 1.4.1
7387
- Fixed ets view memory usage wrong.
74-
- mnesia view memory usage According to bytes.
88+
- mnesia view memory usage according to bytes.
7589
- 1.4.0
76-
- Support write your own plugin.
90+
- Support writing your own plugin.
7791
- 1.3.4
7892
- View(ets mnesia) support page down/up; support sort by memory or size.
7993
- Fixed pause crash.
8094
- Make refresh interval configurable.
8195
- 1.3.3
82-
- fixed io:format(Format,Args) Format not support iolist OTP R21
96+
- fixed io:format(Format, Args) does not support iolist in OTP R21
8397
- 1.3.2
84-
- Make sure all observer_cli process exit when quit.
98+
- Make sure all observer_cli processes exit when quit.
8599
- Upgrade recon to 2.3.6
86100
- 1.3.1
87101
- Add atom limit/count in home.
88102
- Escript support short name and long name.
89-
- Fixed store process not exit.
103+
- Fixed store process not exiting.
90104
- [Upgrade recon to 2.3.5](https://github.com/ferd/recon/commit/e0c3614334589e375f8b1492f404e4b764fe35e7)
91105
- 1.3.0
92106
- Rewrite Network/Process view.
93107
- Support PageDown/PageUp for top n list.
94-
- Escript auto load observer_cli when it's not load on target node.
108+
- Escript auto-loads observer_cli when it's not loaded on target node.
95109
- 1.2.2
96-
- fix schedule number >= 32 display wrong.
110+
- fix scheduler number >= 32 displayed incorrectly.
97111
- improve memory(byte/kilobyte/megabyte/gigabyte) unit.
98112
- 1.2.1
99-
- fixed autosize not work.
100-
- try best to make color adjust all platform.
113+
- fixed autosize not working.
114+
- try our best to make color adjust on all platforms.
101115
- 1.2.0
102116

103117
- add application GUI.

docs/formatter.md

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# How use your own formatter?
1+
# How to use your own formatter?
22

33
Observer CLI before rendering does formatting for:
44

5-
* Proccess State;
5+
* Process State;
66
* Process Messages;
77
* Process Dictionary.
88

@@ -26,9 +26,78 @@ Default formatter config:
2626
{formatter, #{application => observer_cli, mod => observer_cli_formatter_default}}
2727
```
2828

29+
Example: build an erlfmt formatter plugin (external)
30+
31+
Goal: keep observer_cli clean, but let users plug in erlfmt.
32+
33+
Step 1: create your own app
34+
35+
Create a new Erlang app, for example `my_formatter_app`.
36+
37+
Step 2: add erlfmt dependency in your app
38+
39+
In your app's `rebar.config`:
40+
41+
```erlang
42+
{deps, [
43+
observer_cli,
44+
erlfmt
45+
]}.
46+
```
47+
48+
`observer_cli` is only for the behaviour check at compile time.
49+
50+
Step 3: implement the behaviour
51+
52+
Create a module in your app, for example `my_formatter_erlfmt`:
53+
54+
```erlang
55+
-module(my_formatter_erlfmt).
56+
57+
-behaviour(observer_cli_formatter).
58+
59+
-export([format/2]).
60+
61+
format(Pid, Term) ->
62+
Header = io_lib:format("Process: ~p~n~n", [Pid]),
63+
TermString = unicode:characters_to_list(io_lib:format("~p.~n", [Term])),
64+
Formatted =
65+
case erlfmt:format_string(TermString, []) of
66+
{ok, Output, _Warnings} -> Output;
67+
{skip, Output} -> Output;
68+
{error, Error} -> erlang:error({erlfmt_format_failed, Error})
69+
end,
70+
[_ | _] = unicode:characters_to_list([Header, Formatted]).
71+
```
72+
73+
Step 4: make sure the formatter app is on the target node
74+
75+
The target node must have `my_formatter_app` available in its release,
76+
otherwise the formatter module cannot be loaded remotely.
77+
78+
Step 5: tell observer_cli to use your formatter
79+
80+
In the target node's `sys.config` (or runtime env):
81+
82+
```erlang
83+
{observer_cli, [
84+
{formatter, #{application => my_formatter_app, mod => my_formatter_erlfmt}}
85+
]}.
86+
```
87+
88+
If your formatter crashes, observer_cli will fall back to the default formatter.
89+
90+
Runtime env example:
91+
92+
```erlang
93+
application:set_env(observer_cli, formatter, #{
94+
application => my_formatter_app,
95+
mod => my_formatter_erlfmt
96+
}).
97+
```
98+
2999
**Option reference**
30100

31-
- `application` - Formatter application. Observer CLI loads all it's modules to
101+
- `application` - Formatter application. Observer CLI loads all its modules to
32102
remote node.
33103
- `mod` - Implementation of observer_cli_formatter behaviour.
34-

include/observer_cli.hrl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,5 @@
117117
-define('render'(_FA_), observer_cli_lib:render(_FA_)).
118118
-define('output'(_F_, _A_), io:format(iolist_to_binary(_F_), _A_)).
119119
-define('output'(_L_), ?output(_L_, [])).
120+
121+
-define(DEFAULT_FORMATTER, #{application => observer_cli, mod => observer_cli_formatter_default}).

mix.exs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule ObserverCli.MixProject do
44
def project do
55
[
66
app: :observer_cli,
7-
version: "1.8.5",
7+
version: "1.8.6",
88
language: :erlang,
99
description: "observer in shell",
1010
deps: [
@@ -19,8 +19,7 @@ defmodule ObserverCli.MixProject do
1919
# {:formatter, #{
2020
# :application => atom(), - Formatter application. observer_cli loads all it's modules to remote node.
2121
# :mod => module() - observer_cli_formatter implementation.
22-
# }}
23-
formatter: %{application: :observer_cli, mod: :observer_cli_formatter_default},
22+
# }},
2423
# scheduler_usage: :enable, # default value is 'disable', uncomment to enable by default
2524
plugins: [
2625
# module - Specific module implements plugin behavior. It's mandatory.

rebar.config

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
warn_untyped_record,
1717
debug_info
1818
]}.
19-
{deps_dir, "deps"}.
2019
{deps, [
2120
recon
2221
]}.
2322

2423
{project_plugins, [
2524
erlfmt,
25+
covertool,
2626
rebar3_lint,
2727
rebar3_ex_doc
2828
]}.
@@ -47,11 +47,21 @@
4747
]}.
4848
{xref_checks, [undefined_function_calls]}.
4949
{cover_enabled, true}.
50+
{cover_opts, [verbose]}.
51+
{cover_print_enabled, true}.
52+
{cover_export_enabled, true}.
53+
{covertool, [{coverdata_files, ["eunit.coverdata", "proper.coverdata", "ct.coverdata"]}]}.
5054

5155
{profiles, [
56+
{test, [
57+
{erl_opts, [nowarn_missing_spec]}
58+
]},
5259
{inet6, [
5360
{escript_emu_args,
5461
"%%! -escript main observer_cli_escriptize -hidden -proto_dist inet6_tcp +sbtu +A0 -elixir ansi_enabled true\n"}
62+
]},
63+
{ci, [
64+
{erl_opts, [warn_as_error]}
5565
]}
5666
]}.
5767

0 commit comments

Comments
 (0)