libhoney 1.1.0 → 1.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
  SHA1:
3
- metadata.gz: 709e34b6d6a1f0c9c1cd4e14898d4921405fa924
4
- data.tar.gz: c8f47ea904509f3b4ba25e54eaeb3bcf530415f3
3
+ metadata.gz: 3090756dce154f139d8a4c5598ba7a64be9c95e6
4
+ data.tar.gz: 6ad36413896edd22a0175026cd5519d27c4389a6
5
5
  SHA512:
6
- metadata.gz: 676446ff6c3daaf0520957b091939e5ab4c8bb174653fa00f4b22f7147795b0cd25f99639672485a68c6356998ac89f41f7864298062dc23cbe926c4a14c0e68
7
- data.tar.gz: 789b3e21e993a2fa70750f6c7eb056af092068069fbd740ce0e0f466298a41bcd18de9cb390cff5f1b0b656f819efd71db1a6bb6a15ff32d6129b977d194b638
6
+ metadata.gz: c76eb3a559bb39e98f86e99369314a649012e651d2e0b576726089ce16646107a24b56504823c62948dfe2b60d6792aad24ab784a966b8a4d65f109c52ae4571
7
+ data.tar.gz: 23940a295a83f270a249d9a7d6278fbccd71f9998dd59abf1151f33956794fe3fe4c417ce24cbef7c450930c9bda4e24364664cb3a6205e2bf892369de591a64
@@ -50,30 +50,21 @@ module Libhoney
50
50
 
51
51
  before = Time.now
52
52
 
53
- conn = Faraday.new(:url => e.api_host) do |faraday|
54
- faraday.request :json
55
- faraday.adapter :net_http_persistent
56
- end
57
-
58
- resp = conn.post do |req|
59
- req.url '/1/events/' + e.dataset
60
- req.headers = {
61
- 'User-Agent' => "libhoney-rb/#{VERSION}",
62
- 'Content-Type' => 'application/json',
63
- 'X-Honeycomb-Team' => e.writekey,
64
- 'X-Honeycomb-SampleRate' => e.sample_rate.to_s,
65
- 'X-Event-Time' => e.timestamp.iso8601
66
- }
67
- req.body = e.data
53
+ begin
54
+ resp = do_send(e)
55
+
56
+ response = Response.new(:status_code => resp.status)
57
+ rescue Exception => error
58
+ # catch a broader swath of exceptions than is usually good practice,
59
+ # because this is effectively the top-level exception handler for the
60
+ # sender threads, and we don't want those threads to die (leaving
61
+ # nothing consuming the queue).
62
+ response = Response.new(:error => error)
63
+ ensure
64
+ response.duration = Time.now - before
65
+ response.metadata = e.metadata
68
66
  end
69
67
 
70
- # TODO handle faraday errors
71
-
72
- after = Time.now
73
-
74
- response = Response.new(:duration => after - before,
75
- :status_code => resp.status,
76
- :metadata => e.metadata)
77
68
  begin
78
69
  @responses.enq(response, !@block_on_responses)
79
70
  rescue ThreadError
@@ -98,5 +89,29 @@ module Libhoney
98
89
 
99
90
  0
100
91
  end
92
+
93
+ private
94
+ def do_send(event)
95
+ conn = Faraday.new(:url => event.api_host) do |faraday|
96
+ faraday.request :json
97
+ faraday.adapter :net_http_persistent
98
+ end
99
+
100
+ resp = conn.post do |req|
101
+ req.url '/1/events/' + event.dataset
102
+ req.headers = {
103
+ 'User-Agent' => "libhoney-rb/#{VERSION}",
104
+ 'Content-Type' => 'application/json',
105
+ 'X-Honeycomb-Team' => event.writekey,
106
+ 'X-Honeycomb-SampleRate' => event.sample_rate.to_s,
107
+ 'X-Event-Time' => event.timestamp.iso8601
108
+ }
109
+ req.body = event.data
110
+ end
111
+
112
+ # TODO handle faraday errors
113
+
114
+ resp
115
+ end
101
116
  end
102
117
  end
@@ -1,3 +1,3 @@
1
1
  module Libhoney
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libhoney
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Honeycomb.io Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-24 00:00:00.000000000 Z
11
+ date: 2017-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler