catpm 0.10.3 → 0.11.0
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 +1 -1
- data/app/helpers/catpm/application_helper.rb +5 -3
- data/app/views/catpm/errors/show.html.erb +1 -1
- data/app/views/catpm/samples/show.html.erb +17 -3
- data/app/views/catpm/shared/_segments_timeline.html.erb +155 -0
- data/app/views/catpm/shared/_segments_waterfall.html.erb +15 -14
- data/app/views/catpm/status/index.html.erb +4 -4
- data/app/views/catpm/system/pipeline.html.erb +1 -1
- data/app/views/layouts/catpm/application.html.erb +147 -6
- data/db/migrate/20250601000001_create_catpm_tables.rb +34 -32
- data/lib/catpm/call_tracer.rb +2 -1
- data/lib/catpm/collector.rb +434 -46
- data/lib/catpm/configuration.rb +6 -2
- data/lib/catpm/engine.rb +9 -0
- data/lib/catpm/fingerprint.rb +6 -0
- data/lib/catpm/middleware.rb +3 -4
- data/lib/catpm/request_segments.rb +18 -1
- data/lib/catpm/segment_subscribers.rb +1 -1
- data/lib/catpm/sidekiq_server_middleware.rb +90 -0
- data/lib/catpm/stack_sampler.rb +3 -3
- data/lib/catpm/version.rb +1 -1
- data/lib/catpm.rb +5 -0
- data/lib/generators/catpm/templates/initializer.rb.tt +2 -2
- metadata +3 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
class CreateCatpmTables < ActiveRecord::Migration[
|
|
3
|
+
class CreateCatpmTables < ActiveRecord::Migration[Catpm::MIGRATION_VERSION]
|
|
4
4
|
def up
|
|
5
|
-
create_table :catpm_buckets do |t|
|
|
5
|
+
create_table :catpm_buckets, if_not_exists: true do |t|
|
|
6
6
|
t.string :kind, null: false
|
|
7
7
|
t.string :target, null: false
|
|
8
8
|
t.string :operation, null: false, default: ''
|
|
@@ -21,11 +21,11 @@ class CreateCatpmTables < ActiveRecord::Migration[8.0]
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
add_index :catpm_buckets, [:kind, :target, :operation, :bucket_start],
|
|
24
|
-
unique: true, name: 'idx_catpm_buckets_unique'
|
|
25
|
-
add_index :catpm_buckets, :bucket_start, name: 'idx_catpm_buckets_time'
|
|
26
|
-
add_index :catpm_buckets, [:kind, :bucket_start], name: 'idx_catpm_buckets_kind_time'
|
|
24
|
+
unique: true, name: 'idx_catpm_buckets_unique', if_not_exists: true
|
|
25
|
+
add_index :catpm_buckets, :bucket_start, name: 'idx_catpm_buckets_time', if_not_exists: true
|
|
26
|
+
add_index :catpm_buckets, [:kind, :bucket_start], name: 'idx_catpm_buckets_kind_time', if_not_exists: true
|
|
27
27
|
|
|
28
|
-
create_table :catpm_samples do |t|
|
|
28
|
+
create_table :catpm_samples, if_not_exists: true do |t|
|
|
29
29
|
t.references :bucket, null: false, foreign_key: { to_table: :catpm_buckets }
|
|
30
30
|
t.string :kind, null: false
|
|
31
31
|
t.string :sample_type, null: false
|
|
@@ -36,12 +36,12 @@ class CreateCatpmTables < ActiveRecord::Migration[8.0]
|
|
|
36
36
|
t.string :request_id, limit: 16
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
add_index :catpm_samples, :recorded_at, name: 'idx_catpm_samples_time'
|
|
40
|
-
add_index :catpm_samples, [:kind, :recorded_at], name: 'idx_catpm_samples_kind_time'
|
|
41
|
-
add_index :catpm_samples, :error_fingerprint, name: 'idx_catpm_samples_error_fp'
|
|
42
|
-
add_index :catpm_samples, :request_id, name: 'idx_catpm_samples_request_id'
|
|
39
|
+
add_index :catpm_samples, :recorded_at, name: 'idx_catpm_samples_time', if_not_exists: true
|
|
40
|
+
add_index :catpm_samples, [:kind, :recorded_at], name: 'idx_catpm_samples_kind_time', if_not_exists: true
|
|
41
|
+
add_index :catpm_samples, :error_fingerprint, name: 'idx_catpm_samples_error_fp', if_not_exists: true
|
|
42
|
+
add_index :catpm_samples, :request_id, name: 'idx_catpm_samples_request_id', if_not_exists: true
|
|
43
43
|
|
|
44
|
-
create_table :catpm_errors do |t|
|
|
44
|
+
create_table :catpm_errors, if_not_exists: true do |t|
|
|
45
45
|
t.string :fingerprint, null: false, limit: 64
|
|
46
46
|
t.string :kind, null: false
|
|
47
47
|
t.string :error_class, null: false
|
|
@@ -55,29 +55,29 @@ class CreateCatpmTables < ActiveRecord::Migration[8.0]
|
|
|
55
55
|
t.boolean :pinned, null: false, default: false
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
add_index :catpm_errors, :fingerprint, unique: true, name: 'idx_catpm_errors_fingerprint'
|
|
59
|
-
add_index :catpm_errors, [:kind, :last_occurred_at], name: 'idx_catpm_errors_kind_time'
|
|
58
|
+
add_index :catpm_errors, :fingerprint, unique: true, name: 'idx_catpm_errors_fingerprint', if_not_exists: true
|
|
59
|
+
add_index :catpm_errors, [:kind, :last_occurred_at], name: 'idx_catpm_errors_kind_time', if_not_exists: true
|
|
60
60
|
|
|
61
|
-
create_table :catpm_event_buckets do |t|
|
|
61
|
+
create_table :catpm_event_buckets, if_not_exists: true do |t|
|
|
62
62
|
t.string :name, null: false
|
|
63
63
|
t.datetime :bucket_start, null: false
|
|
64
64
|
t.integer :count, null: false, default: 0
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
add_index :catpm_event_buckets, [:name, :bucket_start],
|
|
68
|
-
unique: true, name: 'idx_catpm_event_buckets_unique'
|
|
69
|
-
add_index :catpm_event_buckets, :bucket_start, name: 'idx_catpm_event_buckets_time'
|
|
68
|
+
unique: true, name: 'idx_catpm_event_buckets_unique', if_not_exists: true
|
|
69
|
+
add_index :catpm_event_buckets, :bucket_start, name: 'idx_catpm_event_buckets_time', if_not_exists: true
|
|
70
70
|
|
|
71
|
-
create_table :catpm_event_samples do |t|
|
|
71
|
+
create_table :catpm_event_samples, if_not_exists: true do |t|
|
|
72
72
|
t.string :name, null: false
|
|
73
73
|
t.json :payload
|
|
74
74
|
t.datetime :recorded_at, null: false
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
add_index :catpm_event_samples, [:name, :recorded_at], name: 'idx_catpm_event_samples_name_time'
|
|
78
|
-
add_index :catpm_event_samples, :recorded_at, name: 'idx_catpm_event_samples_time'
|
|
77
|
+
add_index :catpm_event_samples, [:name, :recorded_at], name: 'idx_catpm_event_samples_name_time', if_not_exists: true
|
|
78
|
+
add_index :catpm_event_samples, :recorded_at, name: 'idx_catpm_event_samples_time', if_not_exists: true
|
|
79
79
|
|
|
80
|
-
create_table :catpm_endpoint_prefs do |t|
|
|
80
|
+
create_table :catpm_endpoint_prefs, if_not_exists: true do |t|
|
|
81
81
|
t.string :kind, null: false
|
|
82
82
|
t.string :target, null: false
|
|
83
83
|
t.string :operation, null: false, default: ''
|
|
@@ -86,27 +86,29 @@ class CreateCatpmTables < ActiveRecord::Migration[8.0]
|
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
add_index :catpm_endpoint_prefs, [:kind, :target, :operation],
|
|
89
|
-
unique: true, name: 'idx_catpm_endpoint_prefs_unique'
|
|
89
|
+
unique: true, name: 'idx_catpm_endpoint_prefs_unique', if_not_exists: true
|
|
90
90
|
|
|
91
|
-
create_table :catpm_event_prefs do |t|
|
|
91
|
+
create_table :catpm_event_prefs, if_not_exists: true do |t|
|
|
92
92
|
t.string :name, null: false
|
|
93
93
|
t.boolean :pinned, null: false, default: false
|
|
94
94
|
t.boolean :ignored, null: false, default: false
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
add_index :catpm_event_prefs, :name,
|
|
98
|
-
unique: true, name: 'idx_catpm_event_prefs_unique'
|
|
98
|
+
unique: true, name: 'idx_catpm_event_prefs_unique', if_not_exists: true
|
|
99
99
|
|
|
100
100
|
if postgresql?
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
SELECT
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
101
|
+
safety_assured do
|
|
102
|
+
execute <<~SQL
|
|
103
|
+
CREATE OR REPLACE FUNCTION catpm_merge_jsonb_sums(a jsonb, b jsonb)
|
|
104
|
+
RETURNS jsonb AS $$
|
|
105
|
+
SELECT COALESCE(a, '{}'::jsonb) || (
|
|
106
|
+
SELECT jsonb_object_agg(key, COALESCE((a ->> key)::numeric, 0) + value::numeric)
|
|
107
|
+
FROM jsonb_each_text(COALESCE(b, '{}'::jsonb))
|
|
108
|
+
);
|
|
109
|
+
$$ LANGUAGE sql IMMUTABLE;
|
|
110
|
+
SQL
|
|
111
|
+
end
|
|
110
112
|
end
|
|
111
113
|
end
|
|
112
114
|
|
data/lib/catpm/call_tracer.rb
CHANGED
|
@@ -56,7 +56,8 @@ module Catpm
|
|
|
56
56
|
|
|
57
57
|
started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
58
58
|
detail = format_detail(tp.defined_class, tp.method_id)
|
|
59
|
-
|
|
59
|
+
type = Fingerprint.app_code_type(path)
|
|
60
|
+
index = @request_segments.push_span(type: type, detail: detail, started_at: started_at)
|
|
60
61
|
@call_stack.push(index)
|
|
61
62
|
end
|
|
62
63
|
|