catpm 0.6.3 → 0.6.5
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/app/controllers/catpm/endpoints_controller.rb +3 -3
- data/lib/catpm/collector.rb +4 -0
- data/lib/catpm/configuration.rb +39 -30
- data/lib/catpm/event.rb +20 -4
- data/lib/catpm/flusher.rb +1 -0
- data/lib/catpm/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '0938b1a8e37174b8c0415de3303614b40657302ac1cf4d366214fe9dd0fd769c'
|
|
4
|
+
data.tar.gz: cc9308558a8a7065ff99d225fb18244ab8f51492af67f3d7ba83fa2e48923b35
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b5c7af3130bf87eb185ca324214dfefc2e5c4bd1ecf5a180200ade47847c3f9fa710bc8bc108055f969344e76134f5369bcd82441193ac9199bcbe072093d0e9
|
|
7
|
+
data.tar.gz: 1c47ef33465c2eaa31a92c7cf538afc9cc9b055ef21128181888c94c1363b886e6bc81c4cabfb229d856b4d500856ac189820c020326615a460698737578cf1b
|
|
@@ -81,9 +81,9 @@ module Catpm
|
|
|
81
81
|
.joins(:bucket)
|
|
82
82
|
.where(catpm_buckets: { kind: @kind, target: @target, operation: @operation })
|
|
83
83
|
|
|
84
|
-
@slow_samples = endpoint_samples.where(sample_type: 'slow').order(duration: :desc)
|
|
85
|
-
@samples = endpoint_samples.where(sample_type: 'random').order(recorded_at: :desc)
|
|
86
|
-
@error_samples = endpoint_samples.where(sample_type: 'error').order(recorded_at: :desc)
|
|
84
|
+
@slow_samples = endpoint_samples.where(sample_type: 'slow').order(duration: :desc)
|
|
85
|
+
@samples = endpoint_samples.where(sample_type: 'random').order(recorded_at: :desc)
|
|
86
|
+
@error_samples = endpoint_samples.where(sample_type: 'error').order(recorded_at: :desc)
|
|
87
87
|
|
|
88
88
|
@pref = Catpm::EndpointPref.find_by(kind: @kind, target: @target, operation: @operation)
|
|
89
89
|
@active_error_count = Catpm::ErrorRecord.unresolved.count
|
data/lib/catpm/collector.rb
CHANGED
|
@@ -406,6 +406,10 @@ module Catpm
|
|
|
406
406
|
@random_sample_counts ||= Hash.new(0)
|
|
407
407
|
end
|
|
408
408
|
|
|
409
|
+
def reset_sample_counts!
|
|
410
|
+
@random_sample_counts = nil
|
|
411
|
+
end
|
|
412
|
+
|
|
409
413
|
def inject_gap_segments(segments, req_segments, gap, ctrl_idx, ctrl_seg)
|
|
410
414
|
sampler_groups = req_segments&.sampler_segments || []
|
|
411
415
|
|
data/lib/catpm/configuration.rb
CHANGED
|
@@ -2,57 +2,66 @@
|
|
|
2
2
|
|
|
3
3
|
module Catpm
|
|
4
4
|
class Configuration
|
|
5
|
+
# Boolean / non-numeric settings — plain attr_accessor
|
|
5
6
|
attr_accessor :enabled,
|
|
6
7
|
:instrument_http,
|
|
7
8
|
:instrument_jobs,
|
|
8
9
|
:instrument_segments,
|
|
9
10
|
:instrument_net_http,
|
|
10
11
|
:instrument_stack_sampler,
|
|
11
|
-
:
|
|
12
|
-
:
|
|
13
|
-
:max_sql_length,
|
|
14
|
-
:slow_threshold,
|
|
12
|
+
:instrument_middleware_stack,
|
|
13
|
+
:instrument_call_tree,
|
|
15
14
|
:slow_threshold_per_kind,
|
|
16
15
|
:ignored_targets,
|
|
17
|
-
:retention_period,
|
|
18
|
-
:max_buffer_memory,
|
|
19
|
-
:flush_interval,
|
|
20
|
-
:flush_jitter,
|
|
21
|
-
:max_error_contexts,
|
|
22
16
|
:bucket_sizes,
|
|
23
17
|
:error_handler,
|
|
24
18
|
:http_basic_auth_user,
|
|
25
19
|
:http_basic_auth_password,
|
|
26
20
|
:access_policy,
|
|
27
21
|
:additional_filter_parameters,
|
|
28
|
-
:instrument_middleware_stack,
|
|
29
22
|
:auto_instrument_methods,
|
|
30
23
|
:service_base_classes,
|
|
31
|
-
:random_sample_rate,
|
|
32
|
-
:max_random_samples_per_endpoint,
|
|
33
|
-
:max_slow_samples_per_endpoint,
|
|
34
|
-
:max_error_samples_per_fingerprint,
|
|
35
|
-
:cleanup_interval,
|
|
36
|
-
:circuit_breaker_failure_threshold,
|
|
37
|
-
:circuit_breaker_recovery_timeout,
|
|
38
|
-
:sqlite_busy_timeout,
|
|
39
|
-
:persistence_batch_size,
|
|
40
|
-
:backtrace_lines,
|
|
41
|
-
:shutdown_timeout,
|
|
42
24
|
:events_enabled,
|
|
43
|
-
:events_max_samples_per_name,
|
|
44
25
|
:track_own_requests,
|
|
45
|
-
:stack_sample_interval,
|
|
46
|
-
:max_stack_samples_per_request,
|
|
47
26
|
:downsampling_thresholds,
|
|
48
|
-
:max_error_detail_length,
|
|
49
|
-
:max_fingerprint_app_frames,
|
|
50
|
-
:max_fingerprint_gem_frames,
|
|
51
|
-
:cleanup_batch_size,
|
|
52
|
-
:caller_scan_depth,
|
|
53
|
-
:instrument_call_tree,
|
|
54
27
|
:show_untracked_segments
|
|
55
28
|
|
|
29
|
+
# Numeric settings that must be positive numbers (nil not allowed)
|
|
30
|
+
REQUIRED_NUMERIC = %i[
|
|
31
|
+
slow_threshold max_buffer_memory flush_interval flush_jitter
|
|
32
|
+
random_sample_rate cleanup_interval
|
|
33
|
+
circuit_breaker_failure_threshold circuit_breaker_recovery_timeout
|
|
34
|
+
sqlite_busy_timeout persistence_batch_size shutdown_timeout
|
|
35
|
+
stack_sample_interval segment_source_threshold
|
|
36
|
+
].freeze
|
|
37
|
+
|
|
38
|
+
# Numeric settings where nil means "no limit" / "disabled"
|
|
39
|
+
OPTIONAL_NUMERIC = %i[
|
|
40
|
+
max_segments_per_request retention_period backtrace_lines
|
|
41
|
+
max_random_samples_per_endpoint max_slow_samples_per_endpoint
|
|
42
|
+
max_error_samples_per_fingerprint max_sql_length max_error_contexts
|
|
43
|
+
events_max_samples_per_name max_stack_samples_per_request
|
|
44
|
+
max_error_detail_length max_fingerprint_app_frames
|
|
45
|
+
max_fingerprint_gem_frames cleanup_batch_size caller_scan_depth
|
|
46
|
+
].freeze
|
|
47
|
+
|
|
48
|
+
(REQUIRED_NUMERIC + OPTIONAL_NUMERIC).each do |attr|
|
|
49
|
+
attr_reader attr
|
|
50
|
+
|
|
51
|
+
define_method(:"#{attr}=") do |value|
|
|
52
|
+
if REQUIRED_NUMERIC.include?(attr)
|
|
53
|
+
unless value.is_a?(Numeric)
|
|
54
|
+
raise ArgumentError, "catpm config.#{attr} must be a number, got #{value.inspect}"
|
|
55
|
+
end
|
|
56
|
+
else
|
|
57
|
+
unless value.nil? || value.is_a?(Numeric)
|
|
58
|
+
raise ArgumentError, "catpm config.#{attr} must be a number or nil, got #{value.inspect}"
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
instance_variable_set(:"@#{attr}", value)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
56
65
|
def initialize
|
|
57
66
|
@enabled = true
|
|
58
67
|
@instrument_http = true
|
data/lib/catpm/event.rb
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
module Catpm
|
|
4
4
|
class Event
|
|
5
|
-
OBJECT_OVERHEAD = 40
|
|
6
|
-
REF_SIZE = 8
|
|
5
|
+
OBJECT_OVERHEAD = 40 # bytes, Ruby object header
|
|
6
|
+
REF_SIZE = 8 # bytes, pointer on 64-bit
|
|
7
|
+
HASH_ENTRY_SIZE = 80 # bytes, per key-value pair in a Hash (bucket + key obj + value obj)
|
|
7
8
|
NUMERIC_FIELDS_SIZE = 64 # fixed numeric fields (duration, timestamps, etc.)
|
|
8
9
|
|
|
9
10
|
attr_accessor :kind, :target, :operation, :duration, :started_at,
|
|
@@ -69,13 +70,28 @@ module Catpm
|
|
|
69
70
|
def context_bytes
|
|
70
71
|
return 0 if context.nil? || context.empty?
|
|
71
72
|
|
|
72
|
-
context
|
|
73
|
+
estimate_hash_bytes(context)
|
|
73
74
|
end
|
|
74
75
|
|
|
75
76
|
def metadata_bytes
|
|
76
77
|
return 0 if metadata.nil? || metadata.empty?
|
|
77
78
|
|
|
78
|
-
metadata
|
|
79
|
+
estimate_hash_bytes(metadata)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def estimate_hash_bytes(obj)
|
|
83
|
+
case obj
|
|
84
|
+
when Hash
|
|
85
|
+
OBJECT_OVERHEAD + obj.sum { |k, v| HASH_ENTRY_SIZE + estimate_hash_bytes(k) + estimate_hash_bytes(v) }
|
|
86
|
+
when Array
|
|
87
|
+
OBJECT_OVERHEAD + obj.sum { |v| REF_SIZE + estimate_hash_bytes(v) }
|
|
88
|
+
when String
|
|
89
|
+
OBJECT_OVERHEAD + obj.bytesize
|
|
90
|
+
when Symbol, Integer, Float, TrueClass, FalseClass, NilClass
|
|
91
|
+
REF_SIZE
|
|
92
|
+
else
|
|
93
|
+
OBJECT_OVERHEAD + REF_SIZE
|
|
94
|
+
end
|
|
79
95
|
end
|
|
80
96
|
end
|
|
81
97
|
end
|
data/lib/catpm/flusher.rb
CHANGED
data/lib/catpm/version.rb
CHANGED