trace_viz 0.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.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +15 -0
  4. data/.tool-versions +1 -0
  5. data/.vscode/launch.json +32 -0
  6. data/.vscode/settings.json +33 -0
  7. data/CODE_OF_CONDUCT.md +132 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +167 -0
  10. data/Rakefile +12 -0
  11. data/examples/example.rb +42 -0
  12. data/lib/trace_viz/adapters/base_adapter.rb +13 -0
  13. data/lib/trace_viz/adapters/trace_point/depth_manager.rb +34 -0
  14. data/lib/trace_viz/adapters/trace_point/event_handler.rb +36 -0
  15. data/lib/trace_viz/adapters/trace_point/trace_data.rb +89 -0
  16. data/lib/trace_viz/adapters/trace_point/trace_formatter.rb +95 -0
  17. data/lib/trace_viz/adapters/trace_point/trace_logger.rb +44 -0
  18. data/lib/trace_viz/adapters/trace_point_adapter.rb +25 -0
  19. data/lib/trace_viz/configuration.rb +61 -0
  20. data/lib/trace_viz/context/base_context.rb +13 -0
  21. data/lib/trace_viz/context/config_context.rb +34 -0
  22. data/lib/trace_viz/context/manager/context_map.rb +31 -0
  23. data/lib/trace_viz/context/manager/context_operations.rb +60 -0
  24. data/lib/trace_viz/context/manager/context_registry.rb +20 -0
  25. data/lib/trace_viz/context/manager/context_validation.rb +34 -0
  26. data/lib/trace_viz/context/manager.rb +37 -0
  27. data/lib/trace_viz/context/tracking/depth.rb +31 -0
  28. data/lib/trace_viz/context/tracking_context.rb +18 -0
  29. data/lib/trace_viz/context.rb +13 -0
  30. data/lib/trace_viz/core/tracer.rb +19 -0
  31. data/lib/trace_viz/core.rb +8 -0
  32. data/lib/trace_viz/errors.rb +8 -0
  33. data/lib/trace_viz/logger.rb +73 -0
  34. data/lib/trace_viz/utils/colorize.rb +35 -0
  35. data/lib/trace_viz/version.rb +5 -0
  36. data/lib/trace_viz.rb +13 -0
  37. data/sig/trace_viz.rbs +4 -0
  38. metadata +83 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: dad6986e31d5fab4d42a7e6820086bd39ad16d3dd7461b483425d06122533d56
4
+ data.tar.gz: ca9411d76b1134ad5e676264771e7046a6e52fbe250040f61c5b3294071d2578
5
+ SHA512:
6
+ metadata.gz: c66ab56494adc950558f5e9f21f8630178a262443440d70799ee43284ad03b0615e1031df8f24d495b9970b054c841c057d1858e629e5216c05c35a7485071b6
7
+ data.tar.gz: c30a273a89fa59c417e3974056916f135083ad50320dbb18c063b3db0c365231bb09118611770e1a158435997733101e9a917026245936ece186c73a7e9fcf71
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,15 @@
1
+ inherit_gem:
2
+ rubocop-shopify: rubocop.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 3.0
6
+ Exclude:
7
+ - '.git/**/*'
8
+ - 'Rakefile'
9
+ - 'examples/**/*'
10
+
11
+ Style/StringLiterals:
12
+ EnforcedStyle: double_quotes
13
+
14
+ Style/StringLiteralsInInterpolation:
15
+ EnforcedStyle: double_quotes
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.3.0
@@ -0,0 +1,32 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "type": "ruby_lsp",
6
+ "name": "RSpec: Run Current Spec File",
7
+ "request": "launch",
8
+ "program": "${workspaceFolder}/bin/rspec ${file}",
9
+ "env": {
10
+ "RAILS_ENV": "test"
11
+ }
12
+ },
13
+ {
14
+ "type": "ruby_lsp",
15
+ "name": "RSpec: Run All Specs",
16
+ "request": "launch",
17
+ "program": "${workspaceFolder}/bin/rspec",
18
+ "env": {
19
+ "RAILS_ENV": "test"
20
+ }
21
+ },
22
+ {
23
+ "type": "ruby_lsp",
24
+ "name": "RSpec: Run Test at Cursor",
25
+ "request": "launch",
26
+ "program": "${workspaceFolder}/bin/rspec ${file}:${lineNumber}",
27
+ "env": {
28
+ "RAILS_ENV": "test"
29
+ }
30
+ }
31
+ ]
32
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "[ruby]": {
3
+ "editor.defaultFormatter": "Shopify.ruby-lsp",
4
+ "editor.formatOnSave": true,
5
+ "editor.tabSize": 2,
6
+ "editor.insertSpaces": true,
7
+ "editor.semanticHighlighting.enabled": true,
8
+ "editor.formatOnType": true
9
+ },
10
+ "[markdown]": {
11
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
12
+ "editor.formatOnSave": true,
13
+ "editor.tabSize": 2
14
+ },
15
+ "rubyLsp.enabledFeatures": {
16
+ "codeActions": true,
17
+ "diagnostics": true,
18
+ "documentHighlights": true,
19
+ "documentLink": true,
20
+ "documentSymbols": true,
21
+ "foldingRanges": true,
22
+ "formatting": true,
23
+ "hover": true,
24
+ "inlayHint": true,
25
+ "onTypeFormatting": true,
26
+ "selectionRanges": true,
27
+ "semanticHighlighting": true,
28
+ "completion": true,
29
+ "codeLens": true
30
+ },
31
+ "rubyLsp.formatter": "rubocop",
32
+ "ruby.rubocop.configFilePath": ".rubocop.yml"
33
+ }
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,167 @@
1
+ # TraceViz
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/trace_viz.svg)](https://rubygems.org/gems/trace_viz)
4
+ [![Downloads](https://img.shields.io/gem/dt/trace_viz)](https://rubygems.org/gems/trace_viz)
5
+ [![Build Status](https://github.com/patrick204nqh/trace_viz/actions/workflows/main.yml/badge.svg)](https://github.com/patrick204nqh/trace_viz/actions)
6
+ [![Maintainability](https://api.codeclimate.com/v1/badges/e97579abe66f3477e71d/maintainability)](https://codeclimate.com/github/patrick204nqh/trace_viz/maintainability)
7
+ ![License](https://img.shields.io/github/license/patrick204nqh/trace_viz)
8
+
9
+ TraceViz is a Ruby library designed to trace and visualize events executed in a block of code. It is useful for logging, debugging, and generating diagrams to understand code execution and flow. The gem allows you to customize how much detail you want to see, such as method calls, parameters, return values, and execution times.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```bash
16
+ gem 'trace_viz'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ ```bash
22
+ bundle install
23
+ ```
24
+
25
+ Or install it yourself as:
26
+
27
+ ```bash
28
+ gem install trace_viz
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ Wrap your code inside the TraceViz.trace block to start tracing its execution. The tracing behavior can be customized using various options:
34
+
35
+ ```ruby
36
+ TraceViz.trace(
37
+ tab_size: 2,
38
+ show_indent: true,
39
+ show_depth: true,
40
+ max_display_depth: 4, # Recommended to keep this value between 3 and 5
41
+ show_method_name: true,
42
+ show_source_location: false,
43
+ show_params: true,
44
+ show_return_value: true,
45
+ show_execution_time: true,
46
+ show_trace_events: [:call, :return]
47
+ ) do
48
+ # Your code here
49
+ end
50
+ ```
51
+
52
+ **Example**
53
+
54
+ ```ruby
55
+ class Example
56
+ def perform_task(x, y)
57
+ result = add_numbers(x, y)
58
+ log_result(result)
59
+ result
60
+ end
61
+
62
+ def add_numbers(a, b)
63
+ sleep(0.1)
64
+ sum = a + b
65
+ multiply_by_factor(sum, 2)
66
+ end
67
+
68
+ def multiply_by_factor(value, factor)
69
+ sleep(0.05)
70
+ value * factor
71
+ end
72
+
73
+ def log_result(result)
74
+ sleep(0.02)
75
+ puts "Final result: #{result}"
76
+ end
77
+ end
78
+
79
+ TraceViz.trace(
80
+ tab_size: 4,
81
+ show_indent: true,
82
+ show_depth: true,
83
+ max_display_depth: 3,
84
+ show_method_name: true,
85
+ show_source_location: false,
86
+ show_params: true,
87
+ show_return_value: true,
88
+ show_execution_time: true,
89
+ show_trace_events: [:call, :return]
90
+ ) do
91
+ example = Example.new
92
+ example.perform_task(5, 7)
93
+ end
94
+ ```
95
+
96
+ **Output**
97
+
98
+ ```bash
99
+ 🚀 [START] #depth:0 Example#perform_task (5, 7, nil)
100
+ 🚀 [START] #depth:1 Example#add_numbers (5, 7, nil)
101
+ 🚀 [START] #depth:2 Example#multiply_by_factor (12, 2)
102
+ 🏁 [FINISH] #depth:2 Example#multiply_by_factor #=> 24
103
+ 🏁 [FINISH] #depth:1 Example#add_numbers #=> 24
104
+ 🚀 [START] #depth:1 Example#log_result (24)
105
+ Final result: 24
106
+ 🏁 [FINISH] #depth:1 Example#log_result #=> nil
107
+ 🏁 [FINISH] #depth:0 Example#perform_task #=> 24
108
+ ```
109
+
110
+ ### Configuration Options
111
+
112
+ | Option | Type | Description |
113
+ | ---------------------- | ---------------- | -------------------------------------------------------------------------------- |
114
+ | `tab_size` | Integer | Defines the number of spaces used for indentation when `show_indent` is enabled. |
115
+ | `show_indent` | Boolean | Whether to visually indent nested calls. |
116
+ | `show_depth` | Boolean | Displays the depth level of the method call. |
117
+ | `max_display_depth` | Integer | Limits the display to a maximum depth of calls. |
118
+ | `show_method_name` | Boolean | Shows the name of the method being called. |
119
+ | `show_source_location` | Boolean | Logs the source file name and line number where the method is defined. |
120
+ | `show_params` | Boolean | Logs the parameters passed to the method. |
121
+ | `show_return_value` | Boolean | Logs the return value of the method. |
122
+ | `show_execution_time` | Boolean | Logs the execution time for methods. |
123
+ | `show_trace_events` | Array of Symbols | Specifies the events to trace. Valid values include: |
124
+ | | | - `:call` - Log method calls. |
125
+ | | | - `:return` - Log method returns. |
126
+
127
+ ## Development
128
+
129
+ To set up your development environment:
130
+
131
+ 1. Clone the repository:
132
+
133
+ ```bash
134
+ git clone https://github.com/patrick204nqh/trace_viz.git
135
+ ```
136
+
137
+ 2. Navigate to the project directory:
138
+
139
+ ```bash
140
+ cd trace_viz
141
+ ```
142
+
143
+ 3. Install dependencies:
144
+
145
+ ```bash
146
+ bundle install
147
+ ```
148
+
149
+ 4. Run the test suite:
150
+
151
+ ```bash
152
+ bin/rspec
153
+ ```
154
+
155
+ You can use `irb` or `pry` to test the gem locally. Make your changes, add tests, and ensure all tests pass before submitting a pull request.
156
+
157
+ ## Contributing
158
+
159
+ Bug reports and pull requests are welcome on GitHub at https://github.com/patrick204nqh/trace_viz. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/patrick204nqh/trace_viz/blob/main/CODE_OF_CONDUCT.md).
160
+
161
+ ## License
162
+
163
+ TraceViz is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
164
+
165
+ ## Acknowledgements
166
+
167
+ Special thanks to the Ruby community for their continued support and inspiration!
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,42 @@
1
+ $LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
2
+ require "trace_viz"
3
+
4
+ class Example
5
+ def perform_task(x, y)
6
+ result = add_numbers(x, y)
7
+ log_result(result)
8
+ result
9
+ end
10
+
11
+ def add_numbers(a, b)
12
+ sleep(0.1)
13
+ sum = a + b
14
+ multiply_by_factor(sum, 2)
15
+ end
16
+
17
+ def multiply_by_factor(value, factor)
18
+ sleep(0.05)
19
+ value * factor
20
+ end
21
+
22
+ def log_result(result)
23
+ sleep(0.02)
24
+ puts "Final result: #{result}"
25
+ end
26
+ end
27
+
28
+ TraceViz.trace(
29
+ tab_size: 4,
30
+ show_indent: true,
31
+ show_depth: true,
32
+ max_display_depth: 3,
33
+ show_method_name: true,
34
+ show_params: true,
35
+ show_return_value: true,
36
+ show_execution_time: true,
37
+ show_source_location: true,
38
+ show_trace_events: [:call, :return]
39
+ ) do
40
+ example = Example.new
41
+ example.perform_task(5, 7)
42
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "trace_viz/context"
4
+
5
+ module TraceViz
6
+ module Adapters
7
+ class BaseAdapter
8
+ def trace
9
+ raise NotImplementedError
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,34 @@
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
@@ -0,0 +1,36 @@
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
@@ -0,0 +1,89 @@
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