trace_viz 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +34 -0
- data/README.md +134 -39
- data/Steepfile +34 -0
- data/examples/eu_central_bank.rb +69 -0
- data/examples/example.cast +189 -0
- data/examples/example.rb +94 -23
- data/lib/trace_viz/adapters/base_adapter.rb +23 -2
- data/lib/trace_viz/adapters/trace_point_adapter.rb +10 -11
- data/lib/trace_viz/collectors/base_collector.rb +90 -0
- data/lib/trace_viz/collectors/filters/base_class_filter.rb +29 -0
- data/lib/trace_viz/collectors/filters/base_exclude_filter.rb +16 -0
- data/lib/trace_viz/collectors/filters/base_filter.rb +17 -0
- data/lib/trace_viz/collectors/filters/base_include_filter.rb +16 -0
- data/lib/trace_viz/collectors/filters/exclude_classes_filter.rb +15 -0
- data/lib/trace_viz/collectors/filters/exclude_default_classes_filter.rb +34 -0
- data/lib/trace_viz/collectors/filters/exclude_gems_filter.rb +30 -0
- data/lib/trace_viz/collectors/filters/exclude_internal_call_filter.rb +31 -0
- data/lib/trace_viz/collectors/filters/exclude_rails_framework_filter.rb +38 -0
- data/lib/trace_viz/collectors/filters/include_classes_filter.rb +15 -0
- data/lib/trace_viz/collectors/filters/include_gems_filter.rb +54 -0
- data/lib/trace_viz/collectors/filters/registry.rb +59 -0
- data/lib/trace_viz/collectors/hierarchy_linker.rb +30 -0
- data/lib/trace_viz/collectors/matchers/base_matcher.rb +13 -0
- data/lib/trace_viz/collectors/matchers/trace_point_action_matcher.rb +38 -0
- data/lib/trace_viz/collectors/matchers/within_depth_matcher.rb +26 -0
- data/lib/trace_viz/collectors/steps/assign_depth_for_call_step.rb +30 -0
- data/lib/trace_viz/collectors/steps/assign_depth_for_return_step.rb +39 -0
- data/lib/trace_viz/collectors/steps/base_step.rb +27 -0
- data/lib/trace_viz/collectors/steps/build_hierarchy_step.rb +32 -0
- data/lib/trace_viz/collectors/steps/hidden_step.rb +25 -0
- data/lib/trace_viz/collectors/steps/linking_step.rb +36 -0
- data/lib/trace_viz/collectors/steps/validation_step.rb +33 -0
- data/lib/trace_viz/collectors/steps.rb +10 -0
- data/lib/trace_viz/collectors/trace_pipeline.rb +26 -0
- data/lib/trace_viz/collectors/trace_pipeline_builder.rb +29 -0
- data/lib/trace_viz/collectors/trace_point_collector.rb +41 -0
- data/lib/trace_viz/collectors/trace_stats.rb +21 -0
- data/lib/trace_viz/config/copier.rb +38 -0
- data/lib/trace_viz/config/validator.rb +75 -0
- data/lib/trace_viz/configuration.rb +36 -30
- data/lib/trace_viz/context/config_context.rb +1 -1
- data/lib/trace_viz/context/manager.rb +17 -21
- data/lib/trace_viz/context/map.rb +29 -0
- data/lib/trace_viz/context/registry.rb +37 -0
- data/lib/trace_viz/context/tracking/active_calls.rb +37 -0
- data/lib/trace_viz/context/tracking_context.rb +11 -2
- data/lib/trace_viz/context.rb +2 -2
- data/lib/trace_viz/core/tracer.rb +3 -0
- data/lib/trace_viz/defaults/actions.rb +84 -0
- data/lib/trace_viz/defaults/colors.rb +61 -0
- data/lib/trace_viz/defaults/config.rb +89 -0
- data/lib/trace_viz/defaults/themes.rb +66 -0
- data/lib/trace_viz/defaults.rb +20 -0
- data/lib/trace_viz/exporters/base_exporter.rb +81 -0
- data/lib/trace_viz/exporters/export_manager.rb +33 -0
- data/lib/trace_viz/exporters/registry.rb +25 -0
- data/lib/trace_viz/exporters/text_exporter.rb +37 -0
- data/lib/trace_viz/formatters/base_formatter.rb +15 -0
- data/lib/trace_viz/formatters/export/base_formatter.rb +12 -0
- data/lib/trace_viz/formatters/export/formatter_factory.rb +27 -0
- data/lib/trace_viz/formatters/export/method_call_formatter.rb +21 -0
- data/lib/trace_viz/formatters/export/method_return_formatter.rb +22 -0
- data/lib/trace_viz/formatters/export/summary_group_formatter.rb +35 -0
- data/lib/trace_viz/formatters/helpers/depth_helper.rb +15 -0
- data/lib/trace_viz/formatters/helpers/indent_helper.rb +15 -0
- data/lib/trace_viz/formatters/helpers/log/color_helper.rb +23 -0
- data/lib/trace_viz/formatters/helpers/log/depth_helper.rb +22 -0
- data/lib/trace_viz/formatters/helpers/log/method_name_helper.rb +29 -0
- data/lib/trace_viz/formatters/helpers/log/params_helper.rb +51 -0
- data/lib/trace_viz/formatters/helpers/log/result_helper.rb +27 -0
- data/lib/trace_viz/formatters/helpers/log/summary/params_helper.rb +53 -0
- data/lib/trace_viz/formatters/helpers/method_details_helper.rb +15 -0
- data/lib/trace_viz/formatters/helpers/params_helper.rb +43 -0
- data/lib/trace_viz/formatters/helpers/result_helper.rb +21 -0
- data/lib/trace_viz/formatters/helpers/source_helper.rb +22 -0
- data/lib/trace_viz/formatters/helpers/summary/params_helper.rb +41 -0
- data/lib/trace_viz/formatters/helpers/summary/source_helper.rb +24 -0
- data/lib/trace_viz/formatters/helpers/time_helper.rb +15 -0
- data/lib/trace_viz/formatters/helpers.rb +10 -0
- data/lib/trace_viz/formatters/log/base_formatter.rb +13 -0
- data/lib/trace_viz/formatters/log/formatter_factory.rb +27 -0
- data/lib/trace_viz/formatters/log/method_call_formatter.rb +34 -0
- data/lib/trace_viz/formatters/log/method_return_formatter.rb +24 -0
- data/lib/trace_viz/formatters/log/summary_group_formatter.rb +40 -0
- data/lib/trace_viz/formatters/log/verbose_formatter.rb +14 -0
- data/lib/trace_viz/formatters/trace_data_formatter.rb +24 -0
- data/lib/trace_viz/helpers/config_helper.rb +13 -0
- data/lib/trace_viz/helpers/trace_point/param_helper.rb +98 -0
- data/lib/trace_viz/helpers/tracking_helper.rb +26 -0
- data/lib/trace_viz/helpers.rb +9 -0
- data/lib/trace_viz/logger.rb +28 -49
- data/lib/trace_viz/loggers/base_logger.rb +29 -0
- data/lib/trace_viz/loggers/log_level_resolver.rb +18 -0
- data/lib/trace_viz/loggers/logging_manager.rb +46 -0
- data/lib/trace_viz/loggers/post_collection_logger.rb +39 -0
- data/lib/trace_viz/loggers/trace_logger.rb +37 -0
- data/lib/trace_viz/loggers/trace_stats_logger.rb +47 -0
- data/lib/trace_viz/renderers/base_renderer.rb +24 -0
- data/lib/trace_viz/renderers/render_context.rb +18 -0
- data/lib/trace_viz/renderers/renderer_factory.rb +41 -0
- data/lib/trace_viz/renderers/summary/node_processor.rb +82 -0
- data/lib/trace_viz/renderers/summary_renderer.rb +22 -0
- data/lib/trace_viz/renderers/verbose_renderer.rb +29 -0
- data/lib/trace_viz/shared/renderer_helper.rb +46 -0
- data/lib/trace_viz/shared.rb +8 -0
- data/lib/trace_viz/trace_data/base.rb +49 -0
- data/lib/trace_viz/trace_data/node.rb +33 -0
- data/lib/trace_viz/trace_data/root_node.rb +20 -0
- data/lib/trace_viz/trace_data/summary_node.rb +49 -0
- data/lib/trace_viz/trace_data/trace_point/base.rb +59 -0
- data/lib/trace_viz/trace_data/trace_point/method_call.rb +47 -0
- data/lib/trace_viz/trace_data/trace_point/method_return.rb +45 -0
- data/lib/trace_viz/trace_data/trace_point_builder.rb +23 -0
- data/lib/trace_viz/traits/depth_trackable.rb +13 -0
- data/lib/trace_viz/traits/identifiable.rb +25 -0
- data/lib/trace_viz/traits/time_trackable.rb +13 -0
- data/lib/trace_viz/traits.rb +10 -0
- data/lib/trace_viz/utils/colorize.rb +12 -23
- data/lib/trace_viz/utils/format_utils/key_value_formatter.rb +37 -0
- data/lib/trace_viz/utils/format_utils/value_truncator.rb +74 -0
- data/lib/trace_viz/utils/format_utils.rb +24 -0
- data/lib/trace_viz/utils/id_generator.rb +35 -0
- data/lib/trace_viz/version.rb +1 -1
- data/sig/adapters/base_adapter.rbs +11 -0
- data/sig/adapters/trace_point_adapter.rbs +13 -0
- data/sig/collectors/filters/registry.rbs +13 -0
- data/sig/collectors/trace_point_collector.rbs +17 -0
- data/sig/config/copier.rbs +15 -0
- data/sig/config/validator.rbs +18 -0
- data/sig/configuration.rbs +22 -0
- data/sig/context/base_context.rbs +9 -0
- data/sig/context/config_context.rbs +13 -0
- data/sig/context/manager.rbs +10 -0
- data/sig/context/map.rbs +13 -0
- data/sig/context.rbs +5 -0
- data/sig/core/tracer.rbs +7 -0
- data/sig/core.rbs +4 -0
- data/sig/defaults.rbs +17 -0
- data/sig/errors.rbs +13 -0
- data/sig/logger.rbs +33 -0
- data/sig/trace_viz.rbs +1 -2
- data/sig/utils/colorize.rbs +8 -0
- data/sig/utils/format_utils/key_value_formatter.rbs +16 -0
- data/sig/utils/format_utils/value_truncator.rbs +19 -0
- data/sig/utils/format_utils.rbs +8 -0
- data/sig/version.rbs +3 -0
- metadata +140 -16
- data/lib/trace_viz/adapters/trace_point/depth_manager.rb +0 -34
- data/lib/trace_viz/adapters/trace_point/event_handler.rb +0 -36
- data/lib/trace_viz/adapters/trace_point/trace_data.rb +0 -89
- data/lib/trace_viz/adapters/trace_point/trace_formatter.rb +0 -95
- data/lib/trace_viz/adapters/trace_point/trace_logger.rb +0 -44
- data/lib/trace_viz/context/manager/context_map.rb +0 -31
- data/lib/trace_viz/context/manager/context_operations.rb +0 -60
- data/lib/trace_viz/context/manager/context_registry.rb +0 -20
- data/lib/trace_viz/context/manager/context_validation.rb +0 -34
@@ -0,0 +1,10 @@
|
|
1
|
+
module TraceViz
|
2
|
+
module Context
|
3
|
+
class Manager
|
4
|
+
def self.enter_contexts: (Hash[Symbol, untyped] contexts) -> void
|
5
|
+
def self.exit_contexts: (*Symbol keys) -> void
|
6
|
+
def self.with_contexts: (?Hash[Symbol, untyped] contexts) { () -> void } -> void
|
7
|
+
def self.fetch_context: (Symbol key) -> untyped
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/sig/context/map.rbs
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module TraceViz
|
2
|
+
module Context
|
3
|
+
class Map
|
4
|
+
@context_map: Hash[Symbol, untyped]
|
5
|
+
|
6
|
+
def initialize: () -> void
|
7
|
+
def replace: (Hash[Symbol, untyped] new_map) -> void
|
8
|
+
def fetch: (Symbol key) -> untyped
|
9
|
+
def remove: (*Symbol keys) -> void
|
10
|
+
def reset: () -> void
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/sig/context.rbs
ADDED
data/sig/core/tracer.rbs
ADDED
data/sig/core.rbs
ADDED
data/sig/defaults.rbs
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module TraceViz
|
2
|
+
class Defaults
|
3
|
+
COLORS: Hash[Symbol, String]
|
4
|
+
ACTION_EMOJIS: Hash[Symbol, String]
|
5
|
+
ACTION_COLORS: Hash[Symbol, Symbol]
|
6
|
+
CONFIG: Hash[Symbol, untyped]
|
7
|
+
VALID_PARAM_MODES: Array[Symbol]
|
8
|
+
VALID_EXPORT_FORMATS: Array[Symbol]
|
9
|
+
|
10
|
+
def self.colors: () -> Hash[Symbol, String]
|
11
|
+
def self.action_colors: () -> Hash[Symbol, Symbol]
|
12
|
+
def self.action_emojis: () -> Hash[Symbol, String]
|
13
|
+
def self.fetch_defaults: () -> Hash[Symbol, untyped]
|
14
|
+
def self.valid_param_modes: () -> Array[Symbol]
|
15
|
+
def self.valid_export_formats: () -> Array[Symbol]
|
16
|
+
end
|
17
|
+
end
|
data/sig/errors.rbs
ADDED
data/sig/logger.rbs
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module TraceViz
|
2
|
+
class Logger
|
3
|
+
# Constants
|
4
|
+
LEVELS: Array[Symbol]
|
5
|
+
|
6
|
+
# Constructor
|
7
|
+
def initialize: (output: IO) -> void
|
8
|
+
|
9
|
+
# Dynamic methods for each log level
|
10
|
+
def info: (String?) -> void
|
11
|
+
def success: (String?) -> void
|
12
|
+
def error: (String?) -> void
|
13
|
+
def warn: (String?) -> void
|
14
|
+
def start: (String?) -> void
|
15
|
+
def processing: (String?) -> void
|
16
|
+
def finish: (String?) -> void
|
17
|
+
def exported: (String?) -> void
|
18
|
+
def skipped: (String?) -> void
|
19
|
+
def stats: (String?) -> void
|
20
|
+
def default: (String?) -> void
|
21
|
+
|
22
|
+
# Public methods
|
23
|
+
def log: (String?, Symbol) -> void
|
24
|
+
|
25
|
+
# Private methods
|
26
|
+
private def validate_message!: (String?) -> void
|
27
|
+
private def validate_level!: (Symbol) -> void
|
28
|
+
private def colors_for: (Symbol) -> Array[Symbol]
|
29
|
+
private def emoji_for: (Symbol) -> String
|
30
|
+
private def build_message: (String?, Symbol, String) -> String
|
31
|
+
private def apply_colors: (String, Array[Symbol]) -> String
|
32
|
+
end
|
33
|
+
end
|
data/sig/trace_viz.rbs
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module TraceViz
|
2
|
+
module Utils
|
3
|
+
module FormatUtils
|
4
|
+
class KeyValueFormatter
|
5
|
+
DEFAULT_MODE: Symbol
|
6
|
+
|
7
|
+
def initialize: (mode: Symbol) -> void
|
8
|
+
|
9
|
+
def format: (Hash[untyped, untyped]) -> String
|
10
|
+
|
11
|
+
private def validate_input: (untyped) -> void
|
12
|
+
private def build_formatter: () -> Hash[Symbol, ^(untyped, untyped) -> String]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module TraceViz
|
2
|
+
module Utils
|
3
|
+
module FormatUtils
|
4
|
+
class ValueTruncator
|
5
|
+
DEFAULT_LENGTH: Integer
|
6
|
+
|
7
|
+
def initialize: (length: Integer) -> void
|
8
|
+
|
9
|
+
def truncate: (String | Array[untyped] | Hash[untyped, untyped] | Object) -> (String | Array[untyped] | Hash[untyped, untyped] | Object)
|
10
|
+
|
11
|
+
private def valid_length?: () -> bool
|
12
|
+
private def truncate_string: (String) -> String
|
13
|
+
private def truncate_array: (Array[untyped]) -> Array[untyped]
|
14
|
+
private def truncate_hash: (Hash[untyped, untyped]) -> String
|
15
|
+
private def truncate_generic: (Object) -> String
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/sig/version.rbs
ADDED
metadata
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trace_viz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Huy Nguyen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
|
13
|
+
description: "TraceViz is a Ruby library designed to trace and visualize events executed
|
14
|
+
\nin a block of code. Useful for debugging and logging. \nDiagram generation is
|
15
|
+
currently under development.\n"
|
15
16
|
email:
|
16
17
|
- patrick204nqh@gmail.com
|
17
18
|
executables: []
|
@@ -24,36 +25,159 @@ files:
|
|
24
25
|
- ".vscode/launch.json"
|
25
26
|
- ".vscode/settings.json"
|
26
27
|
- CODE_OF_CONDUCT.md
|
28
|
+
- CONTRIBUTING.md
|
27
29
|
- LICENSE.txt
|
28
30
|
- README.md
|
29
31
|
- Rakefile
|
32
|
+
- Steepfile
|
33
|
+
- examples/eu_central_bank.rb
|
34
|
+
- examples/example.cast
|
30
35
|
- examples/example.rb
|
31
36
|
- lib/trace_viz.rb
|
32
37
|
- lib/trace_viz/adapters/base_adapter.rb
|
33
|
-
- lib/trace_viz/adapters/trace_point/depth_manager.rb
|
34
|
-
- lib/trace_viz/adapters/trace_point/event_handler.rb
|
35
|
-
- lib/trace_viz/adapters/trace_point/trace_data.rb
|
36
|
-
- lib/trace_viz/adapters/trace_point/trace_formatter.rb
|
37
|
-
- lib/trace_viz/adapters/trace_point/trace_logger.rb
|
38
38
|
- lib/trace_viz/adapters/trace_point_adapter.rb
|
39
|
+
- lib/trace_viz/collectors/base_collector.rb
|
40
|
+
- lib/trace_viz/collectors/filters/base_class_filter.rb
|
41
|
+
- lib/trace_viz/collectors/filters/base_exclude_filter.rb
|
42
|
+
- lib/trace_viz/collectors/filters/base_filter.rb
|
43
|
+
- lib/trace_viz/collectors/filters/base_include_filter.rb
|
44
|
+
- lib/trace_viz/collectors/filters/exclude_classes_filter.rb
|
45
|
+
- lib/trace_viz/collectors/filters/exclude_default_classes_filter.rb
|
46
|
+
- lib/trace_viz/collectors/filters/exclude_gems_filter.rb
|
47
|
+
- lib/trace_viz/collectors/filters/exclude_internal_call_filter.rb
|
48
|
+
- lib/trace_viz/collectors/filters/exclude_rails_framework_filter.rb
|
49
|
+
- lib/trace_viz/collectors/filters/include_classes_filter.rb
|
50
|
+
- lib/trace_viz/collectors/filters/include_gems_filter.rb
|
51
|
+
- lib/trace_viz/collectors/filters/registry.rb
|
52
|
+
- lib/trace_viz/collectors/hierarchy_linker.rb
|
53
|
+
- lib/trace_viz/collectors/matchers/base_matcher.rb
|
54
|
+
- lib/trace_viz/collectors/matchers/trace_point_action_matcher.rb
|
55
|
+
- lib/trace_viz/collectors/matchers/within_depth_matcher.rb
|
56
|
+
- lib/trace_viz/collectors/steps.rb
|
57
|
+
- lib/trace_viz/collectors/steps/assign_depth_for_call_step.rb
|
58
|
+
- lib/trace_viz/collectors/steps/assign_depth_for_return_step.rb
|
59
|
+
- lib/trace_viz/collectors/steps/base_step.rb
|
60
|
+
- lib/trace_viz/collectors/steps/build_hierarchy_step.rb
|
61
|
+
- lib/trace_viz/collectors/steps/hidden_step.rb
|
62
|
+
- lib/trace_viz/collectors/steps/linking_step.rb
|
63
|
+
- lib/trace_viz/collectors/steps/validation_step.rb
|
64
|
+
- lib/trace_viz/collectors/trace_pipeline.rb
|
65
|
+
- lib/trace_viz/collectors/trace_pipeline_builder.rb
|
66
|
+
- lib/trace_viz/collectors/trace_point_collector.rb
|
67
|
+
- lib/trace_viz/collectors/trace_stats.rb
|
68
|
+
- lib/trace_viz/config/copier.rb
|
69
|
+
- lib/trace_viz/config/validator.rb
|
39
70
|
- lib/trace_viz/configuration.rb
|
40
71
|
- lib/trace_viz/context.rb
|
41
72
|
- lib/trace_viz/context/base_context.rb
|
42
73
|
- lib/trace_viz/context/config_context.rb
|
43
74
|
- lib/trace_viz/context/manager.rb
|
44
|
-
- lib/trace_viz/context/
|
45
|
-
- lib/trace_viz/context/
|
46
|
-
- lib/trace_viz/context/
|
47
|
-
- lib/trace_viz/context/manager/context_validation.rb
|
75
|
+
- lib/trace_viz/context/map.rb
|
76
|
+
- lib/trace_viz/context/registry.rb
|
77
|
+
- lib/trace_viz/context/tracking/active_calls.rb
|
48
78
|
- lib/trace_viz/context/tracking/depth.rb
|
49
79
|
- lib/trace_viz/context/tracking_context.rb
|
50
80
|
- lib/trace_viz/core.rb
|
51
81
|
- lib/trace_viz/core/tracer.rb
|
82
|
+
- lib/trace_viz/defaults.rb
|
83
|
+
- lib/trace_viz/defaults/actions.rb
|
84
|
+
- lib/trace_viz/defaults/colors.rb
|
85
|
+
- lib/trace_viz/defaults/config.rb
|
86
|
+
- lib/trace_viz/defaults/themes.rb
|
52
87
|
- lib/trace_viz/errors.rb
|
88
|
+
- lib/trace_viz/exporters/base_exporter.rb
|
89
|
+
- lib/trace_viz/exporters/export_manager.rb
|
90
|
+
- lib/trace_viz/exporters/registry.rb
|
91
|
+
- lib/trace_viz/exporters/text_exporter.rb
|
92
|
+
- lib/trace_viz/formatters/base_formatter.rb
|
93
|
+
- lib/trace_viz/formatters/export/base_formatter.rb
|
94
|
+
- lib/trace_viz/formatters/export/formatter_factory.rb
|
95
|
+
- lib/trace_viz/formatters/export/method_call_formatter.rb
|
96
|
+
- lib/trace_viz/formatters/export/method_return_formatter.rb
|
97
|
+
- lib/trace_viz/formatters/export/summary_group_formatter.rb
|
98
|
+
- lib/trace_viz/formatters/helpers.rb
|
99
|
+
- lib/trace_viz/formatters/helpers/depth_helper.rb
|
100
|
+
- lib/trace_viz/formatters/helpers/indent_helper.rb
|
101
|
+
- lib/trace_viz/formatters/helpers/log/color_helper.rb
|
102
|
+
- lib/trace_viz/formatters/helpers/log/depth_helper.rb
|
103
|
+
- lib/trace_viz/formatters/helpers/log/method_name_helper.rb
|
104
|
+
- lib/trace_viz/formatters/helpers/log/params_helper.rb
|
105
|
+
- lib/trace_viz/formatters/helpers/log/result_helper.rb
|
106
|
+
- lib/trace_viz/formatters/helpers/log/summary/params_helper.rb
|
107
|
+
- lib/trace_viz/formatters/helpers/method_details_helper.rb
|
108
|
+
- lib/trace_viz/formatters/helpers/params_helper.rb
|
109
|
+
- lib/trace_viz/formatters/helpers/result_helper.rb
|
110
|
+
- lib/trace_viz/formatters/helpers/source_helper.rb
|
111
|
+
- lib/trace_viz/formatters/helpers/summary/params_helper.rb
|
112
|
+
- lib/trace_viz/formatters/helpers/summary/source_helper.rb
|
113
|
+
- lib/trace_viz/formatters/helpers/time_helper.rb
|
114
|
+
- lib/trace_viz/formatters/log/base_formatter.rb
|
115
|
+
- lib/trace_viz/formatters/log/formatter_factory.rb
|
116
|
+
- lib/trace_viz/formatters/log/method_call_formatter.rb
|
117
|
+
- lib/trace_viz/formatters/log/method_return_formatter.rb
|
118
|
+
- lib/trace_viz/formatters/log/summary_group_formatter.rb
|
119
|
+
- lib/trace_viz/formatters/log/verbose_formatter.rb
|
120
|
+
- lib/trace_viz/formatters/trace_data_formatter.rb
|
121
|
+
- lib/trace_viz/helpers.rb
|
122
|
+
- lib/trace_viz/helpers/config_helper.rb
|
123
|
+
- lib/trace_viz/helpers/trace_point/param_helper.rb
|
124
|
+
- lib/trace_viz/helpers/tracking_helper.rb
|
53
125
|
- lib/trace_viz/logger.rb
|
126
|
+
- lib/trace_viz/loggers/base_logger.rb
|
127
|
+
- lib/trace_viz/loggers/log_level_resolver.rb
|
128
|
+
- lib/trace_viz/loggers/logging_manager.rb
|
129
|
+
- lib/trace_viz/loggers/post_collection_logger.rb
|
130
|
+
- lib/trace_viz/loggers/trace_logger.rb
|
131
|
+
- lib/trace_viz/loggers/trace_stats_logger.rb
|
132
|
+
- lib/trace_viz/renderers/base_renderer.rb
|
133
|
+
- lib/trace_viz/renderers/render_context.rb
|
134
|
+
- lib/trace_viz/renderers/renderer_factory.rb
|
135
|
+
- lib/trace_viz/renderers/summary/node_processor.rb
|
136
|
+
- lib/trace_viz/renderers/summary_renderer.rb
|
137
|
+
- lib/trace_viz/renderers/verbose_renderer.rb
|
138
|
+
- lib/trace_viz/shared.rb
|
139
|
+
- lib/trace_viz/shared/renderer_helper.rb
|
140
|
+
- lib/trace_viz/trace_data/base.rb
|
141
|
+
- lib/trace_viz/trace_data/node.rb
|
142
|
+
- lib/trace_viz/trace_data/root_node.rb
|
143
|
+
- lib/trace_viz/trace_data/summary_node.rb
|
144
|
+
- lib/trace_viz/trace_data/trace_point/base.rb
|
145
|
+
- lib/trace_viz/trace_data/trace_point/method_call.rb
|
146
|
+
- lib/trace_viz/trace_data/trace_point/method_return.rb
|
147
|
+
- lib/trace_viz/trace_data/trace_point_builder.rb
|
148
|
+
- lib/trace_viz/traits.rb
|
149
|
+
- lib/trace_viz/traits/depth_trackable.rb
|
150
|
+
- lib/trace_viz/traits/identifiable.rb
|
151
|
+
- lib/trace_viz/traits/time_trackable.rb
|
54
152
|
- lib/trace_viz/utils/colorize.rb
|
153
|
+
- lib/trace_viz/utils/format_utils.rb
|
154
|
+
- lib/trace_viz/utils/format_utils/key_value_formatter.rb
|
155
|
+
- lib/trace_viz/utils/format_utils/value_truncator.rb
|
156
|
+
- lib/trace_viz/utils/id_generator.rb
|
55
157
|
- lib/trace_viz/version.rb
|
158
|
+
- sig/adapters/base_adapter.rbs
|
159
|
+
- sig/adapters/trace_point_adapter.rbs
|
160
|
+
- sig/collectors/filters/registry.rbs
|
161
|
+
- sig/collectors/trace_point_collector.rbs
|
162
|
+
- sig/config/copier.rbs
|
163
|
+
- sig/config/validator.rbs
|
164
|
+
- sig/configuration.rbs
|
165
|
+
- sig/context.rbs
|
166
|
+
- sig/context/base_context.rbs
|
167
|
+
- sig/context/config_context.rbs
|
168
|
+
- sig/context/manager.rbs
|
169
|
+
- sig/context/map.rbs
|
170
|
+
- sig/core.rbs
|
171
|
+
- sig/core/tracer.rbs
|
172
|
+
- sig/defaults.rbs
|
173
|
+
- sig/errors.rbs
|
174
|
+
- sig/logger.rbs
|
56
175
|
- sig/trace_viz.rbs
|
176
|
+
- sig/utils/colorize.rbs
|
177
|
+
- sig/utils/format_utils.rbs
|
178
|
+
- sig/utils/format_utils/key_value_formatter.rbs
|
179
|
+
- sig/utils/format_utils/value_truncator.rbs
|
180
|
+
- sig/version.rbs
|
57
181
|
homepage: https://github.com/patrick204nqh/trace_viz
|
58
182
|
licenses:
|
59
183
|
- MIT
|
@@ -61,7 +185,7 @@ metadata:
|
|
61
185
|
homepage_uri: https://github.com/patrick204nqh/trace_viz
|
62
186
|
source_code_uri: https://github.com/patrick204nqh/trace_viz
|
63
187
|
changelog_uri: https://github.com/patrick204nqh/trace_viz/blob/main/CHANGELOG.md
|
64
|
-
post_install_message:
|
188
|
+
post_install_message:
|
65
189
|
rdoc_options: []
|
66
190
|
require_paths:
|
67
191
|
- lib
|
@@ -77,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
201
|
version: '0'
|
78
202
|
requirements: []
|
79
203
|
rubygems_version: 3.5.3
|
80
|
-
signing_key:
|
204
|
+
signing_key:
|
81
205
|
specification_version: 4
|
82
206
|
summary: Trace method and attribute usage in Ruby classes and generate diagrams.
|
83
207
|
test_files: []
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module TraceViz
|
4
|
-
module Adapters
|
5
|
-
module TracePoint
|
6
|
-
class DepthManager
|
7
|
-
def initialize(trace_data)
|
8
|
-
@trace_data = trace_data
|
9
|
-
@context = Context.for(:tracking)
|
10
|
-
end
|
11
|
-
|
12
|
-
def assign_depth
|
13
|
-
context_depth = context&.depth
|
14
|
-
return 0 unless context_depth
|
15
|
-
|
16
|
-
case trace_data.event
|
17
|
-
when :call
|
18
|
-
current_depth = context_depth.current || 0
|
19
|
-
context_depth.increment
|
20
|
-
current_depth
|
21
|
-
when :return
|
22
|
-
context_depth.decrement
|
23
|
-
else
|
24
|
-
0 # Disables depth tracking for other events
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
attr_reader :trace_data, :context
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module TraceViz
|
4
|
-
module Adapters
|
5
|
-
module TracePoint
|
6
|
-
class EventHandler
|
7
|
-
def initialize(trace_data)
|
8
|
-
@trace_data = trace_data
|
9
|
-
end
|
10
|
-
|
11
|
-
def handle
|
12
|
-
case trace_data.event
|
13
|
-
when :call
|
14
|
-
handle_call
|
15
|
-
when :return
|
16
|
-
handle_return
|
17
|
-
else
|
18
|
-
raise AdapterError, "Unknown event type #{trace_data.event}"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
attr_reader :trace_data
|
25
|
-
|
26
|
-
def handle_call
|
27
|
-
trace_data.log_trace
|
28
|
-
end
|
29
|
-
|
30
|
-
def handle_return
|
31
|
-
trace_data.log_trace
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "trace_viz/adapters/trace_point/depth_manager"
|
4
|
-
|
5
|
-
module TraceViz
|
6
|
-
module Adapters
|
7
|
-
module TracePoint
|
8
|
-
class TraceData
|
9
|
-
attr_reader :trace_point, :config, :timestamp, :depth
|
10
|
-
|
11
|
-
def initialize(trace_point)
|
12
|
-
@trace_point = trace_point
|
13
|
-
@config = Context.for(:config).configuration
|
14
|
-
@logger = TraceLogger.new(self)
|
15
|
-
@depth_manager = DepthManager.new(self)
|
16
|
-
|
17
|
-
record_timestamp
|
18
|
-
assign_depth
|
19
|
-
end
|
20
|
-
|
21
|
-
def id
|
22
|
-
trace_point.method_id
|
23
|
-
end
|
24
|
-
|
25
|
-
def event
|
26
|
-
trace_point.event
|
27
|
-
end
|
28
|
-
|
29
|
-
def path
|
30
|
-
trace_point.path
|
31
|
-
end
|
32
|
-
|
33
|
-
def line_number
|
34
|
-
trace_point.lineno
|
35
|
-
end
|
36
|
-
|
37
|
-
def klass
|
38
|
-
trace_point.defined_class
|
39
|
-
end
|
40
|
-
|
41
|
-
def params
|
42
|
-
trace_point.binding.local_variables
|
43
|
-
end
|
44
|
-
|
45
|
-
def result
|
46
|
-
trace_point.return_value
|
47
|
-
end
|
48
|
-
|
49
|
-
def internal_call?
|
50
|
-
internal_path? || internal_class?
|
51
|
-
end
|
52
|
-
|
53
|
-
def exceeded_max_depth?
|
54
|
-
return false unless config.max_display_depth
|
55
|
-
|
56
|
-
depth > config.max_display_depth
|
57
|
-
end
|
58
|
-
|
59
|
-
def duration
|
60
|
-
# TODO: Implement duration calculation
|
61
|
-
end
|
62
|
-
|
63
|
-
def log_trace
|
64
|
-
logger.log_trace
|
65
|
-
end
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
attr_reader :logger, :depth_manager
|
70
|
-
|
71
|
-
def internal_path?
|
72
|
-
path.include?("<internal:")
|
73
|
-
end
|
74
|
-
|
75
|
-
def internal_class?
|
76
|
-
klass.to_s.start_with?("TracePoint")
|
77
|
-
end
|
78
|
-
|
79
|
-
def record_timestamp
|
80
|
-
@timestamp = Time.now
|
81
|
-
end
|
82
|
-
|
83
|
-
def assign_depth
|
84
|
-
@depth = @depth_manager.assign_depth
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "trace_viz/utils/colorize"
|
4
|
-
|
5
|
-
module TraceViz
|
6
|
-
module Adapters
|
7
|
-
module TracePoint
|
8
|
-
class TraceFormatter
|
9
|
-
def initialize(trace_data)
|
10
|
-
@trace_data = trace_data
|
11
|
-
@config = @trace_data.config
|
12
|
-
@logger = TraceViz.logger
|
13
|
-
end
|
14
|
-
|
15
|
-
def format_call
|
16
|
-
return "" if trace_data.exceeded_max_depth?
|
17
|
-
|
18
|
-
[
|
19
|
-
indent_if_enabled,
|
20
|
-
colorize(depth_if_enabled, :blue),
|
21
|
-
colorize(method_name_if_enabled, :light_green),
|
22
|
-
colorize(source_location_if_enabled, :dark_gray),
|
23
|
-
colorize(params_if_enabled, :yellow),
|
24
|
-
].compact.join(" ")
|
25
|
-
end
|
26
|
-
|
27
|
-
def format_return
|
28
|
-
return "" if trace_data.exceeded_max_depth?
|
29
|
-
|
30
|
-
[
|
31
|
-
indent_if_enabled,
|
32
|
-
colorize(depth_if_enabled, :blue),
|
33
|
-
colorize(method_name_if_enabled, :light_green),
|
34
|
-
colorize(result_if_enabled, :cyan),
|
35
|
-
colorize(source_location_if_enabled, :dark_gray),
|
36
|
-
colorize(execution_time_if_enabled, :red),
|
37
|
-
].compact.join(" ")
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
attr_reader :trace_data, :config, :logger
|
43
|
-
|
44
|
-
def indent_if_enabled
|
45
|
-
return unless config.show_indent && config.show_depth
|
46
|
-
|
47
|
-
" " * (config.tab_size * trace_data.depth)
|
48
|
-
end
|
49
|
-
|
50
|
-
def depth_if_enabled
|
51
|
-
return unless config.show_depth
|
52
|
-
|
53
|
-
"#depth:#{trace_data.depth}"
|
54
|
-
end
|
55
|
-
|
56
|
-
def method_name_if_enabled
|
57
|
-
return unless config.show_method_name
|
58
|
-
|
59
|
-
"#{trace_data.klass}##{trace_data.id}"
|
60
|
-
end
|
61
|
-
|
62
|
-
def source_location_if_enabled
|
63
|
-
return unless config.show_source_location
|
64
|
-
|
65
|
-
"at #{trace_data.path}:#{trace_data.line_number}"
|
66
|
-
end
|
67
|
-
|
68
|
-
def params_if_enabled
|
69
|
-
return unless config.show_params
|
70
|
-
|
71
|
-
param_values = trace_data.params.map do |var|
|
72
|
-
trace_data.trace_point.binding.local_variable_get(var).inspect
|
73
|
-
end.join(", ")
|
74
|
-
"(#{param_values})"
|
75
|
-
end
|
76
|
-
|
77
|
-
def result_if_enabled
|
78
|
-
return unless config.show_return_value
|
79
|
-
|
80
|
-
"#=> #{trace_data.result.inspect}"
|
81
|
-
end
|
82
|
-
|
83
|
-
def execution_time_if_enabled
|
84
|
-
return unless config.show_execution_time && trace_data.duration
|
85
|
-
|
86
|
-
"in #{trace_data.duration}ms"
|
87
|
-
end
|
88
|
-
|
89
|
-
def colorize(text, color_key)
|
90
|
-
Utils::Colorize.colorize(text, color_key)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|