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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8c0b039fc3f9703bc1fcfb811b639faf990d6f853f09456790c74e33512b4fd
4
- data.tar.gz: 855f9d7efdcb7f13a80a081848274067628a837602602bc8f8b44205c67f8e90
3
+ metadata.gz: d2889ede32bbf41a40a4dfa362ea7bf26985745ac42ecebf23a72061569f6c82
4
+ data.tar.gz: 1037e9081ce61981fd23a7e62da974181e04859140ceab111d9e1a3bfed1db1d
5
5
  SHA512:
6
- metadata.gz: '062291508bede280a514ea8b685f786f0bcaedc7d80f5196974c3245963a9d56927fc54cd988089fda3c92f7976a3bd4a7aecb74dacd8dee37cce1547f528af7'
7
- data.tar.gz: 75ffd7186d7c31a9ecf6ba964584fee83cceded341ba9e957b82e506f965cbda2b7e8408b7d2ee3643353bb98b0750a3856865e5646cc146dad0764cc60e8d11
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, @@host, @@port)
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
@@ -1,3 +1,3 @@
1
1
  module CanaryIpa
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canary_ipa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Canary Monitoring, Inc