canary_ipa 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/lib/canary_ipa.rb +15 -6
- data/lib/canary_ipa/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2889ede32bbf41a40a4dfa362ea7bf26985745ac42ecebf23a72061569f6c82
|
4
|
+
data.tar.gz: 1037e9081ce61981fd23a7e62da974181e04859140ceab111d9e1a3bfed1db1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 484829790ac308cff43c014c31aac3f39092645560a57d0712c070cd3b9deca29719aa78cb7e099f55d9b77ddc8076107366ad70238588e3d777a70da0c08dbd
|
7
|
+
data.tar.gz: 0b2609a95c3cf75fc673069cdf50dc2c7dd108be35093fa7032036326a26c6c80a89d2a54a9888bfc9f7438fd55dd2b2ada746c4ebbed114165ef8818251a5df
|
data/README.md
CHANGED
@@ -20,6 +20,18 @@ Just installing the Gem is enough. There is some optional configuration through
|
|
20
20
|
* `CANARY_MONITORING_AGENT_PORT` can be set to a port to send the telemetry data to, the default is to
|
21
21
|
sent to port 51712.
|
22
22
|
|
23
|
+
## Rails usage
|
24
|
+
|
25
|
+
When working with Rails, you probably already have most of your configuration in `config/application.rb`. If so,
|
26
|
+
you can simply configure the Gem using:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
CanaryIpa.config do | c |
|
30
|
+
c.host = "cma.prod.test.com"
|
31
|
+
c.port = 12345
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
23
35
|
## Installation
|
24
36
|
Add this line to your application's Gemfile:
|
25
37
|
|
data/lib/canary_ipa.rb
CHANGED
@@ -1,19 +1,28 @@
|
|
1
|
-
require "canary_ipa/version"
|
2
1
|
require "canary_ipa/railtie"
|
3
2
|
|
4
3
|
module CanaryIpa
|
4
|
+
class << self
|
5
|
+
attr_writer :host, :port
|
6
|
+
|
7
|
+
def host
|
8
|
+
@host || ENV["CANARY_MONITORING_AGENT_HOST"] || "127.0.0.1"
|
9
|
+
end
|
10
|
+
def port
|
11
|
+
@port || (ENV["CANAY_MONITORING_AGENT_PORT"] || "51712").to_i
|
12
|
+
end
|
13
|
+
def config
|
14
|
+
yield self
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
5
18
|
module NetHttpExtensions
|
6
19
|
@@sock = UDPSocket.new
|
7
|
-
@@host = ENV["CANARY_MONITORING_AGENT_HOST"] || "127.0.0.1"
|
8
|
-
@@port = (ENV["CANARY_MONITORING_AGENT_PORT"] || "51712").to_i
|
9
20
|
def request(req, body = nil, &block)
|
10
21
|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
11
22
|
result = super(req, body, &block)
|
12
23
|
delta = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
|
13
24
|
delta_ms = delta * 1000
|
14
|
-
@@sock.send("0\t#{req.method}\t#{@address}\t#{req.path}\t#{delta_ms}\n", 0,
|
15
|
-
#overhead = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start - delta
|
16
|
-
#puts "Measuring and UDP overhead: around #{overhead}s"
|
25
|
+
@@sock.send("0\t#{req.method}\t#{@address}\t#{req.path}\t#{delta_ms}\n", 0, CanaryIpa.host, CanaryIpa.port)
|
17
26
|
result
|
18
27
|
end
|
19
28
|
end
|
data/lib/canary_ipa/version.rb
CHANGED