raygun-apm 1.1.15.pre3
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/COPYING.rax +9 -0
- data/LICENSE +27 -0
- data/LICENSE.bipbuffer +24 -0
- data/README.rdoc +118 -0
- data/bin/console +14 -0
- data/bin/rake +27 -0
- data/bin/rake.cmd +30 -0
- data/bin/raygun-diagnostics +6 -0
- data/bin/setup +8 -0
- data/ext/raygun/extconf.rb +114 -0
- data/lib/raygun/apm/blacklist/parser.rb +49 -0
- data/lib/raygun/apm/blacklist/translator.rb +79 -0
- data/lib/raygun/apm/blacklist.rb +476 -0
- data/lib/raygun/apm/config.rb +104 -0
- data/lib/raygun/apm/diagnostics.rb +54 -0
- data/lib/raygun/apm/event.rb +49 -0
- data/lib/raygun/apm/hooks/excon.rb +36 -0
- data/lib/raygun/apm/hooks/httpclient.rb +43 -0
- data/lib/raygun/apm/hooks/internals.rb +95 -0
- data/lib/raygun/apm/hooks/mongodb.rb +45 -0
- data/lib/raygun/apm/hooks/net_http.rb +44 -0
- data/lib/raygun/apm/hooks/redis.rb +46 -0
- data/lib/raygun/apm/tracer.rb +131 -0
- data/lib/raygun/apm/version.rb +6 -0
- data/lib/raygun/apm.rb +18 -0
- data/raygun-apm.gemspec +43 -0
- metadata +282 -0
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
module Raygun
|
|
2
|
+
module Apm
|
|
3
|
+
module Blacklist
|
|
4
|
+
PROFILER = %w{
|
|
5
|
+
Raygun
|
|
6
|
+
Raygun::Apm::
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
# From https://ruby-doc.org/core-2.6.3/ , to automate
|
|
10
|
+
DEFAULT_RUBY = %w{
|
|
11
|
+
#<refinement:
|
|
12
|
+
#<Module:
|
|
13
|
+
#<Class:
|
|
14
|
+
#<#<Class:
|
|
15
|
+
ARGF#
|
|
16
|
+
ArgumentError#
|
|
17
|
+
Array#
|
|
18
|
+
Base64#
|
|
19
|
+
BasicObject#
|
|
20
|
+
Binding#
|
|
21
|
+
Class#
|
|
22
|
+
ClosedQueueError#
|
|
23
|
+
Comparable#
|
|
24
|
+
Complex#
|
|
25
|
+
ConditionVariable#
|
|
26
|
+
Continuation#
|
|
27
|
+
Data#
|
|
28
|
+
Dir#
|
|
29
|
+
Dir::
|
|
30
|
+
ENV#
|
|
31
|
+
EOFError#
|
|
32
|
+
Encoding#
|
|
33
|
+
Encoding::
|
|
34
|
+
EncodingError#
|
|
35
|
+
Enumerable#
|
|
36
|
+
Enumerator#
|
|
37
|
+
Enumerator::
|
|
38
|
+
Errno#
|
|
39
|
+
Exception#
|
|
40
|
+
FalseClass#
|
|
41
|
+
Fiber#
|
|
42
|
+
FiberError#
|
|
43
|
+
File#
|
|
44
|
+
File::
|
|
45
|
+
FileTest#
|
|
46
|
+
Float#
|
|
47
|
+
FloatDomainError#
|
|
48
|
+
FrozenError#
|
|
49
|
+
GC#
|
|
50
|
+
GC::Profiler#
|
|
51
|
+
Hash#
|
|
52
|
+
IO#
|
|
53
|
+
IO::
|
|
54
|
+
IOError#
|
|
55
|
+
IndexError#
|
|
56
|
+
Integer#
|
|
57
|
+
Interrupt#
|
|
58
|
+
JSON#
|
|
59
|
+
Kernel#
|
|
60
|
+
KeyError#
|
|
61
|
+
LoadError#
|
|
62
|
+
LocalJumpError#
|
|
63
|
+
Marshal#
|
|
64
|
+
MatchData#
|
|
65
|
+
Math#
|
|
66
|
+
Math::
|
|
67
|
+
Method#
|
|
68
|
+
Module#
|
|
69
|
+
Mutex#
|
|
70
|
+
+Thread::Mutex#synchronize
|
|
71
|
+
+Thread::Mutex#lock
|
|
72
|
+
+Thread::Mutex#unlock
|
|
73
|
+
+Thread::Mutex#sleep
|
|
74
|
+
NameError#
|
|
75
|
+
NilClass#
|
|
76
|
+
NoMemoryError#
|
|
77
|
+
NoMethodError#
|
|
78
|
+
NotImplementedError#
|
|
79
|
+
Numeric#
|
|
80
|
+
Object#
|
|
81
|
+
ObjectSpace#
|
|
82
|
+
ObjectSpace::
|
|
83
|
+
Proc#
|
|
84
|
+
Process#
|
|
85
|
+
Process::
|
|
86
|
+
Psych#
|
|
87
|
+
Queue#
|
|
88
|
+
Random#
|
|
89
|
+
Random::
|
|
90
|
+
Range#
|
|
91
|
+
RangeError#
|
|
92
|
+
Rational#
|
|
93
|
+
Regexp#
|
|
94
|
+
RegexpError#
|
|
95
|
+
RubyVM#
|
|
96
|
+
RubyVM::
|
|
97
|
+
RuntimeError#
|
|
98
|
+
ScriptError#
|
|
99
|
+
SecurityError#
|
|
100
|
+
Set#
|
|
101
|
+
SimpleDelegator#
|
|
102
|
+
Singleton#
|
|
103
|
+
Singleton::
|
|
104
|
+
Signal#
|
|
105
|
+
SignalException#
|
|
106
|
+
SizedQueue#
|
|
107
|
+
Socket#
|
|
108
|
+
StandardError#
|
|
109
|
+
StopIteration#
|
|
110
|
+
String#
|
|
111
|
+
Struct#
|
|
112
|
+
Symbol#
|
|
113
|
+
SyntaxError#
|
|
114
|
+
SystemCallError#
|
|
115
|
+
SystemExit#
|
|
116
|
+
SystemStackError#
|
|
117
|
+
Thread#
|
|
118
|
+
Thread::
|
|
119
|
+
ThreadError#
|
|
120
|
+
ThreadGroup#
|
|
121
|
+
Timeout
|
|
122
|
+
Time#
|
|
123
|
+
TracePoint#
|
|
124
|
+
TrueClass#
|
|
125
|
+
TypeError#
|
|
126
|
+
UnboundMethod#
|
|
127
|
+
UncaughtThrowError#
|
|
128
|
+
UnicodeNormalize#
|
|
129
|
+
Warning#
|
|
130
|
+
ZeroDivisionError#
|
|
131
|
+
IPAddr#
|
|
132
|
+
Net::
|
|
133
|
+
OpenSSL#
|
|
134
|
+
OpenSSL::
|
|
135
|
+
BasicSocket#
|
|
136
|
+
Forwardable#
|
|
137
|
+
Gem#
|
|
138
|
+
FFI#
|
|
139
|
+
Addrinfo#
|
|
140
|
+
Open3#
|
|
141
|
+
Shellwords#
|
|
142
|
+
WeakRef#
|
|
143
|
+
RbConfig#
|
|
144
|
+
Singleton#
|
|
145
|
+
OpenStruct#
|
|
146
|
+
Bundler#
|
|
147
|
+
Delegator#
|
|
148
|
+
PrettyPrint#
|
|
149
|
+
PP#
|
|
150
|
+
PP::
|
|
151
|
+
PP#sharing_detection
|
|
152
|
+
PrettyPrint#
|
|
153
|
+
PrettyPrint::
|
|
154
|
+
Minitest
|
|
155
|
+
Psych
|
|
156
|
+
Mutex_m#
|
|
157
|
+
ERB#
|
|
158
|
+
ERB::
|
|
159
|
+
Gem#
|
|
160
|
+
Gem::
|
|
161
|
+
FileUtils#
|
|
162
|
+
FileUtils::
|
|
163
|
+
Tempfile#
|
|
164
|
+
Tempfile::
|
|
165
|
+
Logger#
|
|
166
|
+
Logger::
|
|
167
|
+
Ractor#
|
|
168
|
+
Ractor::
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
INTERNALS = %w{
|
|
172
|
+
+Object#sleep
|
|
173
|
+
+Object#exec
|
|
174
|
+
+Object#fork
|
|
175
|
+
+Object#system
|
|
176
|
+
+Object#spawn
|
|
177
|
+
+Continuation#callcc
|
|
178
|
+
+IO#syscall
|
|
179
|
+
+IO#open
|
|
180
|
+
+IO#puts
|
|
181
|
+
+IO#gets
|
|
182
|
+
+IO#readline
|
|
183
|
+
+IO#readlines
|
|
184
|
+
+Random#srand
|
|
185
|
+
+Random#rand
|
|
186
|
+
+Signal#trap
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
HTTP_OUT = %w{
|
|
190
|
+
#Faraday
|
|
191
|
+
URI
|
|
192
|
+
MonitorMixin
|
|
193
|
+
Faraday
|
|
194
|
+
+Faraday::Connection#get
|
|
195
|
+
+Faraday::Connection#head
|
|
196
|
+
+Faraday::Connection#delete
|
|
197
|
+
+Faraday::Connection#trace
|
|
198
|
+
+Faraday::Connection#post
|
|
199
|
+
+Faraday::Connection#put
|
|
200
|
+
+Faraday::Connection#patch
|
|
201
|
+
#multipart-post
|
|
202
|
+
Multipartable
|
|
203
|
+
SecureRandom
|
|
204
|
+
Parts
|
|
205
|
+
CompositeReadIO
|
|
206
|
+
+Multipartable#initialize
|
|
207
|
+
#rest-client
|
|
208
|
+
RestClient
|
|
209
|
+
Netrc
|
|
210
|
+
HTTP::CookieJar
|
|
211
|
+
DomainName
|
|
212
|
+
HTTP::Accept
|
|
213
|
+
+RestClient.get
|
|
214
|
+
+RestClient.head
|
|
215
|
+
+RestClient.delete
|
|
216
|
+
+RestClient.trace
|
|
217
|
+
+RestClient.post
|
|
218
|
+
+RestClient.put
|
|
219
|
+
+RestClient.patch
|
|
220
|
+
#excon
|
|
221
|
+
Excon
|
|
222
|
+
+Excon.get
|
|
223
|
+
+Excon.head
|
|
224
|
+
+Excon.delete
|
|
225
|
+
+Excon.trace
|
|
226
|
+
+Excon.post
|
|
227
|
+
+Excon.put
|
|
228
|
+
+Excon.patch
|
|
229
|
+
#HTTParty
|
|
230
|
+
HTTParty
|
|
231
|
+
+HTTParty.get
|
|
232
|
+
+HTTParty.head
|
|
233
|
+
+HTTParty.delete
|
|
234
|
+
+HTTParty.trace
|
|
235
|
+
+HTTParty.post
|
|
236
|
+
+HTTParty.put
|
|
237
|
+
+HTTParty.patch
|
|
238
|
+
#httpclient
|
|
239
|
+
HTTPClient
|
|
240
|
+
HTTP::Message
|
|
241
|
+
+HTTPClient#get
|
|
242
|
+
+HTTPClient#head
|
|
243
|
+
+HTTPClient#delete
|
|
244
|
+
+HTTPClient#trace
|
|
245
|
+
+HTTPClient#post
|
|
246
|
+
+HTTPClient#put
|
|
247
|
+
+HTTPClient#patch
|
|
248
|
+
#net-http
|
|
249
|
+
+Net::HTTP.get_response
|
|
250
|
+
+Net::HTTP.get
|
|
251
|
+
+Net::HTTP.head
|
|
252
|
+
+Net::HTTP.delete
|
|
253
|
+
+Net::HTTP.trace
|
|
254
|
+
+Net::HTTP.post
|
|
255
|
+
+Net::HTTP.put
|
|
256
|
+
+Net::HTTP.patch
|
|
257
|
+
+Net::HTTP.post_form
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
QUERIES = %w{
|
|
261
|
+
#mongodb
|
|
262
|
+
Mongo
|
|
263
|
+
BSON
|
|
264
|
+
+Mongo::Operation::Executable#do_execute
|
|
265
|
+
#redis
|
|
266
|
+
Redis
|
|
267
|
+
+Redis#auth
|
|
268
|
+
+Redis#select
|
|
269
|
+
+Redis#ping
|
|
270
|
+
+Redis#echo
|
|
271
|
+
+Redis#bgrewriteaof
|
|
272
|
+
+Redis#bgsave
|
|
273
|
+
+Redis#config
|
|
274
|
+
+Redis#dbsize
|
|
275
|
+
+Redis#debug
|
|
276
|
+
+Redis#flushall
|
|
277
|
+
+Redis#flushdb
|
|
278
|
+
+Redis#info
|
|
279
|
+
+Redis#lastsave
|
|
280
|
+
+Redis#monitor
|
|
281
|
+
+Redis#save
|
|
282
|
+
+Redis#shutdown
|
|
283
|
+
+Redis#slave
|
|
284
|
+
+Redis#slowlog
|
|
285
|
+
+Redis#sync
|
|
286
|
+
+Redis#time
|
|
287
|
+
+Redis#persist
|
|
288
|
+
+Redis#expire
|
|
289
|
+
+Redis#expireat
|
|
290
|
+
+Redis#ttl
|
|
291
|
+
+Redis#pexpire
|
|
292
|
+
+Redis#pexpireat
|
|
293
|
+
+Redis#pttl
|
|
294
|
+
+Redis#dump
|
|
295
|
+
+Redis#restore
|
|
296
|
+
+Redis#migrate
|
|
297
|
+
+Redis#del
|
|
298
|
+
+Redis#unlink
|
|
299
|
+
+Redis#exists
|
|
300
|
+
+Redis#keys
|
|
301
|
+
+Redis#move
|
|
302
|
+
+Redis#object
|
|
303
|
+
+Redis#randomkey
|
|
304
|
+
+Redis#rename
|
|
305
|
+
+Redis#renamenx
|
|
306
|
+
+Redis#sort
|
|
307
|
+
+Redis#type
|
|
308
|
+
+Redis#decr
|
|
309
|
+
+Redis#decrby
|
|
310
|
+
+Redis#incr
|
|
311
|
+
+Redis#incrby
|
|
312
|
+
+Redis#incrbyfloat
|
|
313
|
+
+Redis#set
|
|
314
|
+
+Redis#multi
|
|
315
|
+
+Redis#client
|
|
316
|
+
+Redis#set
|
|
317
|
+
+Redis#setex
|
|
318
|
+
+Redis#psetex
|
|
319
|
+
+Redis#setnx
|
|
320
|
+
+Redis#mset
|
|
321
|
+
+Redis#mapped_mset
|
|
322
|
+
+Redis#msetnx
|
|
323
|
+
+Redis#mapped_msetnx
|
|
324
|
+
+Redis#get
|
|
325
|
+
+Redis#mget
|
|
326
|
+
+Redis#mapped_mget
|
|
327
|
+
+Redis#setrange
|
|
328
|
+
+Redis#getrange
|
|
329
|
+
+Redis#setbit
|
|
330
|
+
+Redis#getbit
|
|
331
|
+
+Redis#append
|
|
332
|
+
+Redis#bitcount
|
|
333
|
+
+Redis#bitop
|
|
334
|
+
+Redis#bitpos
|
|
335
|
+
+Redis#getset
|
|
336
|
+
+Redis#strlen
|
|
337
|
+
+Redis#llen
|
|
338
|
+
+Redis#lpush
|
|
339
|
+
+Redis#lpushx
|
|
340
|
+
+Redis#rpush
|
|
341
|
+
+Redis#rpushx
|
|
342
|
+
+Redis#lpop
|
|
343
|
+
+Redis#rpop
|
|
344
|
+
+Redis#rpoplpush
|
|
345
|
+
+Redis#blpop
|
|
346
|
+
+Redis#brpop
|
|
347
|
+
+Redis#brpoplpush
|
|
348
|
+
+Redis#lindex
|
|
349
|
+
+Redis#linsert
|
|
350
|
+
+Redis#lrange
|
|
351
|
+
+Redis#lrem
|
|
352
|
+
+Redis#lset
|
|
353
|
+
+Redis#ltrim
|
|
354
|
+
+Redis#scard
|
|
355
|
+
+Redis#sadd
|
|
356
|
+
+Redis#srem
|
|
357
|
+
+Redis#spop
|
|
358
|
+
+Redis#srandmember
|
|
359
|
+
+Redis#smove
|
|
360
|
+
+Redis#sismember
|
|
361
|
+
+Redis#smembers
|
|
362
|
+
+Redis#sdiff
|
|
363
|
+
+Redis#sdiffstore
|
|
364
|
+
+Redis#sinter
|
|
365
|
+
+Redis#sinterstore
|
|
366
|
+
+Redis#sunion
|
|
367
|
+
+Redis#sunionstore
|
|
368
|
+
+Redis#zcard
|
|
369
|
+
+Redis#zadd
|
|
370
|
+
+Redis#zincrby
|
|
371
|
+
+Redis#zrem
|
|
372
|
+
+Redis#zpopmax
|
|
373
|
+
+Redis#zpopmin
|
|
374
|
+
+Redis#bzpopmax
|
|
375
|
+
+Redis#bzpopmin
|
|
376
|
+
+Redis#zscore
|
|
377
|
+
+Redis#zrange
|
|
378
|
+
+Redis#zrevrange
|
|
379
|
+
+Redis#zrank
|
|
380
|
+
+Redis#zrevrank
|
|
381
|
+
+Redis#zremrangebyrank
|
|
382
|
+
+Redis#zlexcount
|
|
383
|
+
+Redis#zrangebylex
|
|
384
|
+
+Redis#zrevrangebylex
|
|
385
|
+
+Redis#zrangebyscore
|
|
386
|
+
+Redis#zrevrangebyscore
|
|
387
|
+
+Redis#zremrangebyscore
|
|
388
|
+
+Redis#zcount
|
|
389
|
+
+Redis#zinterstore
|
|
390
|
+
+Redis#zunionstore
|
|
391
|
+
+Redis#hlen
|
|
392
|
+
+Redis#hset
|
|
393
|
+
+Redis#hsetnx
|
|
394
|
+
+Redis#hmset
|
|
395
|
+
+Redis#mapped_hmset
|
|
396
|
+
+Redis#hget
|
|
397
|
+
+Redis#hmget
|
|
398
|
+
+Redis#mapped_hmget
|
|
399
|
+
+Redis#hdel
|
|
400
|
+
+Redis#hexists
|
|
401
|
+
+Redis#hincrby
|
|
402
|
+
+Redis#hincrbyfloat
|
|
403
|
+
+Redis#hkeys
|
|
404
|
+
+Redis#hvals
|
|
405
|
+
+Redis#hgetall
|
|
406
|
+
+Redis#publish
|
|
407
|
+
+Redis#subscribe
|
|
408
|
+
+Redis#subscribe_with_timeout
|
|
409
|
+
+Redis#unsubscribe
|
|
410
|
+
+Redis#psubscribe
|
|
411
|
+
+Redis#psubscribe_with_timeout
|
|
412
|
+
+Redis#punsubscribe
|
|
413
|
+
+Redis#pubsub
|
|
414
|
+
+Redis#watch
|
|
415
|
+
+Redis#unwatch
|
|
416
|
+
+Redis#pipelined
|
|
417
|
+
+Redis#multi
|
|
418
|
+
+Redis#exec
|
|
419
|
+
+Redis#discard
|
|
420
|
+
+Redis#script
|
|
421
|
+
+Redis#eval
|
|
422
|
+
+Redis#evalsha
|
|
423
|
+
+Redis#scan
|
|
424
|
+
+Redis#hscan
|
|
425
|
+
+Redis#zscan
|
|
426
|
+
+Redis#sscan
|
|
427
|
+
+Redis#pfadd
|
|
428
|
+
+Redis#pfcount
|
|
429
|
+
+Redis#pfmerge
|
|
430
|
+
+Redis#geoadd
|
|
431
|
+
+Redis#geohash
|
|
432
|
+
+Redis#georadiusbymember
|
|
433
|
+
+Redis#geopos
|
|
434
|
+
+Redis#geodist
|
|
435
|
+
+Redis#xinfo
|
|
436
|
+
+Redis#xadd
|
|
437
|
+
+Redis#xtrim
|
|
438
|
+
+Redis#xdel
|
|
439
|
+
+Redis#xrange
|
|
440
|
+
+Redis#xrevrange
|
|
441
|
+
+Redis#xlen
|
|
442
|
+
+Redis#xread
|
|
443
|
+
+Redis#xgroup
|
|
444
|
+
+Redis#xreadgroup
|
|
445
|
+
+Redis#xack
|
|
446
|
+
+Redis#xclaim
|
|
447
|
+
+Redis#xpending
|
|
448
|
+
+Redis#sentinel
|
|
449
|
+
+Redis#cluster
|
|
450
|
+
+Redis#asking
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
RAYGUN4RUBY = %w{
|
|
454
|
+
Raygun::Breadcrumbs
|
|
455
|
+
Raygun::Configuration
|
|
456
|
+
Raygun.config
|
|
457
|
+
Raygun.log
|
|
458
|
+
Raygun.should_report?
|
|
459
|
+
Raygun::Client
|
|
460
|
+
+Raygun.track_exception
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
def self.extend_with(list)
|
|
464
|
+
self.extended_blacklist << list
|
|
465
|
+
end
|
|
466
|
+
|
|
467
|
+
def self.extended_blacklist
|
|
468
|
+
@@extended_blacklist ||= []
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
def self.resolve_entries
|
|
472
|
+
DEFAULT_RUBY + PROFILER + INTERNALS + HTTP_OUT + QUERIES + RAYGUN4RUBY + self.extended_blacklist.flatten
|
|
473
|
+
end
|
|
474
|
+
end
|
|
475
|
+
end
|
|
476
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
module Raygun
|
|
2
|
+
module Apm
|
|
3
|
+
class Config
|
|
4
|
+
LOGLEVELS = {
|
|
5
|
+
"None" => Tracer::LOG_NONE,
|
|
6
|
+
"Info" => Tracer::LOG_INFO,
|
|
7
|
+
"Warning" => Tracer::LOG_WARNING,
|
|
8
|
+
"Error" => Tracer::LOG_ERROR,
|
|
9
|
+
"Verbose" => Tracer::LOG_VERBOSE,
|
|
10
|
+
"Debug" => Tracer::LOG_DEBUG,
|
|
11
|
+
"Everything" => Tracer::LOG_EVERYTHING,
|
|
12
|
+
# ruby profiler specific
|
|
13
|
+
"Blacklist" => Tracer::LOG_BLACKLIST
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
ENVIRONMENTS = {
|
|
17
|
+
"development" => Tracer::ENV_DEVELOPMENT,
|
|
18
|
+
"production" => Tracer::ENV_PRODUCTION
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
DEFAULT_BLACKLIST_PATH_UNIX = "/usr/share/Raygun/Blacklist"
|
|
22
|
+
DEFAULT_BLACKLIST_PATH_WINDOWS = "C:\\ProgramData\\Raygun\\Blacklist"
|
|
23
|
+
|
|
24
|
+
attr_accessor :env
|
|
25
|
+
def initialize(env=ENV)
|
|
26
|
+
@env = env
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.cast_to_boolean(x)
|
|
30
|
+
case x
|
|
31
|
+
when true, 'true', 'True', 1, '1' then true
|
|
32
|
+
else
|
|
33
|
+
false
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.config_var(attr, opts={}, &blk)
|
|
38
|
+
define_method attr.downcase do
|
|
39
|
+
val = if x = env[attr]
|
|
40
|
+
if opts[:as] == Integer
|
|
41
|
+
Integer(x)
|
|
42
|
+
elsif opts[:as] == String
|
|
43
|
+
x.to_s
|
|
44
|
+
elsif opts[:as] == :boolean
|
|
45
|
+
self.class.cast_to_boolean(x)
|
|
46
|
+
end
|
|
47
|
+
else
|
|
48
|
+
opts[:default]
|
|
49
|
+
end
|
|
50
|
+
blk ? blk.call(val) : val
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Initial constants for ProtonAgentTail.exe
|
|
55
|
+
UDP_SINK_HOST = TCP_SINK_HOST = TCP_MANAGEMENT_HOST = '127.0.0.1'
|
|
56
|
+
UDP_SINK_MULTICAST_HOST = '239.100.15.215'
|
|
57
|
+
UDP_SINK_PORT = TCP_SINK_PORT = 2799
|
|
58
|
+
TCP_MANAGEMENT_PORT = 2790
|
|
59
|
+
|
|
60
|
+
## Enumerate all PROTON_ constants
|
|
61
|
+
config_var 'PROTON_API_KEY', as: String, default: ''
|
|
62
|
+
config_var 'PROTON_DEBUG_LOGLEVEL', as: String, default: 'None'
|
|
63
|
+
config_var 'PROTON_USER_OVERRIDES_FILE', as: String
|
|
64
|
+
config_var 'PROTON_NETWORK_MODE', as: String, default: 'Udp'
|
|
65
|
+
config_var 'PROTON_FILE_IPC_FOLDER', as: String
|
|
66
|
+
config_var 'PROTON_USE_MULTICAST', as: String, default: 'False'
|
|
67
|
+
config_var 'PROTON_BATCH_IDLE_COUNTER', as: Integer, default: 500
|
|
68
|
+
## New - Ruby profiler
|
|
69
|
+
config_var 'PROTON_UDP_PORT', as: Integer, default: UDP_SINK_PORT
|
|
70
|
+
config_var 'PROTON_TCP_PORT', as: Integer, default: TCP_SINK_PORT
|
|
71
|
+
## Conditional hooks
|
|
72
|
+
config_var 'PROTON_HOOK_REDIS', as: :boolean, default: 'True'
|
|
73
|
+
config_var 'PROTON_HOOK_INTERNALS', as: :boolean, default: 'True'
|
|
74
|
+
|
|
75
|
+
def proton_udp_host
|
|
76
|
+
if proton_use_multicast == 'True'
|
|
77
|
+
UDP_SINK_MULTICAST_HOST
|
|
78
|
+
else
|
|
79
|
+
env['PROTON_UDP_HOST'] ? env['PROTON_UDP_HOST'].to_s : UDP_SINK_HOST
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def proton_tcp_host
|
|
84
|
+
env['PROTON_TCP_HOST'] ? env['PROTON_TCP_HOST'].to_s : TCP_SINK_HOST
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def loglevel
|
|
88
|
+
LOGLEVELS[proton_debug_loglevel] || raise(ArgumentError, "invalid log level")
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def environment
|
|
92
|
+
environment = env['RACK_ENV'] || env['RAILS_ENV'] || 'production'
|
|
93
|
+
ENVIRONMENTS[environment] || Tracer::ENV_PRODUCTION
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Prefer what is set by PROTON_USER_OVERRIDES_FILE env
|
|
97
|
+
def blacklist_file
|
|
98
|
+
return proton_user_overrides_file if proton_user_overrides_file
|
|
99
|
+
path = Gem.win_platform? ? DEFAULT_BLACKLIST_PATH_WINDOWS : DEFAULT_BLACKLIST_PATH_UNIX
|
|
100
|
+
"#{File.join(path, proton_api_key)}.txt"
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require "socket"
|
|
2
|
+
require "json"
|
|
3
|
+
|
|
4
|
+
module Raygun
|
|
5
|
+
module Apm
|
|
6
|
+
class Diagnostics
|
|
7
|
+
AGENT_STATE_DOWN = "\nThe Raygun APM Agent appears to not be running on the current host.\nIf not already installed, please consult https://raygun.com/documentation/product-guides/apm/agent/downloads/\nOtherwise refer to https://raygun.com/documentation/product-guides/apm/agent/installation/ for starting the Agent."
|
|
8
|
+
AGENT_STATE_UNKNOWN = "\nThe Raygun APM Agent is reachable, but Unable to determine the state of the Agent at the moment."
|
|
9
|
+
AGENT_STATE_UP_MISCONFIGURED = "\nThe Raygun APM Agent is running, but misconfigured.\nThe API Key needs to be set through the Raygun_ApiKey environment variable.\nThe API key can be found under 'Application Settings' in the Raygun UI"
|
|
10
|
+
AGENT_STATE_UP_CONFIGURED = "\nThe Raygun APM Agent is configured properly!"
|
|
11
|
+
AGENT_MINIMUM_VERSION_NOT_MET = "\nVersion #{Raygun::Apm::VERSION} of the Raygun APM Profiler requires a minimum Agent version #{Raygun::Apm::MINIMUM_AGENT_VERSION}\nPlease download the latest Agent from https://raygun.com/documentation/product-guides/apm/agent/downloads/"
|
|
12
|
+
PROFILER_NOOPED = "Profiler loaded in noop mode and will be disabled due to the minimum Agent version not met"
|
|
13
|
+
|
|
14
|
+
def initialize(host: Apm::Config::TCP_MANAGEMENT_HOST, port: Apm::Config::TCP_MANAGEMENT_PORT)
|
|
15
|
+
@host = host
|
|
16
|
+
@port = port
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def verify_agent(tracer)
|
|
20
|
+
socket.write "GetAgentInfo"
|
|
21
|
+
response = JSON.parse(socket.gets)
|
|
22
|
+
if minimum_agent_version_not_met?(response['Version'])
|
|
23
|
+
puts AGENT_MINIMUM_VERSION_NOT_MET
|
|
24
|
+
tracer.noop!
|
|
25
|
+
puts PROFILER_NOOPED
|
|
26
|
+
else
|
|
27
|
+
if response['Status'] == 1
|
|
28
|
+
puts AGENT_STATE_UP_CONFIGURED
|
|
29
|
+
elsif response['Status'] == 0
|
|
30
|
+
puts AGENT_STATE_UP_MISCONFIGURED
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
rescue Errno::ECONNREFUSED
|
|
34
|
+
puts AGENT_STATE_DOWN
|
|
35
|
+
rescue
|
|
36
|
+
puts AGENT_STATE_UNKNOWN
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
def socket
|
|
41
|
+
@socket ||= s = TCPSocket.new(@host, @port)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def minimum_agent_version_not_met?(version)
|
|
45
|
+
# Legacy path
|
|
46
|
+
if String === version
|
|
47
|
+
version < Raygun::Apm::MINIMUM_AGENT_VERSION
|
|
48
|
+
else
|
|
49
|
+
"#{version['Major']}.#{version['Minor']}.#{version['Build']}.#{version['Revision']}" < Raygun::Apm::MINIMUM_AGENT_VERSION
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Raygun
|
|
2
|
+
module Apm
|
|
3
|
+
class Event
|
|
4
|
+
def inspect
|
|
5
|
+
"#<#{self.class.name}:#{self.object_id}> length:#{self.length} pid:#{self[:pid]} tid:#{self[:tid]} timestamp:#{self[:timestamp]}"
|
|
6
|
+
end
|
|
7
|
+
class ExceptionThrown < Event
|
|
8
|
+
def inspect
|
|
9
|
+
super + " class:#{self[:class_name]}"
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
class ThreadStarted < Event
|
|
13
|
+
def inspect
|
|
14
|
+
super + " parent_tid:#{self[:parent_tid]}"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
class Begin < Event
|
|
18
|
+
def inspect
|
|
19
|
+
super + " function_id:#{self[:function_id]} instance_id:#{self[:instance_id]}"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
class End < Event
|
|
23
|
+
def inspect
|
|
24
|
+
super + " function_id:#{self[:function_id]}"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
class Methodinfo < Event
|
|
28
|
+
def inspect
|
|
29
|
+
super + " function_id:#{self[:function_id]} class_name:#{self[:class_name]} method_name:#{self[:method_name]} method_source:#{self[:method_source]}"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
class HttpOut < Event
|
|
33
|
+
def inspect
|
|
34
|
+
super + " url:#{self[:url]} verb:#{self[:verb]} status:#{self[:status]} duration:#{self[:duration]}"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
class Sql < Event
|
|
38
|
+
def inspect
|
|
39
|
+
super + " provider:#{self[:provider]} host:#{self[:host]} query:#{self[:query]} database:#{self[:database]} duration:#{self[:duration]}"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
class BeginTransaction < Event
|
|
43
|
+
def inspect
|
|
44
|
+
super + " api_key:#{self[:api_key]} technology_type:#{self[:technology_type]} process_type:#{self[:process_type]}"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'excon'
|
|
2
|
+
|
|
3
|
+
module Raygun
|
|
4
|
+
module Apm
|
|
5
|
+
module Hooks
|
|
6
|
+
module Excon
|
|
7
|
+
def request(params={}, &block)
|
|
8
|
+
if tracer = Raygun::Apm::Tracer.instance
|
|
9
|
+
started = tracer.now
|
|
10
|
+
response = super
|
|
11
|
+
ended = tracer.now
|
|
12
|
+
event = raygun_apm_http_out_event
|
|
13
|
+
event[:pid] = Process.pid
|
|
14
|
+
event[:url] = "#{@data[:scheme]}://#{@data[:host]}/#{params[:path]}"
|
|
15
|
+
event[:verb] = params[:method].to_s.upcase
|
|
16
|
+
event[:status] = response.status
|
|
17
|
+
event[:duration] = ended - started
|
|
18
|
+
event[:timestamp] = started
|
|
19
|
+
event[:tid] = tracer.get_thread_id(Thread.current)
|
|
20
|
+
tracer.emit(event)
|
|
21
|
+
response
|
|
22
|
+
else
|
|
23
|
+
super
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
def raygun_apm_http_out_event
|
|
29
|
+
@_raygun_apm_http_out_event ||= Raygun::Apm::Event::HttpOut.new
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
Raygun::Apm::Tracer.patch(Excon::Connection, Raygun::Apm::Hooks::Excon)
|