rails-profiler 0.8.0 → 0.9.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/app/assets/builds/profiler.js +14 -6
- data/lib/profiler/collectors/flamegraph_collector.rb +11 -0
- data/lib/profiler/version.rb +1 -1
- data/lib/profiler.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1530091bc78596f3f4b410c27e7ab7d8ff332c644ea345b6f7e6819a9e87fc62
|
|
4
|
+
data.tar.gz: a733275e9bf99ed4300d85b7fa4a4f88f0249705f3183ead0956bb75a51b6562
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 492ed61fe90adb99887d0c981010af043f10a645202944f0a0250776c27d5e22c83f0547eaf74cd0829aac02329237701bfd3da365f56b61dfe0cba62e0181c8
|
|
7
|
+
data.tar.gz: 7da1fce0f77cd22f69a42e1cb837dcef63b3a20d26e4c42c95cd193eb3bf0d6b31cb84095d4f64c77fbf4404320485289aa0225a1c3fff9e2debc42f1d49a495
|
|
@@ -1647,7 +1647,8 @@
|
|
|
1647
1647
|
partial: "#f59e0b",
|
|
1648
1648
|
sql: "#fb923c",
|
|
1649
1649
|
cache: "#a78bfa",
|
|
1650
|
-
http: "#f87171"
|
|
1650
|
+
http: "#f87171",
|
|
1651
|
+
custom: "#e879f9"
|
|
1651
1652
|
};
|
|
1652
1653
|
var FRAME_HEIGHT = 24;
|
|
1653
1654
|
var FRAME_GAP = 1;
|
|
@@ -2012,7 +2013,8 @@
|
|
|
2012
2013
|
partial: "Partial",
|
|
2013
2014
|
sql: "SQL",
|
|
2014
2015
|
cache: "Cache",
|
|
2015
|
-
http: "HTTP"
|
|
2016
|
+
http: "HTTP",
|
|
2017
|
+
custom: "Custom"
|
|
2016
2018
|
};
|
|
2017
2019
|
var CATEGORY_COLORS2 = {
|
|
2018
2020
|
controller: "#60a5fa",
|
|
@@ -2020,7 +2022,8 @@
|
|
|
2020
2022
|
partial: "#f59e0b",
|
|
2021
2023
|
sql: "#fb923c",
|
|
2022
2024
|
cache: "#a78bfa",
|
|
2023
|
-
http: "#f87171"
|
|
2025
|
+
http: "#f87171",
|
|
2026
|
+
custom: "#e879f9"
|
|
2024
2027
|
};
|
|
2025
2028
|
var FlameGraphTooltip = class {
|
|
2026
2029
|
constructor(container, totalDuration) {
|
|
@@ -2067,6 +2070,9 @@
|
|
|
2067
2070
|
payloadText = `Key: ${node.payload.key}`;
|
|
2068
2071
|
} else if (category === "http" && node.payload.url) {
|
|
2069
2072
|
payloadText = node.payload.url;
|
|
2073
|
+
} else if (category === "custom" && Object.keys(node.payload).length > 0) {
|
|
2074
|
+
const entries = Object.entries(node.payload).map(([k3, v3]) => `${k3}: ${JSON.stringify(v3)}`).join("\n");
|
|
2075
|
+
payloadText = entries.length > 200 ? entries.slice(0, 200) + "..." : entries;
|
|
2070
2076
|
}
|
|
2071
2077
|
if (payloadText) {
|
|
2072
2078
|
const payloadDiv = document.createElement("div");
|
|
@@ -2148,7 +2154,8 @@
|
|
|
2148
2154
|
partial: "#f59e0b",
|
|
2149
2155
|
sql: "#fb923c",
|
|
2150
2156
|
cache: "#a78bfa",
|
|
2151
|
-
http: "#f87171"
|
|
2157
|
+
http: "#f87171",
|
|
2158
|
+
custom: "#e879f9"
|
|
2152
2159
|
};
|
|
2153
2160
|
var CATEGORY_LABELS2 = {
|
|
2154
2161
|
controller: "Controller",
|
|
@@ -2156,7 +2163,8 @@
|
|
|
2156
2163
|
partial: "Partial",
|
|
2157
2164
|
sql: "SQL",
|
|
2158
2165
|
cache: "Cache",
|
|
2159
|
-
http: "HTTP"
|
|
2166
|
+
http: "HTTP",
|
|
2167
|
+
custom: "Custom"
|
|
2160
2168
|
};
|
|
2161
2169
|
function FlameGraphTab({ flamegraphData, perfData }) {
|
|
2162
2170
|
const canvasRef = A2(null);
|
|
@@ -3019,7 +3027,7 @@
|
|
|
3019
3027
|
] }),
|
|
3020
3028
|
/* @__PURE__ */ u3("div", { class: "profiler-p-4 tab-content active", children: [
|
|
3021
3029
|
activeTab === "job" && /* @__PURE__ */ u3(JobTab, { jobData: cd["job"] }),
|
|
3022
|
-
activeTab === "database" && /* @__PURE__ */ u3(DatabaseTab, { dbData: cd["database"] }),
|
|
3030
|
+
activeTab === "database" && /* @__PURE__ */ u3(DatabaseTab, { dbData: cd["database"], token: profile.token }),
|
|
3023
3031
|
activeTab === "cache" && /* @__PURE__ */ u3(CacheTab, { cacheData: cd["cache"] }),
|
|
3024
3032
|
activeTab === "http" && /* @__PURE__ */ u3(HttpTab, { httpData: cd["http"] })
|
|
3025
3033
|
] })
|
|
@@ -109,6 +109,17 @@ module Profiler
|
|
|
109
109
|
end
|
|
110
110
|
end
|
|
111
111
|
|
|
112
|
+
# Called by Profiler.measure to record custom instrumentation events
|
|
113
|
+
def record_custom_event(label:, started_at:, finished_at:, metadata: {})
|
|
114
|
+
@events << Models::TimelineEvent.new(
|
|
115
|
+
name: label,
|
|
116
|
+
started_at: started_at,
|
|
117
|
+
finished_at: finished_at,
|
|
118
|
+
category: "custom",
|
|
119
|
+
payload: metadata
|
|
120
|
+
)
|
|
121
|
+
end
|
|
122
|
+
|
|
112
123
|
# Called by NetHttpInstrumentation to record outbound HTTP events
|
|
113
124
|
def record_http_event(started_at:, finished_at:, url:, method:, status:)
|
|
114
125
|
@events << Models::TimelineEvent.new(
|
data/lib/profiler/version.rb
CHANGED
data/lib/profiler.rb
CHANGED
|
@@ -25,6 +25,28 @@ module Profiler
|
|
|
25
25
|
configuration.enabled
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
# Instrument an arbitrary code block and record it in the FlameGraph.
|
|
29
|
+
# Usage: Profiler.measure("payment.stripe_charge", metadata: { amount: 1000 }) { Stripe::Charge.create(...) }
|
|
30
|
+
def measure(label, metadata: {}, &block)
|
|
31
|
+
return yield unless enabled?
|
|
32
|
+
|
|
33
|
+
collector = Thread.current[:profiler_flamegraph_collector]
|
|
34
|
+
return yield unless collector
|
|
35
|
+
|
|
36
|
+
started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
37
|
+
result = yield
|
|
38
|
+
finished_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
39
|
+
|
|
40
|
+
collector.record_custom_event(
|
|
41
|
+
label: label,
|
|
42
|
+
started_at: started_at,
|
|
43
|
+
finished_at: finished_at,
|
|
44
|
+
metadata: metadata
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
result
|
|
48
|
+
end
|
|
49
|
+
|
|
28
50
|
# Dump a variable to the profiler
|
|
29
51
|
# Usage: Profiler.dump(variable, "optional label")
|
|
30
52
|
def dump(value, label = nil)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails-profiler
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sébastien Duplessy
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-04-
|
|
11
|
+
date: 2026-04-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|