ez_logs_agent 0.1.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 +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +57 -0
- data/CONFIGURATION.md +752 -0
- data/FAQ.md +574 -0
- data/LICENSE.txt +21 -0
- data/QUICKSTART.md +390 -0
- data/README.md +1021 -0
- data/RELEASING.md +55 -0
- data/Rakefile +8 -0
- data/lib/ez_logs_agent/actor.rb +57 -0
- data/lib/ez_logs_agent/actor_validator.rb +51 -0
- data/lib/ez_logs_agent/buffer.rb +83 -0
- data/lib/ez_logs_agent/capturers/active_job_capturer.rb +270 -0
- data/lib/ez_logs_agent/capturers/database_capturer.rb +467 -0
- data/lib/ez_logs_agent/capturers/job_capturer.rb +238 -0
- data/lib/ez_logs_agent/configuration.rb +186 -0
- data/lib/ez_logs_agent/configuration_validator.rb +139 -0
- data/lib/ez_logs_agent/correlation.rb +40 -0
- data/lib/ez_logs_agent/event_builder.rb +281 -0
- data/lib/ez_logs_agent/flush_scheduler.rb +99 -0
- data/lib/ez_logs_agent/logger.rb +62 -0
- data/lib/ez_logs_agent/middleware/http_request.rb +1094 -0
- data/lib/ez_logs_agent/railtie.rb +353 -0
- data/lib/ez_logs_agent/resource_extractor.rb +172 -0
- data/lib/ez_logs_agent/retry_sender.rb +120 -0
- data/lib/ez_logs_agent/transport.rb +91 -0
- data/lib/ez_logs_agent/version.rb +5 -0
- data/lib/ez_logs_agent.rb +42 -0
- data/lib/generators/ez_logs_agent/install/install_generator.rb +94 -0
- data/lib/generators/ez_logs_agent/install/templates/ez_logs_agent.rb.tt +128 -0
- data/lib/tasks/ez_logs_agent.rake +110 -0
- data/script/publish-to-public.sh +113 -0
- data/sig/ez_logs_agent.rbs +4 -0
- metadata +178 -0
data/QUICKSTART.md
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
# EZLogs Agent — Quick Start Guide
|
|
2
|
+
|
|
3
|
+
Get EZLogs running in your Rails application in 5 minutes.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
Before you begin, make sure you have:
|
|
10
|
+
|
|
11
|
+
- ✅ **Ruby** 3.1.0 or higher
|
|
12
|
+
- ✅ **Rails** application (any recent version)
|
|
13
|
+
- ✅ **EZLogs account** with an API key ([sign up here](https://your-ezlogs-server.com))
|
|
14
|
+
|
|
15
|
+
**Optional but supported:**
|
|
16
|
+
- Sidekiq or ActiveJob (for background job capture)
|
|
17
|
+
- ActiveRecord (for database change capture)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Step 1: Add the Gem
|
|
22
|
+
|
|
23
|
+
Add EZLogs Agent to your `Gemfile`:
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
gem 'ez_logs_agent'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Then install it:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bundle install
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Expected output:**
|
|
36
|
+
```
|
|
37
|
+
Fetching ez_logs_agent 0.1.0
|
|
38
|
+
Installing ez_logs_agent 0.1.0
|
|
39
|
+
Bundle complete!
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Step 2: Run the Generator
|
|
45
|
+
|
|
46
|
+
Generate the configuration file:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
rails generate ez_logs_agent:install
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**What this does:**
|
|
53
|
+
- Creates `config/initializers/ez_logs_agent.rb` with all available configuration options
|
|
54
|
+
- Adds helpful comments explaining each setting
|
|
55
|
+
|
|
56
|
+
**Expected output:**
|
|
57
|
+
```
|
|
58
|
+
create config/initializers/ez_logs_agent.rb
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Step 3: Get Your API Key
|
|
64
|
+
|
|
65
|
+
1. **Sign up** for EZLogs at [your-ezlogs-server.com](https://your-ezlogs-server.com)
|
|
66
|
+
2. **Create a company** (happens automatically during registration)
|
|
67
|
+
3. **Navigate to Settings** → **API Keys**
|
|
68
|
+
4. **Click "Create New API Key"**
|
|
69
|
+
5. **Copy the key** (it starts with `ezl_`)
|
|
70
|
+
|
|
71
|
+
**Important:** Keep your API key secure. Don't commit it to version control.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Step 4: Configure the Agent
|
|
76
|
+
|
|
77
|
+
Open `config/initializers/ez_logs_agent.rb` and add your credentials:
|
|
78
|
+
|
|
79
|
+
```ruby
|
|
80
|
+
EzLogsAgent.configure do |config|
|
|
81
|
+
# Required: Your EZLogs server URL
|
|
82
|
+
config.server_url = "https://your-ezlogs-server.com"
|
|
83
|
+
|
|
84
|
+
# Required: Your API key from Step 3
|
|
85
|
+
config.project_token = "ezl_your_api_key_here"
|
|
86
|
+
end
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Using Environment Variables (Recommended)
|
|
90
|
+
|
|
91
|
+
For better security, use environment variables:
|
|
92
|
+
|
|
93
|
+
```ruby
|
|
94
|
+
EzLogsAgent.configure do |config|
|
|
95
|
+
config.server_url = ENV['EZLOGS_SERVER_URL']
|
|
96
|
+
config.project_token = ENV['EZLOGS_API_KEY']
|
|
97
|
+
end
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Then set them in your environment:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# .env (for development, using dotenv gem)
|
|
104
|
+
EZLOGS_SERVER_URL=https://your-ezlogs-server.com
|
|
105
|
+
EZLOGS_API_KEY=ezl_your_api_key_here
|
|
106
|
+
|
|
107
|
+
# Production (set via your hosting platform)
|
|
108
|
+
# Heroku: heroku config:set EZLOGS_API_KEY=ezl_...
|
|
109
|
+
# Render: Set in environment variables dashboard
|
|
110
|
+
# etc.
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Note:** The configuration parameter is called `project_token`, but it's your API key from the EZLogs dashboard.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Step 5: Test the Connection
|
|
118
|
+
|
|
119
|
+
Verify everything is configured correctly:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
rails ez_logs_agent:test_connection
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### ✅ Success Output
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
[EzLogsAgent] Testing connection to https://your-ezlogs-server.com...
|
|
129
|
+
✅ Configuration is valid
|
|
130
|
+
✅ Connection successful (HTTP 200)
|
|
131
|
+
✅ Test event sent successfully
|
|
132
|
+
✅ All checks passed! EZLogs Agent is configured correctly.
|
|
133
|
+
|
|
134
|
+
Next steps:
|
|
135
|
+
1. Restart your Rails application
|
|
136
|
+
2. Visit your EZLogs dashboard
|
|
137
|
+
3. Interact with your application to generate events
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
If you see this, **you're all set!** Skip to Step 6.
|
|
141
|
+
|
|
142
|
+
### ❌ Failure Output
|
|
143
|
+
|
|
144
|
+
If the test fails, you'll see what's wrong:
|
|
145
|
+
|
|
146
|
+
**Example: Invalid API key**
|
|
147
|
+
```
|
|
148
|
+
❌ Connection failed (HTTP 401 Unauthorized)
|
|
149
|
+
|
|
150
|
+
Possible causes:
|
|
151
|
+
- Invalid API key (project_token)
|
|
152
|
+
- API key has been revoked
|
|
153
|
+
- Check your project_token in config/initializers/ez_logs_agent.rb
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Example: Server unreachable**
|
|
157
|
+
```
|
|
158
|
+
❌ Connection failed (timeout)
|
|
159
|
+
|
|
160
|
+
Possible causes:
|
|
161
|
+
- Server URL is incorrect
|
|
162
|
+
- Network connectivity issue
|
|
163
|
+
- Firewall blocking outbound HTTPS
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Fix the error** shown in the output and run the test again.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Step 6: Restart Your Application
|
|
171
|
+
|
|
172
|
+
Restart your Rails server to load the configuration:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# Stop the server (Ctrl+C)
|
|
176
|
+
# Then start it again
|
|
177
|
+
rails server
|
|
178
|
+
|
|
179
|
+
# Or for production deployments, use your platform's restart command
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Verify Initialization
|
|
183
|
+
|
|
184
|
+
Check your Rails logs for the startup message:
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
[EzLogsAgent] Agent initialized successfully
|
|
188
|
+
[EzLogsAgent] Server URL: https://your-ezlogs-server.com
|
|
189
|
+
[EzLogsAgent] ✓ HTTP capture enabled
|
|
190
|
+
[EzLogsAgent] ✓ Sidekiq capture enabled
|
|
191
|
+
[EzLogsAgent] ✓ Database capture enabled
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
If you see this, the agent is running!
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Step 7: Generate Activity
|
|
199
|
+
|
|
200
|
+
Interact with your application to generate events:
|
|
201
|
+
|
|
202
|
+
1. **Make HTTP requests** — Visit pages, submit forms, trigger API endpoints
|
|
203
|
+
2. **Run background jobs** — Trigger jobs that send emails, process data, etc.
|
|
204
|
+
3. **Change database records** — Create, update, or delete records
|
|
205
|
+
|
|
206
|
+
### Example Activities
|
|
207
|
+
|
|
208
|
+
```ruby
|
|
209
|
+
# In Rails console or by using your app
|
|
210
|
+
|
|
211
|
+
# HTTP request (if you visit a page)
|
|
212
|
+
GET /users
|
|
213
|
+
|
|
214
|
+
# Database change
|
|
215
|
+
user = User.create(email: "test@example.com")
|
|
216
|
+
|
|
217
|
+
# Background job (if configured)
|
|
218
|
+
WelcomeEmailJob.perform_later(user)
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Step 8: View Your Activity Log
|
|
224
|
+
|
|
225
|
+
1. **Open your EZLogs dashboard** at [your-ezlogs-server.com](https://your-ezlogs-server.com)
|
|
226
|
+
2. **Navigate to the Timeline** (usually the home page)
|
|
227
|
+
3. **See your activity** appear in real-time!
|
|
228
|
+
|
|
229
|
+
You should see entries like:
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
User created 'test@example.com'
|
|
233
|
+
2:34 PM, January 15, 2025
|
|
234
|
+
|
|
235
|
+
✓ User record created
|
|
236
|
+
✓ Welcome email job enqueued
|
|
237
|
+
✓ Email sent successfully
|
|
238
|
+
|
|
239
|
+
Status: Completed
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Next Steps
|
|
245
|
+
|
|
246
|
+
Congratulations! EZLogs is now capturing activity from your application.
|
|
247
|
+
|
|
248
|
+
### Enhance Your Setup
|
|
249
|
+
|
|
250
|
+
**1. Add Actor Context** (track who triggered each action)
|
|
251
|
+
|
|
252
|
+
```ruby
|
|
253
|
+
EzLogsAgent.configure do |config|
|
|
254
|
+
# ... existing config ...
|
|
255
|
+
|
|
256
|
+
config.actor_from_request = ->(env, controller) {
|
|
257
|
+
return nil unless controller.respond_to?(:current_user)
|
|
258
|
+
user = controller.current_user
|
|
259
|
+
return nil unless user
|
|
260
|
+
|
|
261
|
+
{
|
|
262
|
+
id: user.id.to_s,
|
|
263
|
+
label: user.email
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
end
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
See [README.md#actor-context](README.md#actor-context--who-triggered-this) for details.
|
|
270
|
+
|
|
271
|
+
**2. Configure Display Names** (human-readable resource identifiers)
|
|
272
|
+
|
|
273
|
+
```ruby
|
|
274
|
+
EzLogsAgent.configure do |config|
|
|
275
|
+
# ... existing config ...
|
|
276
|
+
|
|
277
|
+
config.display_name_for = {
|
|
278
|
+
"User" => :email,
|
|
279
|
+
"Product" => :name,
|
|
280
|
+
"Order" => :number
|
|
281
|
+
}
|
|
282
|
+
end
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
See [README.md#display-names](README.md#display-names--human-readable-resource-identifiers) for details.
|
|
286
|
+
|
|
287
|
+
**3. Exclude Sensitive Paths**
|
|
288
|
+
|
|
289
|
+
```ruby
|
|
290
|
+
EzLogsAgent.configure do |config|
|
|
291
|
+
# ... existing config ...
|
|
292
|
+
|
|
293
|
+
config.excluded_paths = ["/admin*", "/internal*"]
|
|
294
|
+
end
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
**4. Customize What Gets Captured**
|
|
298
|
+
|
|
299
|
+
```ruby
|
|
300
|
+
EzLogsAgent.configure do |config|
|
|
301
|
+
# ... existing config ...
|
|
302
|
+
|
|
303
|
+
# Disable specific capture types if needed
|
|
304
|
+
config.capture_http = true # HTTP requests
|
|
305
|
+
config.capture_jobs = true # Background jobs
|
|
306
|
+
config.capture_database = true # Database changes
|
|
307
|
+
end
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Full Configuration Reference
|
|
311
|
+
|
|
312
|
+
See [CONFIGURATION.md](CONFIGURATION.md) for all available options.
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## Troubleshooting
|
|
317
|
+
|
|
318
|
+
### Events Not Showing Up
|
|
319
|
+
|
|
320
|
+
1. **Run the connection test:**
|
|
321
|
+
```bash
|
|
322
|
+
rails ez_logs_agent:test_connection
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
2. **Check Rails logs** for agent messages:
|
|
326
|
+
```
|
|
327
|
+
[EzLogsAgent] Sending batch of 5 events...
|
|
328
|
+
[EzLogsAgent] Batch sent successfully (HTTP 200)
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
3. **Enable debug logging:**
|
|
332
|
+
```ruby
|
|
333
|
+
# config/initializers/ez_logs_agent.rb
|
|
334
|
+
config.log_level = :debug
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Common Issues
|
|
338
|
+
|
|
339
|
+
| Problem | Solution |
|
|
340
|
+
|---------|----------|
|
|
341
|
+
| HTTP 401 errors | API key is invalid or revoked. Get a new key from dashboard. |
|
|
342
|
+
| Connection timeout | Check `server_url` is correct and server is reachable. |
|
|
343
|
+
| No events captured | Verify Rails is restarted after configuration changes. |
|
|
344
|
+
| Jobs not captured | Ensure Sidekiq middleware is registered (check logs for `[Railtie] Sidekiq server middleware registered`). |
|
|
345
|
+
|
|
346
|
+
**For more help:** See [README.md#troubleshooting](README.md#troubleshooting)
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## FAQ
|
|
351
|
+
|
|
352
|
+
### Do I need to modify my application code?
|
|
353
|
+
|
|
354
|
+
**No.** EZLogs Agent self-configures via Rails Railtie. Just add the gem, configure it, and restart. No code changes needed.
|
|
355
|
+
|
|
356
|
+
### Will this slow down my application?
|
|
357
|
+
|
|
358
|
+
**No.** Event capture happens asynchronously. Events are buffered in memory and sent in background threads. Zero latency added to requests.
|
|
359
|
+
|
|
360
|
+
### What if the EZLogs server is down?
|
|
361
|
+
|
|
362
|
+
**Your app continues normally.** Events are retried a few times, then dropped. The agent never blocks or crashes your application.
|
|
363
|
+
|
|
364
|
+
### Is my data secure?
|
|
365
|
+
|
|
366
|
+
**Yes.** Events are sent over HTTPS with Bearer token authentication. Data is scoped to your company with complete isolation.
|
|
367
|
+
|
|
368
|
+
### Can I use this in production?
|
|
369
|
+
|
|
370
|
+
**Yes.** EZLogs Agent is production-ready with 685+ tests and comprehensive error handling. It's designed to be invisible to your application.
|
|
371
|
+
|
|
372
|
+
### How much does it cost?
|
|
373
|
+
|
|
374
|
+
See pricing at [your-ezlogs-server.com/pricing](https://your-ezlogs-server.com/pricing)
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
## Support
|
|
379
|
+
|
|
380
|
+
- **Documentation:** [README.md](README.md)
|
|
381
|
+
- **Configuration:** [CONFIGURATION.md](CONFIGURATION.md)
|
|
382
|
+
- **FAQ:** [FAQ.md](FAQ.md)
|
|
383
|
+
- **Issues:** [GitHub Issues](https://github.com/your-org/ez_logs/issues)
|
|
384
|
+
- **Email:** support@ezlogs.com
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
**You're all set! 🎉**
|
|
389
|
+
|
|
390
|
+
Your application is now sending activity to EZLogs. Everyone on your team can now understand what's happening in your system—no engineer required.
|