rails_tracepoint_stack 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_tracepoint_stack/filter/custom_trace_selector_filter.rb +19 -0
- data/lib/rails_tracepoint_stack/filter/trace_from_dependencies_filter.rb +42 -0
- data/lib/rails_tracepoint_stack/filter/trace_from_ruby_code_filter.rb +17 -0
- data/lib/rails_tracepoint_stack/filter/trace_to_ignore_filter.rb +14 -0
- data/lib/rails_tracepoint_stack/trace_filter.rb +23 -56
- data/lib/rails_tracepoint_stack/tracer.rb +2 -1
- data/lib/rails_tracepoint_stack/version.rb +1 -1
- data/lib/rails_tracepoint_stack.rb +5 -3
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3045ee154f570e6a780af9aff0edfcd18822b3394a0f268ee9a4e07e6d5769f
|
4
|
+
data.tar.gz: 9865f094f0a70ffcb474148aaab7ee6712ac63450326bf7e3385dfc55e1c123f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c5482941d4e5119b88133eca986cdb87c490d0ed6e69ed0df5a09ebe1d2efebff0c4abbf9b554abf44cbab80038b96b3bf53cb8c86b1052b967d7ad307573d8
|
7
|
+
data.tar.gz: 699757a6965a6101ee9b80e5039580840a5e34de1271538a286d95c6ea5d2f0e678e666c8f098b2a93df5896868fc821182258f4d07616684bace6857087e7b8
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module RailsTracepointStack
|
2
|
+
module Filter
|
3
|
+
module CustomTraceSelectorFilter
|
4
|
+
def is_a_trace_required_to_watch_by_the_custom_configs?(trace:)
|
5
|
+
return false unless RailsTracepointStack.configuration.file_path_to_filter_patterns.any?
|
6
|
+
|
7
|
+
!filter_match_a_custom_pattern_to_be_not_ignored?(trace)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def filter_match_a_custom_pattern_to_be_not_ignored?(trace)
|
13
|
+
RailsTracepointStack.configuration.file_path_to_filter_patterns.any? do |pattern|
|
14
|
+
trace.file_path.match?(pattern)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rails_tracepoint_stack/filter/gem_path'
|
2
|
+
require 'rails_tracepoint_stack/filter/rb_config'
|
3
|
+
|
4
|
+
module RailsTracepointStack
|
5
|
+
module Filter
|
6
|
+
module TraceFromDependenciesFilter
|
7
|
+
def should_ignore_because_is_a_internal_dependency?(trace:)
|
8
|
+
return false if not_ignore_external_source_traces?
|
9
|
+
|
10
|
+
file_path_starts_with_gem_path?(trace) ||
|
11
|
+
file_path_starts_with_ruby_lib_path?(trace) ||
|
12
|
+
file_path_include_bundler_gems_path?(trace)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def file_path_starts_with_gem_path?(trace)
|
18
|
+
gem_paths.any? { |path| trace.file_path.start_with?(path) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def file_path_starts_with_ruby_lib_path?(trace)
|
22
|
+
trace.file_path.start_with?(ruby_lib_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
def file_path_include_bundler_gems_path?(trace)
|
26
|
+
trace.file_path.include?("gems/bundler")
|
27
|
+
end
|
28
|
+
|
29
|
+
def gem_paths
|
30
|
+
@gem_paths ||= RailsTracepointStack::Filter::GemPath.full_gem_path
|
31
|
+
end
|
32
|
+
|
33
|
+
def ruby_lib_path
|
34
|
+
@ruby_lib_path ||= RailsTracepointStack::Filter::RbConfig.ruby_lib_path
|
35
|
+
end
|
36
|
+
|
37
|
+
def not_ignore_external_source_traces?
|
38
|
+
RailsTracepointStack.configuration.log_external_sources
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module RailsTracepointStack
|
2
|
+
module Filter
|
3
|
+
module TraceFromRubyCodeFilter
|
4
|
+
def should_ignore_because_is_ruby_trace?(trace:)
|
5
|
+
return false if not_ignore_external_source_traces?
|
6
|
+
|
7
|
+
trace.file_path.start_with?('<internal:') || trace.file_path == '(eval)'
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def not_ignore_external_source_traces?
|
13
|
+
RailsTracepointStack.configuration.log_external_sources
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module RailsTracepointStack
|
2
|
+
module Filter
|
3
|
+
module TraceToIgnoreFilter
|
4
|
+
def attends_some_custom_pattern_to_ignore?(trace:)
|
5
|
+
return false unless RailsTracepointStack.configuration.ignore_patterns.any?
|
6
|
+
|
7
|
+
RailsTracepointStack
|
8
|
+
.configuration
|
9
|
+
.ignore_patterns
|
10
|
+
.any? { |pattern| trace.file_path.match?(pattern) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,63 +1,30 @@
|
|
1
|
-
require 'rails_tracepoint_stack/filter/
|
2
|
-
require 'rails_tracepoint_stack/filter/
|
1
|
+
require 'rails_tracepoint_stack/filter/custom_trace_selector_filter'
|
2
|
+
require 'rails_tracepoint_stack/filter/trace_from_dependencies_filter'
|
3
|
+
require 'rails_tracepoint_stack/filter/trace_from_ruby_code_filter'
|
4
|
+
require 'rails_tracepoint_stack/filter/trace_to_ignore_filter'
|
3
5
|
|
4
6
|
module RailsTracepointStack
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
module TraceFilter
|
8
|
+
include RailsTracepointStack::Filter::CustomTraceSelectorFilter
|
9
|
+
include RailsTracepointStack::Filter::TraceFromDependenciesFilter
|
10
|
+
include RailsTracepointStack::Filter::TraceFromRubyCodeFilter
|
11
|
+
include RailsTracepointStack::Filter::TraceToIgnoreFilter
|
12
|
+
|
13
|
+
def ignore_trace?(trace:)
|
14
|
+
if attends_some_custom_pattern_to_ignore?(trace: trace)
|
15
|
+
return true
|
11
16
|
end
|
12
|
-
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def self.contains_to_ignore_strings?(trace)
|
17
|
-
trace.file_path.start_with?('<internal:') || trace.file_path == '(eval)'
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.from_gempath_or_lib_path?(trace)
|
21
|
-
!RailsTracepointStack.configuration&.log_external_sources &&
|
22
|
-
(
|
23
|
-
file_path_starts_with_gem_path?(trace) ||
|
24
|
-
file_path_starts_with_ruby_lib_path?(trace) ||
|
25
|
-
file_path_starts_with_bundler_path?(trace)
|
26
|
-
)
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.is_a_to_ignore_pattern?(trace)
|
30
|
-
RailsTracepointStack.configuration&.ignore_patterns&.any? { |pattern| trace.file_path.match?(pattern) }
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.file_path_starts_with_gem_path?(trace)
|
34
|
-
gem_paths.any? { |path| trace.file_path.start_with?(path) }
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.file_path_starts_with_ruby_lib_path?(trace)
|
38
|
-
trace.file_path.start_with?(ruby_lib_path)
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.file_path_starts_with_bundler_path?(trace)
|
42
|
-
trace.file_path.include?("gems/bundler")
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.gem_paths
|
46
|
-
@gem_paths ||= RailsTracepointStack::Filter::GemPath.full_gem_path
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.ruby_lib_path
|
50
|
-
@ruby_lib_path ||= RailsTracepointStack::Filter::RbConfig.ruby_lib_path
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.defined_file_path_to_filter_patterns?
|
54
|
-
RailsTracepointStack.configuration&.file_path_to_filter_patterns&.any?
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.not_matches_file_path_to_filter_patterns?(trace)
|
58
|
-
!RailsTracepointStack.configuration.file_path_to_filter_patterns.any? do |pattern|
|
59
|
-
trace.file_path.match?(pattern)
|
17
|
+
if is_a_trace_required_to_watch_by_the_custom_configs?(trace: trace)
|
18
|
+
return false
|
60
19
|
end
|
20
|
+
if should_ignore_because_is_a_internal_dependency?(trace: trace)
|
21
|
+
return true
|
22
|
+
end
|
23
|
+
if should_ignore_because_is_ruby_trace?(trace: trace)
|
24
|
+
return true
|
25
|
+
end
|
26
|
+
|
27
|
+
return false
|
61
28
|
end
|
62
29
|
end
|
63
30
|
end
|
@@ -6,12 +6,13 @@ require 'rails_tracepoint_stack/log_formatter'
|
|
6
6
|
|
7
7
|
module RailsTracepointStack
|
8
8
|
class Tracer
|
9
|
+
include RailsTracepointStack::TraceFilter
|
9
10
|
# TODO: Tracer.new shoud return the tracer. Is weird to call Tracer.new.tracer
|
10
11
|
def tracer
|
11
12
|
@tracer ||= TracePoint.new(:call) do |tracepoint|
|
12
13
|
trace = RailsTracepointStack::Trace.new(trace_point: tracepoint)
|
13
14
|
|
14
|
-
next if
|
15
|
+
next if ignore_trace?(trace: trace)
|
15
16
|
|
16
17
|
# TODO: Use proper OO
|
17
18
|
message = RailsTracepointStack::LogFormatter.message trace
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'json'
|
2
1
|
require 'rails_tracepoint_stack/configuration'
|
3
2
|
require 'rails_tracepoint_stack/log_formatter'
|
4
3
|
require 'rails_tracepoint_stack/tracer'
|
@@ -7,11 +6,14 @@ $rails_tracer_rtps = nil
|
|
7
6
|
|
8
7
|
module RailsTracepointStack
|
9
8
|
class << self
|
10
|
-
|
9
|
+
attr_writer :configuration, :logger
|
10
|
+
|
11
|
+
def configuration
|
12
|
+
@configuration ||= RailsTracepointStack::Configuration.new
|
13
|
+
end
|
11
14
|
end
|
12
15
|
|
13
16
|
def self.configure
|
14
|
-
self.configuration ||= RailsTracepointStack::Configuration.new
|
15
17
|
yield(configuration)
|
16
18
|
end
|
17
19
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_tracepoint_stack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Daniel Pohlod
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -60,8 +60,12 @@ extra_rdoc_files: []
|
|
60
60
|
files:
|
61
61
|
- lib/rails_tracepoint_stack.rb
|
62
62
|
- lib/rails_tracepoint_stack/configuration.rb
|
63
|
+
- lib/rails_tracepoint_stack/filter/custom_trace_selector_filter.rb
|
63
64
|
- lib/rails_tracepoint_stack/filter/gem_path.rb
|
64
65
|
- lib/rails_tracepoint_stack/filter/rb_config.rb
|
66
|
+
- lib/rails_tracepoint_stack/filter/trace_from_dependencies_filter.rb
|
67
|
+
- lib/rails_tracepoint_stack/filter/trace_from_ruby_code_filter.rb
|
68
|
+
- lib/rails_tracepoint_stack/filter/trace_to_ignore_filter.rb
|
65
69
|
- lib/rails_tracepoint_stack/log_formatter.rb
|
66
70
|
- lib/rails_tracepoint_stack/logger.rb
|
67
71
|
- lib/rails_tracepoint_stack/trace.rb
|