trace_viz 0.0.2 → 1.0.1
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/README.md +68 -43
- data/Steepfile +34 -0
- data/examples/eu_central_bank.rb +69 -0
- data/examples/example.cast +189 -285
- data/lib/trace_viz/adapters/base_adapter.rb +24 -1
- data/lib/trace_viz/adapters/trace_point_adapter.rb +3 -10
- data/lib/trace_viz/builders/base_builder.rb +11 -0
- data/lib/trace_viz/builders/diagram/base_builder.rb +10 -0
- data/lib/trace_viz/builders/diagram/message_builder.rb +96 -0
- data/lib/trace_viz/builders/diagram/sequence_builder.rb +50 -0
- data/lib/trace_viz/collectors/base_collector.rb +42 -35
- data/lib/trace_viz/collectors/filters/base_class_filter.rb +31 -0
- data/lib/trace_viz/collectors/filters/base_exclude_filter.rb +16 -0
- data/lib/trace_viz/collectors/filters/base_filter.rb +2 -8
- data/lib/trace_viz/collectors/filters/base_include_filter.rb +16 -0
- data/lib/trace_viz/collectors/filters/exclude_classes_filter.rb +4 -17
- data/lib/trace_viz/collectors/filters/exclude_default_classes_filter.rb +22 -26
- data/lib/trace_viz/collectors/filters/include_classes_filter.rb +4 -17
- 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 +12 -10
- data/lib/trace_viz/collectors/matchers/within_depth_matcher.rb +6 -5
- 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/{evaluators/hidden_evaluator.rb → steps/hidden_step.rb} +9 -5
- data/lib/trace_viz/collectors/steps/linking_step.rb +36 -0
- data/lib/trace_viz/collectors/{evaluators/filter_evaluator.rb → steps/validation_step.rb} +9 -6
- 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 +1 -11
- data/lib/trace_viz/config/validator.rb +6 -5
- data/lib/trace_viz/configuration.rb +3 -3
- data/lib/trace_viz/context/tracking_context.rb +4 -0
- data/lib/trace_viz/core/tracer.rb +2 -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 +91 -0
- data/lib/trace_viz/defaults/themes.rb +66 -0
- data/lib/trace_viz/defaults.rb +10 -129
- data/lib/trace_viz/exporters/base_exporter.rb +31 -13
- data/lib/trace_viz/exporters/export_manager.rb +33 -0
- data/lib/trace_viz/exporters/mermaid_exporter.rb +17 -0
- data/lib/trace_viz/exporters/registry.rb +27 -0
- data/lib/trace_viz/exporters/text_exporter.rb +2 -2
- data/lib/trace_viz/extractors/base_extractor.rb +17 -0
- data/lib/trace_viz/extractors/diagram/base_extractor.rb +18 -0
- data/lib/trace_viz/extractors/diagram/box_extractor.rb +50 -0
- data/lib/trace_viz/extractors/diagram/message_extractor.rb +23 -0
- data/lib/trace_viz/extractors/diagram/participant_extractor.rb +37 -0
- data/lib/trace_viz/extractors/diagram/processors/message_processor.rb +93 -0
- data/lib/trace_viz/formatters/base_formatter.rb +4 -30
- data/lib/trace_viz/formatters/base_formatter_factory.rb +23 -0
- data/lib/trace_viz/formatters/diagram/sequence/base_formatter.rb +14 -0
- data/lib/trace_viz/formatters/diagram/sequence/message_formatter.rb +37 -0
- data/lib/trace_viz/formatters/diagram_formatter.rb +10 -0
- data/lib/trace_viz/formatters/export/base_formatter.rb +12 -0
- data/lib/trace_viz/formatters/export/formatter_factory.rb +22 -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 +2 -8
- data/lib/trace_viz/formatters/helpers/digram/action_helper.rb +17 -0
- data/lib/trace_viz/formatters/helpers/digram/result_helper.rb +39 -0
- data/lib/trace_viz/formatters/helpers/indent_helper.rb +1 -1
- 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 +55 -0
- data/lib/trace_viz/formatters/helpers/log/result_helper.rb +27 -0
- data/lib/trace_viz/formatters/helpers/log/summary/params_helper.rb +57 -0
- data/lib/trace_viz/formatters/helpers/method_details_helper.rb +1 -1
- data/lib/trace_viz/formatters/helpers/params_helper.rb +30 -9
- data/lib/trace_viz/formatters/helpers/result_helper.rb +5 -4
- data/lib/trace_viz/formatters/helpers/source_helper.rb +6 -4
- data/lib/trace_viz/formatters/helpers/summary/params_helper.rb +45 -0
- data/lib/trace_viz/formatters/helpers/summary/source_helper.rb +24 -0
- data/lib/trace_viz/formatters/helpers/time_helper.rb +2 -2
- 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 +22 -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 +17 -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 +9 -20
- 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 +44 -0
- data/lib/trace_viz/loggers/trace_logger.rb +14 -18
- data/lib/trace_viz/loggers/trace_stats_logger.rb +28 -14
- data/lib/trace_viz/managers/diagram/participant_manager.rb +23 -0
- data/lib/trace_viz/models/box.rb +19 -0
- data/lib/trace_viz/models/diagram.rb +27 -0
- data/lib/trace_viz/models/message.rb +16 -0
- data/lib/trace_viz/models/participant.rb +18 -0
- data/lib/trace_viz/models.rb +8 -0
- data/lib/trace_viz/renderers/base_renderer.rb +27 -0
- data/lib/trace_viz/renderers/diagram/sequence_renderer.rb +59 -0
- data/lib/trace_viz/renderers/render_context.rb +17 -0
- data/lib/trace_viz/renderers/renderer_builder.rb +20 -0
- data/lib/trace_viz/renderers/renderer_factory.rb +29 -0
- data/lib/trace_viz/renderers/summary_renderer.rb +34 -0
- data/lib/trace_viz/renderers/verbose_renderer.rb +29 -0
- data/lib/trace_viz/shared/renderer_helper.rb +25 -0
- data/lib/trace_viz/shared.rb +8 -0
- data/lib/trace_viz/syntax/mermaid/sequence_syntax.rb +99 -0
- data/lib/trace_viz/trace_data/base.rb +22 -22
- data/lib/trace_viz/trace_data/node.rb +39 -0
- data/lib/trace_viz/trace_data/root_node.rb +24 -0
- data/lib/trace_viz/trace_data/summary_node.rb +45 -0
- data/lib/trace_viz/trace_data/trace_point/base.rb +26 -31
- data/lib/trace_viz/trace_data/trace_point/method_call.rb +25 -16
- data/lib/trace_viz/trace_data/trace_point/method_return.rb +21 -1
- 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/transformers/base_transformer.rb +29 -0
- data/lib/trace_viz/transformers/summary_transformer.rb +70 -0
- data/lib/trace_viz/utils/alias_generator.rb +58 -0
- data/lib/trace_viz/utils/colorize.rb +6 -6
- data/lib/trace_viz/utils/format/key_value_formatter.rb +42 -0
- data/lib/trace_viz/utils/format/value_truncator.rb +123 -0
- data/lib/trace_viz/utils/id_generator.rb +35 -0
- data/lib/trace_viz/utils.rb +8 -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 +124 -18
- data/lib/trace_viz/collectors/depth_manager.rb +0 -37
- data/lib/trace_viz/collectors/evaluators/base_evaluator.rb +0 -23
- data/lib/trace_viz/exporters/formatters/base_formatter.rb +0 -12
- data/lib/trace_viz/exporters/formatters/method_call_formatter.rb +0 -21
- data/lib/trace_viz/exporters/formatters/method_return_formatter.rb +0 -22
- data/lib/trace_viz/exporters/transformers/base_transformer.rb +0 -25
- data/lib/trace_viz/exporters/transformers/text_transformer.rb +0 -28
- data/lib/trace_viz/loggers/trace_builder.rb +0 -30
- data/lib/trace_viz/loggers/trace_formatters/base_formatter.rb +0 -32
- data/lib/trace_viz/loggers/trace_formatters/method_call_formatter.rb +0 -21
- data/lib/trace_viz/loggers/trace_formatters/method_return_formatter.rb +0 -22
- data/lib/trace_viz/utils/format_utils.rb +0 -67
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base_formatter"
|
4
|
+
require "trace_viz/formatters/helpers"
|
5
|
+
|
6
|
+
module TraceViz
|
7
|
+
module Formatters
|
8
|
+
module Diagram
|
9
|
+
module Sequence
|
10
|
+
class MessageFormatter < BaseFormatter
|
11
|
+
include Helpers::ParamsHelper
|
12
|
+
include Helpers::Diagram::ActionHelper
|
13
|
+
include Helpers::Diagram::ResultHelper
|
14
|
+
|
15
|
+
def format_internal_message(trace)
|
16
|
+
[
|
17
|
+
action_representation(trace),
|
18
|
+
params_representation(trace),
|
19
|
+
].join("")
|
20
|
+
end
|
21
|
+
|
22
|
+
def format_result(trace)
|
23
|
+
result_representation(trace)
|
24
|
+
end
|
25
|
+
|
26
|
+
def format_call
|
27
|
+
"Calling"
|
28
|
+
end
|
29
|
+
|
30
|
+
def format_return
|
31
|
+
"Returning"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../base_formatter_factory"
|
4
|
+
require_relative "method_call_formatter"
|
5
|
+
require_relative "method_return_formatter"
|
6
|
+
require_relative "summary_group_formatter"
|
7
|
+
|
8
|
+
module TraceViz
|
9
|
+
module Formatters
|
10
|
+
module Export
|
11
|
+
class FormatterFactory < BaseFormatterFactory
|
12
|
+
def initialize
|
13
|
+
super(
|
14
|
+
call: Export::MethodCallFormatter.new,
|
15
|
+
return: Export::MethodReturnFormatter.new,
|
16
|
+
summary_group: Export::SummaryGroupFormatter.new
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base_formatter"
|
4
|
+
|
5
|
+
module TraceViz
|
6
|
+
module Formatters
|
7
|
+
module Export
|
8
|
+
class MethodCallFormatter < BaseFormatter
|
9
|
+
def call(trace_data)
|
10
|
+
[
|
11
|
+
indent_representation(trace_data),
|
12
|
+
depth_representation(trace_data),
|
13
|
+
method_name_representation(trace_data),
|
14
|
+
source_location_representation(trace_data),
|
15
|
+
params_representation(trace_data),
|
16
|
+
].compact.join(" ")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base_formatter"
|
4
|
+
|
5
|
+
module TraceViz
|
6
|
+
module Formatters
|
7
|
+
module Export
|
8
|
+
class MethodReturnFormatter < BaseFormatter
|
9
|
+
def call(trace_data)
|
10
|
+
[
|
11
|
+
indent_representation(trace_data),
|
12
|
+
depth_representation(trace_data),
|
13
|
+
method_name_representation(trace_data),
|
14
|
+
result_representation(trace_data),
|
15
|
+
source_location_representation(trace_data),
|
16
|
+
execution_time_representation(trace_data),
|
17
|
+
].compact.join(" ")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base_formatter"
|
4
|
+
|
5
|
+
module TraceViz
|
6
|
+
module Formatters
|
7
|
+
module Export
|
8
|
+
class SummaryGroupFormatter < BaseFormatter
|
9
|
+
include Helpers::Summary::ParamsHelper
|
10
|
+
include Helpers::Summary::SourceHelper
|
11
|
+
|
12
|
+
def call(trace_data)
|
13
|
+
[
|
14
|
+
indent_representation(trace_data),
|
15
|
+
depth_representation(trace_data),
|
16
|
+
Defaults::Actions.emoji_for(:processing),
|
17
|
+
method_name_representation(trace_data),
|
18
|
+
source_location_representation(trace_data),
|
19
|
+
format_params_template(trace_data, config),
|
20
|
+
summary_info(trace_data),
|
21
|
+
].compact.join(" ")
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def summary_info(trace_data)
|
27
|
+
"[Summary: #{trace_data.count} calls | Avg Time: #{format(
|
28
|
+
"in %.6fms",
|
29
|
+
trace_data.duration,
|
30
|
+
)}]"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -4,16 +4,10 @@ module TraceViz
|
|
4
4
|
module Formatters
|
5
5
|
module Helpers
|
6
6
|
module DepthHelper
|
7
|
-
def depth_representation
|
7
|
+
def depth_representation(trace_data)
|
8
8
|
return unless config.general[:show_depth]
|
9
9
|
|
10
|
-
|
11
|
-
"depth[0]"
|
12
|
-
elsif trace_data.event == :call
|
13
|
-
"depth[#{trace_data.depth}]"
|
14
|
-
elsif trace_data.event == :return
|
15
|
-
"depth[#{trace_data.depth}]"
|
16
|
-
end
|
10
|
+
"depth[#{trace_data.depth}]"
|
17
11
|
end
|
18
12
|
end
|
19
13
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TraceViz
|
4
|
+
module Formatters
|
5
|
+
module Helpers
|
6
|
+
module Diagram
|
7
|
+
module ActionHelper
|
8
|
+
def action_representation(trace_data)
|
9
|
+
return unless config.general[:show_method_name]
|
10
|
+
|
11
|
+
trace_data.action
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "trace_viz/utils"
|
4
|
+
|
5
|
+
module TraceViz
|
6
|
+
module Formatters
|
7
|
+
module Helpers
|
8
|
+
module Diagram
|
9
|
+
module ResultHelper
|
10
|
+
def result_representation(trace_data)
|
11
|
+
return unless config.result[:show]
|
12
|
+
|
13
|
+
result = truncate_structure(trace_data.result)
|
14
|
+
result = sinitize_result(result)
|
15
|
+
result
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def truncate_structure(input)
|
21
|
+
Utils::Format::ValueTruncator.truncate(
|
22
|
+
input,
|
23
|
+
length: config.result[:truncate_value],
|
24
|
+
hash_length: config.result[:truncate_length],
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def sinitize_result(input)
|
29
|
+
input.to_s
|
30
|
+
# .gsub('"', "")
|
31
|
+
# .gsub("'", "")
|
32
|
+
.gsub("#", "")
|
33
|
+
.strip
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -4,7 +4,7 @@ module TraceViz
|
|
4
4
|
module Formatters
|
5
5
|
module Helpers
|
6
6
|
module IndentHelper
|
7
|
-
def indent_representation
|
7
|
+
def indent_representation(trace_data)
|
8
8
|
return unless config.general[:show_indent] && config.general[:show_depth]
|
9
9
|
|
10
10
|
" " * (config.general[:tab_size] * trace_data.depth)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "trace_viz/utils/colorize"
|
4
|
+
|
5
|
+
module TraceViz
|
6
|
+
module Formatters
|
7
|
+
module Helpers
|
8
|
+
module Log
|
9
|
+
module ColorHelper
|
10
|
+
def colorize_for(text, action)
|
11
|
+
colors = Defaults::Actions.colors_for(action)
|
12
|
+
|
13
|
+
colorize(text, *colors)
|
14
|
+
end
|
15
|
+
|
16
|
+
def colorize(text, *colors)
|
17
|
+
Utils::Colorize.colorize(text, *colors)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TraceViz
|
4
|
+
module Formatters
|
5
|
+
module Helpers
|
6
|
+
module Log
|
7
|
+
module DepthHelper
|
8
|
+
def format_depth(trace_data, config)
|
9
|
+
return unless config.general[:show_depth]
|
10
|
+
|
11
|
+
prefix = colorize_for("depth", :trace_depth_prefix)
|
12
|
+
open_block = colorize_for("[", :trace_depth_open)
|
13
|
+
number = colorize_for(trace_data.depth, :trace_depth_value)
|
14
|
+
close_block = colorize_for("]", :trace_depth_close)
|
15
|
+
|
16
|
+
[prefix, open_block, number, close_block].join
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TraceViz
|
4
|
+
module Formatters
|
5
|
+
module Helpers
|
6
|
+
module Log
|
7
|
+
module MethodNameHelper
|
8
|
+
def format_method_name(trace_data, config)
|
9
|
+
return unless config.general[:show_method_name]
|
10
|
+
|
11
|
+
"#{format_class_name(trace_data)}#{format_action_name(trace_data)}"
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def format_class_name(trace_data)
|
17
|
+
klass = colorize_for(trace_data.klass, :trace_method_class)
|
18
|
+
method_sign = colorize_for("#", :trace_method_sign)
|
19
|
+
[klass, method_sign].join
|
20
|
+
end
|
21
|
+
|
22
|
+
def format_action_name(trace_data)
|
23
|
+
colorize_for(trace_data.action, :trace_method_action)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "trace_viz/utils"
|
4
|
+
|
5
|
+
module TraceViz
|
6
|
+
module Formatters
|
7
|
+
module Helpers
|
8
|
+
module Log
|
9
|
+
module ParamsHelper
|
10
|
+
def format_params(trace_data, config)
|
11
|
+
return unless config.params[:show]
|
12
|
+
|
13
|
+
params = prepare_params(trace_data.params, config)
|
14
|
+
wrap_params(params, config)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def prepare_params(params, config)
|
20
|
+
params
|
21
|
+
.then { |p| truncate_values(p, config.params[:truncate_values]) }
|
22
|
+
.then { |p| colorize_keys_and_values(p) }
|
23
|
+
.then { |p| format_as_string(p, config.params[:mode]) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def truncate_values(params, length)
|
27
|
+
return params unless length
|
28
|
+
|
29
|
+
params.transform_values { |value| Utils::Format::ValueTruncator.truncate(value, length: length) }
|
30
|
+
end
|
31
|
+
|
32
|
+
def colorize_keys_and_values(params)
|
33
|
+
params.transform_keys { |key| colorize_for(key.to_s, :trace_params_key) }
|
34
|
+
.transform_values { |value| colorize_for(value.to_s, :trace_params_value) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def format_as_string(params, mode)
|
38
|
+
Utils::Format::KeyValueFormatter.format_pairs(params, mode: mode)
|
39
|
+
end
|
40
|
+
|
41
|
+
def wrap_params(params_string, config)
|
42
|
+
return unless params_string
|
43
|
+
|
44
|
+
truncated = Utils::Format::ValueTruncator.truncate(
|
45
|
+
params_string,
|
46
|
+
length: config.params[:truncate_length],
|
47
|
+
)
|
48
|
+
|
49
|
+
"(#{truncated})"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "trace_viz/utils"
|
4
|
+
|
5
|
+
module TraceViz
|
6
|
+
module Formatters
|
7
|
+
module Helpers
|
8
|
+
module Log
|
9
|
+
module ResultHelper
|
10
|
+
def format_result(trace_data, config)
|
11
|
+
return unless config.result[:show]
|
12
|
+
|
13
|
+
truncated_result = Utils::Format::ValueTruncator.truncate(
|
14
|
+
trace_data.result.inspect,
|
15
|
+
length: config.result[:truncate_value],
|
16
|
+
)
|
17
|
+
|
18
|
+
prefix = colorize_for("#=>", :trace_result_prefix)
|
19
|
+
result = colorize_for(truncated_result, :trace_result_value)
|
20
|
+
|
21
|
+
[prefix, result].join(" ")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "trace_viz/utils"
|
4
|
+
|
5
|
+
module TraceViz
|
6
|
+
module Formatters
|
7
|
+
module Helpers
|
8
|
+
module Log
|
9
|
+
module Summary
|
10
|
+
module ParamsHelper
|
11
|
+
def format_params_template(trace_data, config)
|
12
|
+
return unless config.params[:show]
|
13
|
+
|
14
|
+
params = prepare_params(trace_data.params, config)
|
15
|
+
wrap_params(params, config)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def prepare_params(params, config)
|
21
|
+
params
|
22
|
+
.then { |p| truncate_values(p, config.params[:truncate_values]) }
|
23
|
+
.then { |p| colorize_keys_and_values(p) }
|
24
|
+
.then { |p| format_as_string(p, config.params[:mode]) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def truncate_values(params, length)
|
28
|
+
return params unless length
|
29
|
+
|
30
|
+
params.transform_values { |value| Utils::Format::ValueTruncator.truncate(value, length: length) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def colorize_keys_and_values(params)
|
34
|
+
params.transform_keys { |key| colorize_for(key.to_s, :trace_params_key) }
|
35
|
+
.transform_values { |value| colorize("<#{value.class}>", :yellow) }
|
36
|
+
end
|
37
|
+
|
38
|
+
def format_as_string(params, mode)
|
39
|
+
Utils::Format::KeyValueFormatter.format_pairs(params, mode: mode)
|
40
|
+
end
|
41
|
+
|
42
|
+
def wrap_params(params_string, config)
|
43
|
+
return unless params_string
|
44
|
+
|
45
|
+
truncated = Utils::Format::ValueTruncator.truncate(
|
46
|
+
params_string,
|
47
|
+
length: config.params[:truncate_length],
|
48
|
+
)
|
49
|
+
|
50
|
+
"(#{truncated})"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -1,24 +1,45 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "trace_viz/utils
|
3
|
+
require "trace_viz/utils"
|
4
4
|
|
5
5
|
module TraceViz
|
6
6
|
module Formatters
|
7
7
|
module Helpers
|
8
8
|
module ParamsHelper
|
9
|
-
def params_representation
|
9
|
+
def params_representation(trace_data)
|
10
10
|
return unless config.params[:show]
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
params = process_params(trace_data.params, config)
|
13
|
+
wrap_params_string(params, config)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def process_params(params, config)
|
19
|
+
params
|
20
|
+
.then { |p| truncate_param_values(p, config.params[:truncate_values]) }
|
21
|
+
.then { |p| stringify_params(p, config.params[:mode]) }
|
22
|
+
end
|
23
|
+
|
24
|
+
def truncate_param_values(params, max_length)
|
25
|
+
return params unless max_length
|
26
|
+
|
27
|
+
params.transform_values { |value| Utils::Format::ValueTruncator.truncate(value, length: max_length) }
|
28
|
+
end
|
29
|
+
|
30
|
+
def stringify_params(params, mode)
|
31
|
+
Utils::Format::KeyValueFormatter.format_pairs(params, mode: mode)
|
32
|
+
end
|
33
|
+
|
34
|
+
def wrap_params_string(params_string, config)
|
35
|
+
return unless params_string
|
15
36
|
|
16
|
-
|
17
|
-
|
18
|
-
config.params[:
|
37
|
+
truncated_string = Utils::Format::ValueTruncator.truncate(
|
38
|
+
params_string,
|
39
|
+
length: config.params[:truncate_length],
|
19
40
|
)
|
20
41
|
|
21
|
-
"(#{
|
42
|
+
"(#{truncated_string})"
|
22
43
|
end
|
23
44
|
end
|
24
45
|
end
|
@@ -1,18 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "trace_viz/utils
|
3
|
+
require "trace_viz/utils"
|
4
4
|
|
5
5
|
module TraceViz
|
6
6
|
module Formatters
|
7
7
|
module Helpers
|
8
8
|
module ResultHelper
|
9
|
-
def result_representation
|
9
|
+
def result_representation(trace_data)
|
10
10
|
return unless config.result[:show]
|
11
11
|
|
12
|
-
truncated_result = Utils::
|
12
|
+
truncated_result = Utils::Format::ValueTruncator.truncate(
|
13
13
|
trace_data.result.inspect,
|
14
|
-
config.result[:
|
14
|
+
length: config.result[:truncate_value],
|
15
15
|
)
|
16
|
+
|
16
17
|
"#=> #{truncated_result}"
|
17
18
|
end
|
18
19
|
end
|
@@ -1,18 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "trace_viz/utils
|
3
|
+
require "trace_viz/utils"
|
4
4
|
|
5
5
|
module TraceViz
|
6
6
|
module Formatters
|
7
7
|
module Helpers
|
8
8
|
module SourceHelper
|
9
|
-
def source_location_representation
|
9
|
+
def source_location_representation(trace_data)
|
10
10
|
return unless config.source_location[:show]
|
11
11
|
|
12
|
-
truncated_path = Utils::
|
12
|
+
truncated_path = Utils::Format::ValueTruncator.truncate(
|
13
13
|
trace_data.path,
|
14
|
-
config.source_location[:truncate_length],
|
14
|
+
length: config.source_location[:truncate_length],
|
15
|
+
direction: :start,
|
15
16
|
)
|
17
|
+
|
16
18
|
"at #{truncated_path}:#{trace_data.line_number}"
|
17
19
|
end
|
18
20
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "trace_viz/utils"
|
4
|
+
|
5
|
+
module TraceViz
|
6
|
+
module Formatters
|
7
|
+
module Helpers
|
8
|
+
module Summary
|
9
|
+
module ParamsHelper
|
10
|
+
def format_params_template(trace_data, config)
|
11
|
+
return unless config.params[:show]
|
12
|
+
|
13
|
+
params_template = build_params_template(trace_data.params, config)
|
14
|
+
wrap_params_template(params_template, config)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def build_params_template(params, config)
|
20
|
+
params.transform_values do |value|
|
21
|
+
"<#{value.class}>"
|
22
|
+
end.then do |formatted_params|
|
23
|
+
format_as_string(formatted_params, config.params[:mode])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def format_as_string(params, mode)
|
28
|
+
Utils::Format::KeyValueFormatter.format_pairs(params, mode: mode)
|
29
|
+
end
|
30
|
+
|
31
|
+
def wrap_params_template(params_string, config)
|
32
|
+
return unless params_string
|
33
|
+
|
34
|
+
truncated = Utils::Format::ValueTruncator.truncate(
|
35
|
+
params_string,
|
36
|
+
length: config.params[:truncate_length],
|
37
|
+
)
|
38
|
+
|
39
|
+
"(#{truncated})"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "trace_viz/utils"
|
4
|
+
|
5
|
+
module TraceViz
|
6
|
+
module Formatters
|
7
|
+
module Helpers
|
8
|
+
module Summary
|
9
|
+
module SourceHelper
|
10
|
+
def source_location_representation(trace_data)
|
11
|
+
return unless config.source_location[:show]
|
12
|
+
|
13
|
+
truncated_path = Utils::Format::ValueTruncator.truncate(
|
14
|
+
trace_data.path,
|
15
|
+
length: config.source_location[:truncate_length],
|
16
|
+
direction: :start,
|
17
|
+
)
|
18
|
+
"at #{truncated_path}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|