trace_viz 0.0.1 → 0.0.2

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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +34 -0
  3. data/README.md +130 -38
  4. data/examples/example.cast +285 -0
  5. data/examples/example.rb +94 -23
  6. data/lib/trace_viz/adapters/base_adapter.rb +0 -2
  7. data/lib/trace_viz/adapters/trace_point_adapter.rb +17 -11
  8. data/lib/trace_viz/collectors/base_collector.rb +83 -0
  9. data/lib/trace_viz/collectors/depth_manager.rb +37 -0
  10. data/lib/trace_viz/collectors/evaluators/base_evaluator.rb +23 -0
  11. data/lib/trace_viz/collectors/evaluators/filter_evaluator.rb +30 -0
  12. data/lib/trace_viz/collectors/evaluators/hidden_evaluator.rb +21 -0
  13. data/lib/trace_viz/collectors/filters/base_filter.rb +23 -0
  14. data/lib/trace_viz/collectors/filters/exclude_classes_filter.rb +28 -0
  15. data/lib/trace_viz/collectors/filters/exclude_default_classes_filter.rb +38 -0
  16. data/lib/trace_viz/collectors/filters/exclude_gems_filter.rb +30 -0
  17. data/lib/trace_viz/collectors/filters/exclude_internal_call_filter.rb +31 -0
  18. data/lib/trace_viz/collectors/filters/exclude_rails_framework_filter.rb +38 -0
  19. data/lib/trace_viz/collectors/filters/include_classes_filter.rb +28 -0
  20. data/lib/trace_viz/collectors/filters/include_gems_filter.rb +54 -0
  21. data/lib/trace_viz/collectors/filters/registry.rb +59 -0
  22. data/lib/trace_viz/collectors/matchers/trace_point_action_matcher.rb +36 -0
  23. data/lib/trace_viz/collectors/matchers/within_depth_matcher.rb +25 -0
  24. data/lib/trace_viz/collectors/trace_point_collector.rb +51 -0
  25. data/lib/trace_viz/collectors/trace_stats.rb +21 -0
  26. data/lib/trace_viz/config/copier.rb +38 -0
  27. data/lib/trace_viz/config/validator.rb +74 -0
  28. data/lib/trace_viz/configuration.rb +36 -30
  29. data/lib/trace_viz/context/config_context.rb +1 -1
  30. data/lib/trace_viz/context/manager.rb +17 -21
  31. data/lib/trace_viz/context/map.rb +29 -0
  32. data/lib/trace_viz/context/registry.rb +37 -0
  33. data/lib/trace_viz/context/tracking/active_calls.rb +37 -0
  34. data/lib/trace_viz/context/tracking_context.rb +7 -2
  35. data/lib/trace_viz/context.rb +2 -2
  36. data/lib/trace_viz/core/tracer.rb +1 -0
  37. data/lib/trace_viz/defaults.rb +139 -0
  38. data/lib/trace_viz/exporters/base_exporter.rb +84 -0
  39. data/lib/trace_viz/exporters/formatters/base_formatter.rb +12 -0
  40. data/lib/trace_viz/exporters/formatters/method_call_formatter.rb +21 -0
  41. data/lib/trace_viz/exporters/formatters/method_return_formatter.rb +22 -0
  42. data/lib/trace_viz/exporters/text_exporter.rb +15 -0
  43. data/lib/trace_viz/exporters/transformers/base_transformer.rb +25 -0
  44. data/lib/trace_viz/exporters/transformers/text_transformer.rb +28 -0
  45. data/lib/trace_viz/formatters/base_formatter.rb +42 -0
  46. data/lib/trace_viz/formatters/helpers/depth_helper.rb +21 -0
  47. data/lib/trace_viz/formatters/helpers/indent_helper.rb +15 -0
  48. data/lib/trace_viz/formatters/helpers/method_details_helper.rb +15 -0
  49. data/lib/trace_viz/formatters/helpers/params_helper.rb +26 -0
  50. data/lib/trace_viz/formatters/helpers/result_helper.rb +21 -0
  51. data/lib/trace_viz/formatters/helpers/source_helper.rb +21 -0
  52. data/lib/trace_viz/formatters/helpers/time_helper.rb +15 -0
  53. data/lib/trace_viz/logger.rb +37 -47
  54. data/lib/trace_viz/loggers/trace_builder.rb +30 -0
  55. data/lib/trace_viz/loggers/trace_formatters/base_formatter.rb +32 -0
  56. data/lib/trace_viz/loggers/trace_formatters/method_call_formatter.rb +21 -0
  57. data/lib/trace_viz/loggers/trace_formatters/method_return_formatter.rb +22 -0
  58. data/lib/trace_viz/loggers/trace_logger.rb +38 -0
  59. data/lib/trace_viz/loggers/trace_stats_logger.rb +33 -0
  60. data/lib/trace_viz/trace_data/base.rb +56 -0
  61. data/lib/trace_viz/trace_data/trace_point/base.rb +68 -0
  62. data/lib/trace_viz/trace_data/trace_point/method_call.rb +42 -0
  63. data/lib/trace_viz/trace_data/trace_point/method_return.rb +25 -0
  64. data/lib/trace_viz/trace_data/trace_point_builder.rb +23 -0
  65. data/lib/trace_viz/utils/colorize.rb +12 -23
  66. data/lib/trace_viz/utils/format_utils.rb +67 -0
  67. data/lib/trace_viz/version.rb +1 -1
  68. metadata +58 -13
  69. data/lib/trace_viz/adapters/trace_point/depth_manager.rb +0 -34
  70. data/lib/trace_viz/adapters/trace_point/event_handler.rb +0 -36
  71. data/lib/trace_viz/adapters/trace_point/trace_data.rb +0 -89
  72. data/lib/trace_viz/adapters/trace_point/trace_formatter.rb +0 -95
  73. data/lib/trace_viz/adapters/trace_point/trace_logger.rb +0 -44
  74. data/lib/trace_viz/context/manager/context_map.rb +0 -31
  75. data/lib/trace_viz/context/manager/context_operations.rb +0 -60
  76. data/lib/trace_viz/context/manager/context_registry.rb +0 -20
  77. data/lib/trace_viz/context/manager/context_validation.rb +0 -34
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "trace_viz/context/base_context"
4
-
5
- module TraceViz
6
- module Context
7
- class Manager
8
- module ContextOperations
9
- def create_context(key = nil, **options)
10
- if key
11
- validate_key!(key)
12
- ensure_unique_key!(key)
13
- end
14
-
15
- context_class = @registered_contexts[key] || BaseContext
16
- context = context_class.new(**options)
17
- @context_map[key] = context if key
18
- context
19
- end
20
-
21
- def enter_context(key = nil, **options)
22
- create_context(key, **options)
23
- end
24
-
25
- def enter_multiple_contexts(contexts_with_options = {})
26
- unless contexts_with_options.is_a?(Hash)
27
- raise ContextError, "Expected a Hash of contexts and options, got #{contexts_with_options.class}"
28
- end
29
-
30
- contexts_with_options.each do |key, options|
31
- enter_context(key, **options)
32
- end
33
- end
34
-
35
- def exit_context(key)
36
- validate_key!(key)
37
- context = @context_map.delete(key)
38
- raise ContextError, "No context found with key '#{key}' to exit" unless context
39
-
40
- context
41
- end
42
-
43
- def exit_multiple_contexts(*keys)
44
- keys.each do |key|
45
- validate_key!(key)
46
- exit_context(key)
47
- end
48
- end
49
-
50
- # Execute a block within the context(s) specified
51
- def with_contexts(contexts_with_options = {})
52
- enter_multiple_contexts(contexts_with_options)
53
- yield
54
- ensure
55
- exit_multiple_contexts(*contexts_with_options.keys)
56
- end
57
- end
58
- end
59
- end
60
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module TraceViz
4
- module Context
5
- class Manager
6
- module ContextRegistry
7
- def register_context_type(key, context_class)
8
- validate_key!(key)
9
- validate_context_class!(context_class)
10
-
11
- if @registered_contexts.key?(key)
12
- raise ContextError, "Context type for key '#{key}' is already registered"
13
- end
14
-
15
- @registered_contexts[key] = context_class
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module TraceViz
4
- module Context
5
- class Manager
6
- module ContextValidation
7
- private
8
-
9
- # Validate that the key is either a Symbol or String
10
- def validate_key!(key)
11
- return unless key
12
-
13
- unless key.is_a?(Symbol) || key.is_a?(String)
14
- raise ContextError, "Key must be a Symbol or String, got #{key.class}"
15
- end
16
- end
17
-
18
- # Ensure that the key is unique (no existing context with the same key)
19
- def ensure_unique_key!(key)
20
- if @context_map.key?(key)
21
- raise ContextError, "Context with key '#{key}' already exists"
22
- end
23
- end
24
-
25
- # Validate that the context_class inherits from BaseContext
26
- def validate_context_class!(context_class)
27
- unless context_class < BaseContext
28
- raise ContextError, "Context class must inherit from BaseContext"
29
- end
30
- end
31
- end
32
- end
33
- end
34
- end