dead_bro 0.2.22 → 0.2.23
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/FEATURES.md +333 -0
- data/lib/dead_bro/collectors/jobs.rb +0 -21
- data/lib/dead_bro/collectors/process_info.rb +1 -8
- data/lib/dead_bro/collectors/sample_store.rb +1 -9
- data/lib/dead_bro/configuration.rb +16 -0
- data/lib/dead_bro/job_subscriber.rb +2 -14
- data/lib/dead_bro/monitor.rb +1 -8
- data/lib/dead_bro/subscriber.rb +2 -14
- data/lib/dead_bro/version.rb +1 -1
- data/lib/dead_bro.rb +8 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7d17b4a0fa119f9917bfdf77cc66078019bf72e87ca5c2752183b9e3b85629f5
|
|
4
|
+
data.tar.gz: 26bec0d029e000bd2ecff843ca242b8647862bf39727b31cef6408baa871cd13
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 97c4aba35a1f39c680d8445a9a31dc3ae35d9e0ea29b89eee0f3f9740086db8de498b810d7e38171665106d9f8ff3d15caaef47cbc257c6d39bea31da2852d64
|
|
7
|
+
data.tar.gz: 321aee532718f23c430a81fdec50ab3d27fe5373e02fab0f1598e884d3d0d02b10d175691d1ec08d0bffde97a0cbb5e7488d1b0125d29b6552009921c2dba4e2
|
data/FEATURES.md
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
# ApmBro Feature List
|
|
2
|
+
|
|
3
|
+
A comprehensive feature list for comparing ApmBro with other APM (Application Performance Monitoring) tools.
|
|
4
|
+
|
|
5
|
+
## Core Architecture
|
|
6
|
+
|
|
7
|
+
- **Rails Integration**: Automatic subscription to Rails events via ActiveSupport::Notifications
|
|
8
|
+
- **Zero-Configuration Setup**: Works out of the box with minimal configuration
|
|
9
|
+
- **Asynchronous Metrics Posting**: Non-blocking HTTP requests using background threads
|
|
10
|
+
- **Thread-Local Storage**: Per-request metric collection using thread-local variables
|
|
11
|
+
- **Circuit Breaker Pattern**: Built-in circuit breaker to prevent cascading failures when APM endpoint is down
|
|
12
|
+
- **Deploy Tracking**: Automatic deploy ID resolution from multiple sources (Rails settings, ENV vars, Heroku, Git)
|
|
13
|
+
|
|
14
|
+
## Request Tracking
|
|
15
|
+
|
|
16
|
+
### Controller Action Monitoring
|
|
17
|
+
- **Automatic Tracking**: Tracks all controller actions automatically
|
|
18
|
+
- **Request Duration**: Measures total request processing time
|
|
19
|
+
- **HTTP Method & Path**: Captures HTTP method and request path
|
|
20
|
+
- **Status Codes**: Tracks HTTP response status codes
|
|
21
|
+
- **View Runtime**: Separate tracking of view rendering time
|
|
22
|
+
- **Database Runtime**: Separate tracking of database query time
|
|
23
|
+
- **Request Parameters**: Captures request parameters (with sensitive data filtering)
|
|
24
|
+
- **User Agent**: Tracks user agent strings
|
|
25
|
+
- **User ID Extraction**: Extracts authenticated user ID (supports Warden)
|
|
26
|
+
- **Environment Context**: Tracks Rails environment (development, staging, production)
|
|
27
|
+
|
|
28
|
+
### Request Sampling
|
|
29
|
+
- **Configurable Sample Rate**: Percentage-based sampling (1-100%)
|
|
30
|
+
- **Random Sampling**: Each request has random chance of being tracked
|
|
31
|
+
- **Consistent Per-Request**: Sampling decision applies to all metrics for a request
|
|
32
|
+
- **Error Override**: Errors are always tracked regardless of sampling
|
|
33
|
+
- **Cost Optimization**: Reduces data volume and costs for high-traffic applications
|
|
34
|
+
|
|
35
|
+
### Exclusion Rules
|
|
36
|
+
- **Controller Exclusion**: Exclude entire controllers from tracking
|
|
37
|
+
- **Action Exclusion**: Exclude specific controller#action combinations
|
|
38
|
+
- **Wildcard Support**: Pattern matching with `*` wildcards (e.g., `Admin::*`, `Admin::*#*`)
|
|
39
|
+
- **Job Exclusion**: Exclude specific background jobs from tracking
|
|
40
|
+
- **Flexible Configuration**: Configure via initializer, Rails settings, or environment variables
|
|
41
|
+
|
|
42
|
+
## SQL Query Tracking
|
|
43
|
+
|
|
44
|
+
### Query Details
|
|
45
|
+
- **Full SQL Tracking**: Captures all SQL queries executed during requests and jobs
|
|
46
|
+
- **Query Sanitization**: Automatically sanitizes SQL to remove sensitive data
|
|
47
|
+
- **Query Name**: Tracks query names (e.g., "User Load", "User Update")
|
|
48
|
+
- **Duration Measurement**: Precise query execution time in milliseconds
|
|
49
|
+
- **Cache Detection**: Identifies cached queries
|
|
50
|
+
- **Connection ID**: Tracks database connection ID
|
|
51
|
+
- **Call Stack Traces**: Full backtrace showing where queries were executed
|
|
52
|
+
- **Object Allocations**: Optional tracking of object allocations per query
|
|
53
|
+
|
|
54
|
+
### Query Performance Analysis
|
|
55
|
+
- **Slow Query Detection**: Configurable threshold for identifying slow queries
|
|
56
|
+
- **EXPLAIN ANALYZE**: Automatic execution plan capture for slow queries
|
|
57
|
+
- **Background Execution**: EXPLAIN ANALYZE runs in separate thread (non-blocking)
|
|
58
|
+
- **Multi-Database Support**: Works with PostgreSQL, MySQL, SQLite, and others
|
|
59
|
+
- **Smart Filtering**: Automatically skips transaction queries (BEGIN, COMMIT, ROLLBACK)
|
|
60
|
+
- **Execution Plan Details**:
|
|
61
|
+
- PostgreSQL: Full EXPLAIN ANALYZE with buffer usage statistics
|
|
62
|
+
- MySQL: EXPLAIN ANALYZE with actual execution times
|
|
63
|
+
- SQLite: EXPLAIN QUERY PLAN output
|
|
64
|
+
- **Query Optimization Insights**: Helps identify missing indexes, full table scans, JOIN issues
|
|
65
|
+
|
|
66
|
+
## View Rendering Tracking
|
|
67
|
+
|
|
68
|
+
### View Performance
|
|
69
|
+
- **Template Rendering**: Tracks main template rendering
|
|
70
|
+
- **Partial Rendering**: Tracks partial template rendering with cache key information
|
|
71
|
+
- **Collection Rendering**: Tracks collection rendering (partials in loops)
|
|
72
|
+
- **Rendering Duration**: Precise timing for each view component
|
|
73
|
+
- **Virtual Path Tracking**: Tracks view virtual paths
|
|
74
|
+
- **Layout Information**: Captures layout usage
|
|
75
|
+
|
|
76
|
+
### View Analysis
|
|
77
|
+
- **Slow View Detection**: Identifies the slowest rendering views
|
|
78
|
+
- **Frequency Analysis**: Tracks most frequently rendered views
|
|
79
|
+
- **Cache Hit Rate**: Calculates cache hit rates for partials
|
|
80
|
+
- **Collection Cache Analysis**: Tracks cache hit rates for collection rendering
|
|
81
|
+
- **Performance Metrics**:
|
|
82
|
+
- Total views rendered per request
|
|
83
|
+
- Total view rendering duration
|
|
84
|
+
- Average view rendering duration
|
|
85
|
+
- Breakdown by view type (template, partial, collection)
|
|
86
|
+
|
|
87
|
+
## Memory Tracking & Leak Detection
|
|
88
|
+
|
|
89
|
+
### Lightweight Memory Tracking (Default)
|
|
90
|
+
- **Memory Usage Monitoring**: Tracks memory consumption per request using GC stats
|
|
91
|
+
- **Memory Growth Tracking**: Measures memory growth during request processing
|
|
92
|
+
- **GC Statistics**: Tracks garbage collection count and heap pages
|
|
93
|
+
- **Minimal Performance Impact**: ~0.1ms overhead per request
|
|
94
|
+
- **Memory Before/After**: Captures memory state at request start and end
|
|
95
|
+
|
|
96
|
+
### Detailed Allocation Tracking (Optional)
|
|
97
|
+
- **Object Allocation Tracking**: Detailed tracking of object allocations (disabled by default)
|
|
98
|
+
- **Allocation Sampling**: Configurable sampling rate for allocations
|
|
99
|
+
- **Large Object Detection**: Identifies objects larger than 1MB threshold
|
|
100
|
+
- **Memory Snapshots**: Periodic memory snapshots during request processing
|
|
101
|
+
- **Object Count Tracking**: Tracks object counts before and after requests
|
|
102
|
+
- **Performance Impact**: ~2-5ms overhead per request (only when enabled)
|
|
103
|
+
|
|
104
|
+
### Memory Leak Detection
|
|
105
|
+
- **Pattern Detection**: Detects growing memory patterns over time
|
|
106
|
+
- **GC Efficiency Analysis**: Monitors garbage collection effectiveness
|
|
107
|
+
- **Heap Page Tracking**: Tracks heap page growth
|
|
108
|
+
- **Request Correlation**: Correlates memory growth with specific controllers/actions
|
|
109
|
+
|
|
110
|
+
## Background Job Tracking
|
|
111
|
+
|
|
112
|
+
### Job Execution Monitoring
|
|
113
|
+
- **ActiveJob Integration**: Automatic tracking when ActiveJob is available
|
|
114
|
+
- **Job Class Tracking**: Tracks job class names
|
|
115
|
+
- **Job ID**: Captures unique job identifiers
|
|
116
|
+
- **Queue Name**: Tracks which queue processed the job
|
|
117
|
+
- **Job Arguments**: Captures job arguments (with sensitive data filtering)
|
|
118
|
+
- **Duration Measurement**: Precise job execution time in milliseconds
|
|
119
|
+
- **Status Tracking**: Tracks job status (completed or failed)
|
|
120
|
+
|
|
121
|
+
### Job Error Tracking
|
|
122
|
+
- **Exception Capture**: Captures exceptions from failed jobs
|
|
123
|
+
- **Exception Class**: Tracks exception class names
|
|
124
|
+
- **Exception Messages**: Captures exception messages (truncated to 1000 chars)
|
|
125
|
+
- **Backtraces**: Full exception backtraces (first 50 lines)
|
|
126
|
+
- **SQL Query Context**: Includes SQL queries executed during failed jobs
|
|
127
|
+
- **Memory Context**: Includes memory usage during job execution
|
|
128
|
+
|
|
129
|
+
### Job SQL Tracking
|
|
130
|
+
- **SQL Query Tracking**: Tracks all SQL queries executed during job processing
|
|
131
|
+
- **Query Details**: Same detailed SQL tracking as request tracking
|
|
132
|
+
- **Query Context**: Full context of database operations in background jobs
|
|
133
|
+
|
|
134
|
+
## Cache Tracking
|
|
135
|
+
|
|
136
|
+
### Cache Operations
|
|
137
|
+
- **Read Operations**: Tracks cache read operations
|
|
138
|
+
- **Write Operations**: Tracks cache write operations
|
|
139
|
+
- **Delete Operations**: Tracks cache delete operations
|
|
140
|
+
- **Existence Checks**: Tracks cache existence checks
|
|
141
|
+
- **Fetch Operations**: Tracks cache fetch with hit/miss detection
|
|
142
|
+
- **Multi-Read Operations**: Tracks cache read_multi operations
|
|
143
|
+
- **Multi-Write Operations**: Tracks cache write_multi operations
|
|
144
|
+
- **Cache Generation**: Tracks cache generation events
|
|
145
|
+
|
|
146
|
+
### Cache Analysis
|
|
147
|
+
- **Cache Hit Detection**: Identifies cache hits vs misses
|
|
148
|
+
- **Cache Key Tracking**: Tracks cache keys (truncated to 200 chars)
|
|
149
|
+
- **Store Information**: Identifies which cache store was used
|
|
150
|
+
- **Namespace Tracking**: Tracks cache namespaces
|
|
151
|
+
- **Duration Measurement**: Precise timing for each cache operation
|
|
152
|
+
- **Hit Rate Calculation**: Calculates cache hit rates per request
|
|
153
|
+
|
|
154
|
+
## Redis Tracking
|
|
155
|
+
|
|
156
|
+
### Redis Command Tracking
|
|
157
|
+
- **Command Monitoring**: Tracks all Redis commands executed
|
|
158
|
+
- **Command Name**: Captures Redis command names (GET, SET, etc.)
|
|
159
|
+
- **Key Tracking**: Tracks Redis keys (truncated to 200 chars)
|
|
160
|
+
- **Argument Count**: Tracks number of arguments per command
|
|
161
|
+
- **Database Selection**: Tracks which Redis database is used
|
|
162
|
+
- **Duration Measurement**: Precise timing for each Redis command
|
|
163
|
+
- **Error Tracking**: Captures Redis command errors
|
|
164
|
+
|
|
165
|
+
### Advanced Redis Features
|
|
166
|
+
- **Pipeline Support**: Tracks Redis pipeline operations with command counts
|
|
167
|
+
- **Multi/Transaction Support**: Tracks Redis MULTI/EXEC transactions
|
|
168
|
+
- **ActiveSupport Integration**: Subscribes to ActiveSupport::Notifications for Redis events
|
|
169
|
+
- **Client Instrumentation**: Direct instrumentation of Redis::Client for comprehensive coverage
|
|
170
|
+
|
|
171
|
+
## Error Tracking
|
|
172
|
+
|
|
173
|
+
### Exception Handling
|
|
174
|
+
- **Automatic Exception Capture**: Captures exceptions from controller actions
|
|
175
|
+
- **Exception Class**: Tracks exception class names
|
|
176
|
+
- **Exception Messages**: Captures exception messages (truncated to 1000 chars)
|
|
177
|
+
- **Full Backtraces**: Captures complete exception backtraces (first 50 lines)
|
|
178
|
+
- **Request Context**: Includes full request context with exceptions
|
|
179
|
+
- **Error Flagging**: Errors are marked and always tracked (even with sampling)
|
|
180
|
+
|
|
181
|
+
### Error Context
|
|
182
|
+
- **Controller/Action**: Identifies where the error occurred
|
|
183
|
+
- **Request Parameters**: Includes request parameters at time of error
|
|
184
|
+
- **User Information**: Includes user ID if available
|
|
185
|
+
- **SQL Queries**: Includes SQL queries executed before error
|
|
186
|
+
- **Memory State**: Includes memory usage at time of error
|
|
187
|
+
- **Log Messages**: Includes application logs captured during request
|
|
188
|
+
|
|
189
|
+
## HTTP Instrumentation
|
|
190
|
+
|
|
191
|
+
### Outgoing HTTP Tracking
|
|
192
|
+
- **HTTP Request Tracking**: Tracks outgoing HTTP requests (via middleware)
|
|
193
|
+
- **Request Context**: Captures HTTP request details
|
|
194
|
+
- **Response Context**: Captures HTTP response details
|
|
195
|
+
- **Duration Measurement**: Tracks HTTP request duration
|
|
196
|
+
|
|
197
|
+
## Configuration & Flexibility
|
|
198
|
+
|
|
199
|
+
### Configuration Options
|
|
200
|
+
- **API Key Management**: Multiple sources (config, Rails credentials, ENV)
|
|
201
|
+
- **Endpoint Configuration**: Configurable endpoint URL
|
|
202
|
+
- **Timeout Settings**: Configurable open and read timeouts
|
|
203
|
+
- **Enable/Disable Toggle**: Can be enabled/disabled via configuration
|
|
204
|
+
- **Environment Detection**: Automatic Rails environment detection
|
|
205
|
+
|
|
206
|
+
### Circuit Breaker Configuration
|
|
207
|
+
- **Failure Threshold**: Configurable failure threshold (default: 3)
|
|
208
|
+
- **Recovery Timeout**: Configurable recovery timeout (default: 60 seconds)
|
|
209
|
+
- **Retry Timeout**: Configurable retry timeout (default: 300 seconds)
|
|
210
|
+
- **Enable/Disable**: Can enable/disable circuit breaker
|
|
211
|
+
|
|
212
|
+
### Memory Tracking Configuration
|
|
213
|
+
- **Memory Tracking Toggle**: Enable/disable memory tracking
|
|
214
|
+
- **Allocation Tracking Toggle**: Enable/disable detailed allocation tracking
|
|
215
|
+
- **Sampling Configuration**: Configurable request sampling rate
|
|
216
|
+
|
|
217
|
+
### Query Analysis Configuration
|
|
218
|
+
- **Slow Query Threshold**: Configurable threshold in milliseconds (default: 500ms)
|
|
219
|
+
- **EXPLAIN ANALYZE Toggle**: Enable/disable automatic EXPLAIN ANALYZE
|
|
220
|
+
|
|
221
|
+
## Data Safety & Privacy
|
|
222
|
+
|
|
223
|
+
### Data Sanitization
|
|
224
|
+
- **SQL Sanitization**: Automatically sanitizes SQL queries
|
|
225
|
+
- **Parameter Filtering**: Filters sensitive parameters (password, token, secret, key)
|
|
226
|
+
- **Argument Truncation**: Limits and truncates job arguments
|
|
227
|
+
- **Key Truncation**: Truncates cache and Redis keys to 200 characters
|
|
228
|
+
- **Value Truncation**: Recursively truncates nested values to prevent huge payloads
|
|
229
|
+
- **String Limits**: Limits string values (e.g., user agent to 200 chars, messages to 1000 chars)
|
|
230
|
+
|
|
231
|
+
### Data Limits
|
|
232
|
+
- **Array Limits**: Limits array sizes (e.g., first 10 job arguments, first 5 array elements)
|
|
233
|
+
- **Hash Limits**: Limits hash key counts (e.g., first 20 hash keys, first 30 params)
|
|
234
|
+
- **Backtrace Limits**: Limits backtraces to first 50 lines
|
|
235
|
+
- **Allocation Limits**: Limits allocations tracked per request (max 1000)
|
|
236
|
+
|
|
237
|
+
## Performance & Reliability
|
|
238
|
+
|
|
239
|
+
### Performance Optimizations
|
|
240
|
+
- **Asynchronous Posting**: Non-blocking HTTP requests
|
|
241
|
+
- **Lightweight Default Mode**: Minimal overhead in default configuration
|
|
242
|
+
- **Sampling Support**: Reduces data volume for high-traffic applications
|
|
243
|
+
- **Thread-Local Storage**: Efficient per-request data collection
|
|
244
|
+
- **Background EXPLAIN**: EXPLAIN ANALYZE runs in background thread
|
|
245
|
+
|
|
246
|
+
### Reliability Features
|
|
247
|
+
- **Circuit Breaker**: Prevents cascading failures
|
|
248
|
+
- **Error Handling**: Comprehensive error handling to prevent instrumentation failures
|
|
249
|
+
- **Graceful Degradation**: Continues working even if some features fail
|
|
250
|
+
- **Timeout Protection**: Configurable timeouts prevent hanging requests
|
|
251
|
+
|
|
252
|
+
## Integration & Compatibility
|
|
253
|
+
|
|
254
|
+
### Framework Support
|
|
255
|
+
- **Rails Integration**: Full Rails integration via Railtie
|
|
256
|
+
- **ActiveSupport Notifications**: Uses ActiveSupport::Notifications for event subscription
|
|
257
|
+
- **ActiveRecord Integration**: Tracks ActiveRecord SQL queries
|
|
258
|
+
- **ActiveJob Integration**: Tracks ActiveJob background jobs
|
|
259
|
+
- **ActionView Integration**: Tracks ActionView rendering
|
|
260
|
+
|
|
261
|
+
### Database Support
|
|
262
|
+
- **PostgreSQL**: Full support with EXPLAIN ANALYZE
|
|
263
|
+
- **MySQL**: Full support with EXPLAIN ANALYZE
|
|
264
|
+
- **SQLite**: Full support with EXPLAIN QUERY PLAN
|
|
265
|
+
- **Other Databases**: Basic support with standard EXPLAIN
|
|
266
|
+
|
|
267
|
+
### Cache Store Support
|
|
268
|
+
- **All Cache Stores**: Works with any Rails cache store
|
|
269
|
+
- **Multi-Store Support**: Tracks cache operations across different stores
|
|
270
|
+
|
|
271
|
+
### Redis Support
|
|
272
|
+
- **Redis Gem**: Works with redis gem
|
|
273
|
+
- **Client Instrumentation**: Direct instrumentation of Redis::Client
|
|
274
|
+
- **Pipeline Support**: Tracks Redis pipelines
|
|
275
|
+
- **Transaction Support**: Tracks Redis MULTI/EXEC transactions
|
|
276
|
+
|
|
277
|
+
## Logging & Debugging
|
|
278
|
+
|
|
279
|
+
### Application Logging
|
|
280
|
+
- **Log Capture**: Captures application logs during request processing
|
|
281
|
+
- **Log Context**: Includes logs in metric payloads
|
|
282
|
+
- **Debug Logging**: Optional debug logging for skipped requests
|
|
283
|
+
|
|
284
|
+
## Deployment & Environment
|
|
285
|
+
|
|
286
|
+
### Deploy Tracking
|
|
287
|
+
- **Deploy ID Resolution**: Multiple sources for deploy identification (`Configuration#deploy_id=` wins when set, then ENV in `Configuration::DEPLOY_REVISION_ENV_KEYS` order—including `DEAD_BRO_DEPLOY_ID`, git/CI vars, `DD_VERSION`, etc.), otherwise a **per-process UUID** (fine for single dyno/process; unusable alone for fleets like ECS replicas)
|
|
288
|
+
- **Revision Tracking**: Includes deploy/revision ID in all metric payloads
|
|
289
|
+
|
|
290
|
+
### Environment Support
|
|
291
|
+
- **Rails Environment**: Automatic Rails environment detection
|
|
292
|
+
- **Rack Environment**: Fallback to RACK_ENV or RAILS_ENV
|
|
293
|
+
- **Environment Context**: Includes environment in all metric payloads
|
|
294
|
+
|
|
295
|
+
## Data Collection & Transmission
|
|
296
|
+
|
|
297
|
+
### Metric Payload Structure
|
|
298
|
+
- **Structured Data**: Well-structured JSON payloads
|
|
299
|
+
- **Event Names**: Descriptive event names for different metric types
|
|
300
|
+
- **Timestamp Tracking**: ISO8601 timestamps for all metrics
|
|
301
|
+
- **Metadata**: Rich metadata including environment, host, deploy ID
|
|
302
|
+
|
|
303
|
+
### HTTP Client
|
|
304
|
+
- **HTTPS Support**: Secure HTTPS communication
|
|
305
|
+
- **Bearer Token Auth**: API key authentication via Bearer tokens
|
|
306
|
+
- **JSON Encoding**: JSON-encoded payloads
|
|
307
|
+
- **Custom Headers**: Proper Content-Type and Authorization headers
|
|
308
|
+
|
|
309
|
+
## Comparison-Ready Features
|
|
310
|
+
|
|
311
|
+
### Unique Differentiators
|
|
312
|
+
1. **Automatic EXPLAIN ANALYZE**: Background execution plan capture for slow queries
|
|
313
|
+
2. **Lightweight Memory Tracking**: Low-overhead memory monitoring by default
|
|
314
|
+
3. **Comprehensive Cache Tracking**: Detailed cache operation tracking
|
|
315
|
+
4. **Redis Instrumentation**: Full Redis command tracking including pipelines
|
|
316
|
+
5. **View Rendering Analysis**: Detailed view performance analysis with cache hit rates
|
|
317
|
+
6. **Flexible Exclusion Rules**: Wildcard support for controller/job exclusion
|
|
318
|
+
7. **Request Sampling**: Configurable percentage-based sampling
|
|
319
|
+
8. **Circuit Breaker**: Built-in resilience for APM endpoint failures
|
|
320
|
+
9. **Multi-Source Configuration**: Flexible configuration from multiple sources
|
|
321
|
+
10. **Deploy Tracking**: Automatic deploy ID resolution from multiple sources
|
|
322
|
+
|
|
323
|
+
### Standard APM Features
|
|
324
|
+
- Request/response tracking
|
|
325
|
+
- SQL query tracking
|
|
326
|
+
- Error tracking
|
|
327
|
+
- Background job tracking
|
|
328
|
+
- Memory tracking
|
|
329
|
+
- Performance metrics
|
|
330
|
+
- Exception handling
|
|
331
|
+
- User context
|
|
332
|
+
- Environment tracking
|
|
333
|
+
|
|
@@ -372,27 +372,6 @@ module DeadBro
|
|
|
372
372
|
nil
|
|
373
373
|
end
|
|
374
374
|
|
|
375
|
-
def process_hostname
|
|
376
|
-
if defined?(ProcessInfo)
|
|
377
|
-
begin
|
|
378
|
-
ProcessInfo.safe_hostname
|
|
379
|
-
rescue
|
|
380
|
-
default_hostname
|
|
381
|
-
end
|
|
382
|
-
else
|
|
383
|
-
default_hostname
|
|
384
|
-
end
|
|
385
|
-
rescue
|
|
386
|
-
default_hostname
|
|
387
|
-
end
|
|
388
|
-
|
|
389
|
-
def default_hostname
|
|
390
|
-
require "socket"
|
|
391
|
-
Socket.gethostname
|
|
392
|
-
rescue
|
|
393
|
-
"unknown"
|
|
394
|
-
end
|
|
395
|
-
|
|
396
375
|
def safe_collect
|
|
397
376
|
yield
|
|
398
377
|
rescue => e
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require "rbconfig"
|
|
5
|
-
require "socket"
|
|
6
5
|
|
|
7
6
|
module DeadBro
|
|
8
7
|
module Collectors
|
|
@@ -20,7 +19,7 @@ module DeadBro
|
|
|
20
19
|
{
|
|
21
20
|
kind: DeadBro.process_kind,
|
|
22
21
|
pid: Process.pid,
|
|
23
|
-
hostname: safe_hostname,
|
|
22
|
+
hostname: DeadBro.safe_hostname,
|
|
24
23
|
boot_time: rails_boot_time,
|
|
25
24
|
uptime_s: uptime_seconds(now),
|
|
26
25
|
ruby_version: RUBY_VERSION,
|
|
@@ -52,12 +51,6 @@ module DeadBro
|
|
|
52
51
|
false
|
|
53
52
|
end
|
|
54
53
|
|
|
55
|
-
def safe_hostname
|
|
56
|
-
Socket.gethostname
|
|
57
|
-
rescue
|
|
58
|
-
"unknown"
|
|
59
|
-
end
|
|
60
|
-
|
|
61
54
|
def rails_boot_time
|
|
62
55
|
return nil unless defined?(Rails)
|
|
63
56
|
|
|
@@ -86,15 +86,7 @@ module DeadBro
|
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
def redis_key(key)
|
|
89
|
-
env
|
|
90
|
-
host = begin
|
|
91
|
-
require "socket"
|
|
92
|
-
Socket.gethostname
|
|
93
|
-
rescue
|
|
94
|
-
"unknown"
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
"dead_bro:metrics:#{env}:#{host}:#{key}"
|
|
89
|
+
"dead_bro:metrics:#{DeadBro.env}:#{DeadBro.safe_hostname}:#{key}"
|
|
98
90
|
end
|
|
99
91
|
|
|
100
92
|
def file_path(key)
|
|
@@ -180,6 +180,9 @@ module DeadBro
|
|
|
180
180
|
return stripped
|
|
181
181
|
end
|
|
182
182
|
|
|
183
|
+
revision = read_revision_file
|
|
184
|
+
return revision unless revision.nil? || revision.empty?
|
|
185
|
+
|
|
183
186
|
DeadBro.process_deploy_id
|
|
184
187
|
end
|
|
185
188
|
|
|
@@ -249,6 +252,19 @@ module DeadBro
|
|
|
249
252
|
|
|
250
253
|
private
|
|
251
254
|
|
|
255
|
+
# Capistrano (and similar) write the deployed git SHA to REVISION in the app root.
|
|
256
|
+
def read_revision_file
|
|
257
|
+
return nil unless defined?(Rails) && Rails.respond_to?(:root)
|
|
258
|
+
|
|
259
|
+
path = Rails.root.join("REVISION")
|
|
260
|
+
return nil unless path.file?
|
|
261
|
+
|
|
262
|
+
stripped = File.read(path).strip
|
|
263
|
+
stripped.empty? ? nil : stripped
|
|
264
|
+
rescue
|
|
265
|
+
nil
|
|
266
|
+
end
|
|
267
|
+
|
|
252
268
|
# Turn a list of user-facing patterns into {pattern, has_hash, regex}
|
|
253
269
|
# entries. Regex is nil when the pattern is a plain literal (cheaper eq
|
|
254
270
|
# compare). Compiling up-front removes per-request regex allocation.
|
|
@@ -114,7 +114,7 @@ module DeadBro
|
|
|
114
114
|
status: "completed",
|
|
115
115
|
sql_queries: sql_queries,
|
|
116
116
|
rails_env: DeadBro.env,
|
|
117
|
-
host:
|
|
117
|
+
host: DeadBro.safe_hostname,
|
|
118
118
|
process_kind: DeadBro.process_kind,
|
|
119
119
|
memory_usage: memory_usage_mb,
|
|
120
120
|
gc_stats: gc_stats,
|
|
@@ -213,7 +213,7 @@ module DeadBro
|
|
|
213
213
|
message: exception&.message&.to_s&.[](0, 1000),
|
|
214
214
|
backtrace: Array(exception&.backtrace).first(50),
|
|
215
215
|
rails_env: DeadBro.env,
|
|
216
|
-
host:
|
|
216
|
+
host: DeadBro.safe_hostname,
|
|
217
217
|
process_kind: DeadBro.process_kind,
|
|
218
218
|
memory_usage: memory_usage_mb,
|
|
219
219
|
gc_stats: gc_stats,
|
|
@@ -287,18 +287,6 @@ module DeadBro
|
|
|
287
287
|
[]
|
|
288
288
|
end
|
|
289
289
|
|
|
290
|
-
def self.safe_host
|
|
291
|
-
if defined?(Rails) && Rails.respond_to?(:application)
|
|
292
|
-
begin
|
|
293
|
-
Rails.application.class.module_parent_name
|
|
294
|
-
rescue
|
|
295
|
-
""
|
|
296
|
-
end
|
|
297
|
-
else
|
|
298
|
-
""
|
|
299
|
-
end
|
|
300
|
-
end
|
|
301
|
-
|
|
302
290
|
def self.memory_usage_mb
|
|
303
291
|
DeadBro::MemoryHelpers.rss_mb
|
|
304
292
|
rescue
|
data/lib/dead_bro/monitor.rb
CHANGED
|
@@ -67,7 +67,7 @@ module DeadBro
|
|
|
67
67
|
def collect_and_send_stats
|
|
68
68
|
payload = {
|
|
69
69
|
environment: DeadBro.env,
|
|
70
|
-
host:
|
|
70
|
+
host: DeadBro.safe_hostname,
|
|
71
71
|
pid: Process.pid,
|
|
72
72
|
process_kind: DeadBro.process_kind,
|
|
73
73
|
current_time: Time.now.utc.iso8601,
|
|
@@ -89,13 +89,6 @@ module DeadBro
|
|
|
89
89
|
@client.post_monitor_stats(payload)
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
-
def process_hostname
|
|
93
|
-
require "socket"
|
|
94
|
-
Socket.gethostname
|
|
95
|
-
rescue
|
|
96
|
-
"unknown"
|
|
97
|
-
end
|
|
98
|
-
|
|
99
92
|
def log_error(message)
|
|
100
93
|
msg = "[DeadBro::Monitor] #{message}"
|
|
101
94
|
if defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger
|
data/lib/dead_bro/subscriber.rb
CHANGED
|
@@ -136,7 +136,7 @@ module DeadBro
|
|
|
136
136
|
status: data[:status],
|
|
137
137
|
duration_ms: duration_ms,
|
|
138
138
|
rails_env: DeadBro.env,
|
|
139
|
-
host:
|
|
139
|
+
host: DeadBro.safe_hostname,
|
|
140
140
|
process_kind: DeadBro.process_kind,
|
|
141
141
|
params: safe_params(data),
|
|
142
142
|
user_agent: safe_user_agent(data),
|
|
@@ -168,7 +168,7 @@ module DeadBro
|
|
|
168
168
|
duration_ms: duration_ms,
|
|
169
169
|
view_runtime_ms: data[:view_runtime],
|
|
170
170
|
db_runtime_ms: data[:db_runtime],
|
|
171
|
-
host:
|
|
171
|
+
host: DeadBro.safe_hostname,
|
|
172
172
|
rails_env: DeadBro.env,
|
|
173
173
|
process_kind: DeadBro.process_kind,
|
|
174
174
|
params: safe_params(data),
|
|
@@ -230,18 +230,6 @@ module DeadBro
|
|
|
230
230
|
""
|
|
231
231
|
end
|
|
232
232
|
|
|
233
|
-
def self.safe_host
|
|
234
|
-
if defined?(Rails) && Rails.respond_to?(:application)
|
|
235
|
-
begin
|
|
236
|
-
Rails.application.class.module_parent_name
|
|
237
|
-
rescue
|
|
238
|
-
""
|
|
239
|
-
end
|
|
240
|
-
else
|
|
241
|
-
""
|
|
242
|
-
end
|
|
243
|
-
end
|
|
244
|
-
|
|
245
233
|
def self.safe_params(data)
|
|
246
234
|
return {} unless data[:params]
|
|
247
235
|
|
data/lib/dead_bro/version.rb
CHANGED
data/lib/dead_bro.rb
CHANGED
|
@@ -128,6 +128,14 @@ module DeadBro
|
|
|
128
128
|
"development"
|
|
129
129
|
end
|
|
130
130
|
|
|
131
|
+
# OS hostname for identifying which machine handled a request, job, or metric.
|
|
132
|
+
def self.safe_hostname
|
|
133
|
+
require "socket"
|
|
134
|
+
Socket.gethostname
|
|
135
|
+
rescue
|
|
136
|
+
"unknown"
|
|
137
|
+
end
|
|
138
|
+
|
|
131
139
|
def self.process_kind
|
|
132
140
|
@process_kind ||= begin
|
|
133
141
|
fingerprint = "#{$PROGRAM_NAME} #{process_command_line}".downcase
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dead_bro
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.23
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Emanuel Comsa
|
|
@@ -18,6 +18,7 @@ extensions: []
|
|
|
18
18
|
extra_rdoc_files: []
|
|
19
19
|
files:
|
|
20
20
|
- CHANGELOG.md
|
|
21
|
+
- FEATURES.md
|
|
21
22
|
- README.md
|
|
22
23
|
- lib/dead_bro.rb
|
|
23
24
|
- lib/dead_bro/ar_object_tracker.rb
|
|
@@ -75,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
75
76
|
- !ruby/object:Gem::Version
|
|
76
77
|
version: '0'
|
|
77
78
|
requirements: []
|
|
78
|
-
rubygems_version: 4.0.
|
|
79
|
+
rubygems_version: 4.0.9
|
|
79
80
|
specification_version: 4
|
|
80
81
|
summary: Minimal APM for Rails apps.
|
|
81
82
|
test_files: []
|