app_pulse 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7c1aec98d66b0f9fd087644ebee850f073ea9c72c442fe1bc4bbcc786e8582f9
4
+ data.tar.gz: 2d8cf0ba73dd26124f22501824822b23cd26a93b25198a8a1363d1eae48566c9
5
+ SHA512:
6
+ metadata.gz: fbf275986ceb81b3bd263989a5993f1b58ccca8dc9b89ab531a70a8e1e5256b8346f41efcdd2b9a630f62c3e3094fae9718f74282199a42691a5d9830194a450
7
+ data.tar.gz: c95753a115e8de8cdc47c7d3c69be8d6a2a9b46507a76d00e528518a5067f4a1d22a6d8fa44f309faf75a8f2569fc35255eca232f3a18336bd32c1f3505de6ee
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.4
data/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # CHANGELOG
2
+ ## [0.1.1] – Packaging Fix
3
+
4
+ ### Fixed
5
+ - Ensure config file is included in the gem package
6
+ - Remove built `.gem` artifacts from source control
7
+ - Fix runtime load error when requiring the gem
8
+
9
+
10
+ ## [0.1.0] – Initial Release
11
+
12
+ ### Added
13
+ - Rack middleware for HTTP request lifecycle tracking
14
+ - Request duration measurement using monotonic clock
15
+ - CSV, JSON, and Text output writers
16
+ - Daily file rotation
17
+ - Configurable sampling rate
18
+ - Fault-tolerant design (never breaks host app)
19
+
20
+ ### Notes
21
+ - File-based storage only (no DB writes)
22
+ - Rails-agnostic core
23
+ - Ruby 2.3+ compatible
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at virendrajadhav.dev@gmai.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 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 copy.md ADDED
@@ -0,0 +1,39 @@
1
+ # AppPulse
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/app_pulse`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/app_pulse. 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/[USERNAME]/app_pulse/blob/master/CODE_OF_CONDUCT.md).
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
36
+
37
+ ## Code of Conduct
38
+
39
+ Everyone interacting in the AppPulse project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/app_pulse/blob/master/CODE_OF_CONDUCT.md).
data/README.md ADDED
@@ -0,0 +1,252 @@
1
+ # app_pulse
2
+
3
+ > **Lightweight request signal collection for Ruby applications**
4
+ > Collect signals today. Derive insights tomorrow.
5
+
6
+ `app_pulse` is a small, production-safe Ruby gem that tracks HTTP request lifecycle signals using Rack middleware and stores them in simple, file-based formats for offline analysis.
7
+
8
+ It is **not** an APM, **not** an optimizer, and **not** a dashboard.
9
+ It is a **signal collector**.
10
+
11
+ ---
12
+
13
+ ## Philosophy
14
+
15
+ - Collect signals, not opinions
16
+ - Be lightweight and production-safe
17
+ - Zero configuration by default
18
+ - No Rails internals in core
19
+ - No database writes
20
+ - Data first, insights later
21
+ - Extensible via future gems
22
+
23
+ `app_pulse` is designed to run quietly in production without affecting request flow.
24
+
25
+ ---
26
+
27
+ ## What app_pulse Is (and Is Not)
28
+
29
+ ### ✅ What it does
30
+ - Tracks HTTP requests via Rack middleware
31
+ - Measures request duration
32
+ - Captures status and failures
33
+ - Stores data in rotating files (CSV / JSON / Text)
34
+ - Works with Rails, Rack, Sinatra, and other Rack apps
35
+
36
+ ### ❌ What it does NOT do
37
+ - No automatic optimization
38
+ - No performance advice
39
+ - No UI or dashboard
40
+ - No DB writes
41
+ - No Rails-only behavior
42
+
43
+ ---
44
+
45
+ ## Installation
46
+
47
+ Add to your `Gemfile`:
48
+
49
+ ```ruby
50
+ gem "app_pulse"
51
+ ```
52
+
53
+ Or for local development:
54
+ ```
55
+ gem "app_pulse", path: "../app_pulse"
56
+ ```
57
+ Then run:
58
+ ```
59
+ bundle install
60
+ ```
61
+ # Basic Usage (Rails)
62
+ **1. Add middleware**
63
+ ```
64
+ # config/application.rb
65
+ config.middleware.use AppPulse::Middleware::Request
66
+ ```
67
+
68
+
69
+ That’s it.
70
+ No initializer is required unless you want custom configuration.
71
+
72
+ **2. (Optional) Configuration**
73
+ ```
74
+ # config/initializers/app_pulse.rb
75
+ AppPulse.configure do |config|
76
+ config.output_path = "log/app_pulse"
77
+ config.output_format = :csv
78
+ config.sampling_rate = 1.0
79
+ end
80
+ ```
81
+
82
+ # Basic Usage (Rack / Sinatra)
83
+ ```ruby
84
+ require "app_pulse"
85
+
86
+ AppPulse.configure do |config|
87
+ config.output_path = "log/app_pulse"
88
+ end
89
+
90
+ use AppPulse::Middleware::Request
91
+
92
+ run ->(env) {
93
+ [200, { "Content-Type" => "text/plain" }, ["OK"]]
94
+ }
95
+ ```
96
+ **Collected Signals**
97
+ For each request, app_pulse captures:
98
+ | Field | Description |
99
+ | ----------- | -------------------------------- |
100
+ | timestamp | UTC ISO-8601 timestamp |
101
+ | method | HTTP method |
102
+ | path | Request path |
103
+ | status | HTTP status code |
104
+ | duration_ms | Request duration in milliseconds |
105
+ | success | `true` if status < 500 |
106
+ | error | Error message (if any) |
107
+
108
+
109
+ **Output Formats**
110
+ CSV (default)
111
+ ```
112
+ 2026-01-10T14:35:22Z,GET,/health,200,3.2,true,
113
+ 2026-01-10T14:35:30Z,GET,/error,500,2.1,false,Boom!
114
+ ```
115
+ JSON
116
+ ```
117
+ {"timestamp":"2026-01-10T14:35:22Z","method":"GET","path":"/health","status":200,"duration_ms":3.2,"success":true,"error":null}
118
+
119
+ ```
120
+ Text
121
+ ```
122
+ timestamp=2026-01-10T14:35:22Z | method=GET | path=/health | status=200 | duration_ms=3.2 | success=true | error=
123
+
124
+ ```
125
+ **File Rotation**
126
+
127
+ - Files are rotated daily
128
+
129
+ - One file per format per day
130
+
131
+ - No file locking
132
+
133
+ - Append-only writes
134
+
135
+ Example:
136
+ ```
137
+ log/app_pulse/
138
+ ├── 2026-01-10.csv
139
+ ├── 2026-01-11.csv
140
+
141
+ ```
142
+
143
+ **Sampling**
144
+ ```
145
+ config.sampling_rate = 0.3
146
+ ```
147
+
148
+ - 1.0 → collect 100% of requests
149
+
150
+ - 0.3 → collect ~30%
151
+
152
+ - 0.1 → collect ~10%
153
+
154
+ Sampling is:
155
+
156
+ - Stateless
157
+
158
+ - Thread-safe
159
+
160
+ - Cheap
161
+
162
+ - Industry standard
163
+
164
+ #Fault Tolerance
165
+
166
+ - Errors inside app_pulse never break your app
167
+
168
+ - Writer failures are swallowed intentionally
169
+
170
+ - Application exceptions are re-raised
171
+
172
+ - Observability must never affect availability.
173
+
174
+ #Compatibility
175
+ **Ruby**
176
+
177
+ - Ruby 2.3+ (tested on 2.3.8 and modern Ruby)
178
+
179
+ - Designed to avoid modern syntax
180
+
181
+ **Frameworks**
182
+
183
+ - Rails
184
+
185
+ - Rack
186
+
187
+ - Sinatra
188
+
189
+ - Any Rack-compatible framework
190
+
191
+ **Dependencies**
192
+
193
+ - No Rails dependency in core
194
+
195
+ - No database
196
+
197
+ - No ActiveSupport
198
+
199
+ # Roadmap
200
+ **v0.1.0 (current)**
201
+
202
+ - Request lifecycle collection
203
+
204
+ - CSV / JSON / Text writers
205
+
206
+ - Rack middleware
207
+
208
+ - File-based storage
209
+
210
+ **Planned**
211
+
212
+ - v0.2.x → configurable thresholds
213
+
214
+ - v0.3.x → aggregation helpers
215
+
216
+ - v1.0 → stable observability core
217
+
218
+ **Future Extensions (separate gems)**
219
+
220
+ - `app_pulse-sql`
221
+
222
+ - `app_pulse-jobs`
223
+
224
+ - `app_pulse-exporter`
225
+
226
+ - `app_pulse-dashboard`
227
+
228
+ **Development & Testing**
229
+
230
+ - RSpec for unit tests
231
+
232
+ - Tested with:
233
+
234
+ - - Rails (modern Ruby)
235
+
236
+ - - Rack (Ruby 2.3)
237
+
238
+ - RuboCop compatible
239
+
240
+ - No CI lock-in
241
+
242
+ #License
243
+
244
+ MIT License © Virendra Jadhav
245
+
246
+ **Final Notes**
247
+
248
+ `app_pulse` is intentionally boring.
249
+
250
+ That’s a feature.
251
+
252
+ It gives you raw, trustworthy signals so you can decide what to do with them later — in reports, dashboards, or external systems.
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]
data/app_pulse.gemspec ADDED
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/app_pulse/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "app_pulse"
7
+ spec.version = AppPulse::VERSION
8
+ spec.authors = ["Virendra Jadhav"]
9
+ spec.email = ["virendrajadhav.dev@gmail.com"]
10
+
11
+ spec.summary = "Lightweight request signal collection for Ruby apps"
12
+ spec.description = "AppPulse captures application request lifecycle signals and stores them for offline analysis."
13
+ spec.homepage = "https://github.com/virendra-jadhav/app_pulse"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.3"
16
+
17
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
18
+
19
+ # spec.metadata["homepage_uri"] = spec.homepage
20
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
21
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
22
+
23
+ # # Specify which files should be added to the gem when it is released.
24
+ # # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ # spec.files = Dir.chdir(__dir__) do
26
+ # `git ls-files -z`.split("\x0").reject do |f|
27
+ # (File.expand_path(f) == __FILE__) ||
28
+ # f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
29
+ # end
30
+ # end
31
+ # spec.bindir = "exe"
32
+ # spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
+ # spec.require_paths = ["lib"]
34
+
35
+ # Uncomment to register a new dependency of your gem
36
+ # spec.add_dependency "example-gem", "~> 1.0"
37
+
38
+ # For more information and examples about making a new gem, check out our
39
+ # guide at: https://bundler.io/guides/creating_gem.html
40
+
41
+
42
+
43
+ # RubyGems metadata (used by RubyGems.org UI & tooling)
44
+ spec.metadata["homepage_uri"] = spec.homepage
45
+ spec.metadata["source_code_uri"] = "https://github.com/virendra-jadhav/app_pulse"
46
+ spec.metadata["changelog_uri"] = "https://github.com/virendra-jadhav/app_pulse/blob/main/CHANGELOG.md"
47
+
48
+ # Files included in the gem
49
+ spec.files = Dir.chdir(__dir__) do
50
+ `git ls-files -z`.split("\x0").reject do |f|
51
+ f.start_with?(
52
+ "bin/",
53
+ "test/",
54
+ "spec/",
55
+ "features/",
56
+ ".git",
57
+ ".github",
58
+ "Gemfile"
59
+ )
60
+ end
61
+ end
62
+
63
+ spec.require_paths = ["lib"]
64
+
65
+ # Development-only dependencies
66
+ spec.add_development_dependency "rspec"
67
+ spec.add_development_dependency "rubocop"
68
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "app_pulse/utils/time"
4
+ require "app_pulse/writers"
5
+
6
+ module AppPulse
7
+ module Collector
8
+ class RequestCollector
9
+ class << self
10
+ def collect(env:, status:, duration:, error: nil)
11
+ return unless sample?
12
+
13
+ data = build_payload(env, status, duration, error)
14
+ writer.write(data)
15
+ rescue
16
+ # Never break the host application
17
+ end
18
+
19
+ private
20
+
21
+ def build_payload(env, status, duration, error)
22
+ {
23
+ timestamp: Utils::Time.now_iso,
24
+ method: env["REQUEST_METHOD"],
25
+ path: env["PATH_INFO"],
26
+ status: status,
27
+ duration_ms: duration,
28
+ success: status < 500,
29
+ error: error ? error.message : nil
30
+ }
31
+ end
32
+
33
+ def writer
34
+ Writers.fetch(AppPulse.config.output_format)
35
+ end
36
+
37
+ def sample?
38
+ rand <= AppPulse.config.sampling_rate
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,17 @@
1
+ module AppPulse
2
+ class Config
3
+ attr_accessor :enabled,
4
+ :output_format,
5
+ :output_path,
6
+ :slow_threshold_ms,
7
+ :sampling_rate
8
+
9
+ def initialize
10
+ @enabled = true
11
+ @output_format = :csv
12
+ @output_path = "log/app_pulse"
13
+ @slow_threshold_ms = nil
14
+ @sampling_rate = 1.0
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "app_pulse/collectors/request_collector"
4
+
5
+ module AppPulse
6
+ module Middleware
7
+ class Request
8
+ def initialize(app)
9
+ @app = app
10
+ end
11
+
12
+ def call(env)
13
+ return @app.call(env) unless AppPulse.config.enabled
14
+
15
+ start_time = monotonic_time
16
+
17
+ status, headers, response = @app.call(env)
18
+
19
+ duration = elapsed_ms(start_time)
20
+
21
+ Collector::RequestCollector.collect(
22
+ env: env,
23
+ status: status,
24
+ duration: duration
25
+ )
26
+
27
+ [status, headers, response]
28
+ rescue => error
29
+ Collector::RequestCollector.collect(
30
+ env: env,
31
+ status: 500,
32
+ duration: elapsed_ms(start_time),
33
+ error: error
34
+ )
35
+ raise
36
+ end
37
+
38
+ private
39
+
40
+ # def monotonic_time
41
+ # Process.clock_gettime(Process::CLOCK_MONOTONIC)
42
+ # end
43
+ def monotonic_time
44
+ if Process.const_defined?(:CLOCK_MONOTONIC)
45
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
46
+ else
47
+ Time.now.to_f
48
+ end
49
+ end
50
+
51
+
52
+ def elapsed_ms(start_time)
53
+ ((monotonic_time - start_time) * 1000).round(2)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "time"
4
+
5
+ module AppPulse
6
+ module Utils
7
+ module Time
8
+ class << self
9
+ # Returns current UTC time in ISO 8601 format
10
+ # Example: "2026-01-10T14:23:45Z"
11
+ def now_iso
12
+ ::Time.now.utc.iso8601
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module AppPulse
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "date"
5
+
6
+ module AppPulse
7
+ module Writers
8
+ class BaseWriter
9
+ def write(_data)
10
+ raise NotImplementedError
11
+ end
12
+
13
+ protected
14
+
15
+ def output_dir
16
+ AppPulse.config.output_path
17
+ end
18
+
19
+ def daily_file(extension)
20
+ FileUtils.mkdir_p(output_dir)
21
+
22
+ date = Date.today.strftime("%Y-%m-%d")
23
+ File.join(output_dir, "#{date}.#{extension}")
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "csv"
4
+ require "app_pulse/writers/base_writer"
5
+
6
+ module AppPulse
7
+ module Writers
8
+ class CsvWriter < BaseWriter
9
+ def write(data)
10
+ path = daily_file("csv")
11
+
12
+ CSV.open(path, "a+") do |csv|
13
+ csv << data.values
14
+ end
15
+ rescue
16
+ # Never crash the app
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "app_pulse/writers/base_writer"
5
+
6
+ module AppPulse
7
+ module Writers
8
+ class JsonWriter < BaseWriter
9
+ def write(data)
10
+ path = daily_file("json")
11
+
12
+ File.open(path, "a+") do |file|
13
+ file.puts(JSON.generate(data))
14
+ end
15
+ rescue
16
+ # Never crash the app
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "app_pulse/writers/base_writer"
4
+
5
+ module AppPulse
6
+ module Writers
7
+ class TextWriter < BaseWriter
8
+ def write(data)
9
+ path = daily_file("txt")
10
+
11
+ File.open(path, "a+") do |file|
12
+ file.puts(data.map { |k, v| "#{k}=#{v}" }.join(" | "))
13
+ end
14
+ rescue
15
+ # Never crash the app
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "app_pulse/writers/csv_writer"
4
+ require "app_pulse/writers/json_writer"
5
+ require "app_pulse/writers/text_writer"
6
+
7
+ module AppPulse
8
+ module Writers
9
+ def self.fetch(format)
10
+ case format
11
+ when :csv
12
+ CsvWriter.new
13
+ when :json
14
+ JsonWriter.new
15
+ when :text
16
+ TextWriter.new
17
+ else
18
+ CsvWriter.new
19
+ end
20
+ end
21
+ end
22
+ end
data/lib/app_pulse.rb ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "app_pulse/version"
4
+ require "app_pulse/config"
5
+ require "app_pulse/middleware/request"
6
+
7
+ module AppPulse
8
+ class << self
9
+ def configure
10
+ yield(config)
11
+ end
12
+
13
+ def config
14
+ @config ||= Config.new
15
+ end
16
+ end
17
+ end
data/sig/app_pulse.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module AppPulse
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: app_pulse
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Virendra Jadhav
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-01-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: AppPulse captures application request lifecycle signals and stores them
42
+ for offline analysis.
43
+ email:
44
+ - virendrajadhav.dev@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".rspec"
50
+ - ".rubocop.yml"
51
+ - ".ruby-version"
52
+ - CHANGELOG.md
53
+ - CODE_OF_CONDUCT.md
54
+ - LICENSE.txt
55
+ - README copy.md
56
+ - README.md
57
+ - Rakefile
58
+ - app_pulse.gemspec
59
+ - lib/app_pulse.rb
60
+ - lib/app_pulse/collectors/request_collector.rb
61
+ - lib/app_pulse/config.rb
62
+ - lib/app_pulse/middleware/request.rb
63
+ - lib/app_pulse/utils/time.rb
64
+ - lib/app_pulse/version.rb
65
+ - lib/app_pulse/writers.rb
66
+ - lib/app_pulse/writers/base_writer.rb
67
+ - lib/app_pulse/writers/csv_writer.rb
68
+ - lib/app_pulse/writers/json_writer.rb
69
+ - lib/app_pulse/writers/text_writer.rb
70
+ - sig/app_pulse.rbs
71
+ homepage: https://github.com/virendra-jadhav/app_pulse
72
+ licenses:
73
+ - MIT
74
+ metadata:
75
+ homepage_uri: https://github.com/virendra-jadhav/app_pulse
76
+ source_code_uri: https://github.com/virendra-jadhav/app_pulse
77
+ changelog_uri: https://github.com/virendra-jadhav/app_pulse/blob/main/CHANGELOG.md
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '2.3'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubygems_version: 3.4.19
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Lightweight request signal collection for Ruby apps
97
+ test_files: []