libhoney 1.8.1 → 1.9.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: d74e33b8302fc833dd35b082d3737fa7fdab5778619ebe32847f5a15f422e49b
4
- data.tar.gz: 6312eef683fe6d91daad288b75d0066dea4bf24ba19748fd57c0d720438c2e6d
3
+ metadata.gz: 002dba15d3956c73ef901036b9e0a9ea63e24006f6efe5204764b9a2685d4ae6
4
+ data.tar.gz: 1b21181cff8da8b5d27ced9fc34122a043fe4c75ec312a816559da18e866057e
5
5
  SHA512:
6
- metadata.gz: 7de2ddd45d25a2678d2c0d7d3ae8bf951bb68f395373fdc4beffc95f0ae83e28f802a71970eda66ef39eee8398710e1c4365d84c3009f898d70df3b57d9fe4ad
7
- data.tar.gz: 61dff7d76a2da82da52e5c4d0f94314393a34039c647008b6238e2c544007e7454479241320e7bde40cebe6fdbe08e7fb38453b0fd6e1515c32b33fe4d47c62b
6
+ metadata.gz: e7314941eade26ddf596e947926c29e9482106d36a1cd58d6f1ef9ac9ac672f0efaa788c9e455b45446f50521d32e42595a9e70d9cb8573268017a512d83aadc
7
+ data.tar.gz: 6eef3e11972e7cb4dfc9cc4ffcd31581e0d13e3f3a934ed8fd9bf4f8c69238de49e06d10ae618037d02e0398c10784195a3ada8e8c63078d94ff7f69e2910aaf
@@ -3,6 +3,7 @@ rvm:
3
3
  - 2.2
4
4
  - 2.3
5
5
  - 2.4
6
+ - 2.5
6
7
  deploy:
7
8
  provider: rubygems
8
9
  api_key:
@@ -48,6 +48,13 @@ module Libhoney
48
48
  end
49
49
 
50
50
  def send_loop
51
+ http_clients = Hash.new do |h, api_host|
52
+ h[api_host] = HTTP.persistent(api_host).headers(
53
+ 'User-Agent' => @user_agent,
54
+ 'Content-Type' => 'application/json',
55
+ )
56
+ end
57
+
51
58
  # eat events until we run out
52
59
  loop {
53
60
  e = @send_queue.pop
@@ -56,13 +63,17 @@ module Libhoney
56
63
  before = Time.now
57
64
 
58
65
  begin
59
- resp = HTTP.headers(
60
- 'User-Agent' => @user_agent,
61
- 'Content-Type' => 'application/json',
66
+ http = http_clients[e.api_host]
67
+
68
+ resp = http.post('/1/events/'+URI.escape(e.dataset), json: e.data, headers: {
62
69
  'X-Honeycomb-Team' => e.writekey,
63
70
  'X-Honeycomb-SampleRate' => e.sample_rate,
64
71
  'X-Event-Time' => e.timestamp.iso8601(3)
65
- ).post(URI.join(e.api_host, '/1/events/', URI.escape(e.dataset)), :json => e.data)
72
+ })
73
+
74
+ # "You must consume response before sending next request via persistent connection"
75
+ # https://github.com/httprb/http/wiki/Persistent-Connections-%28keep-alive%29#note-using-persistent-requests-correctly
76
+ resp.flush
66
77
 
67
78
  response = Response.new(:status_code => resp.status)
68
79
  rescue Exception => error
@@ -72,16 +83,22 @@ module Libhoney
72
83
  # nothing consuming the queue).
73
84
  response = Response.new(:error => error)
74
85
  ensure
75
- response.duration = Time.now - before
76
- response.metadata = e.metadata
86
+ if response
87
+ response.duration = Time.now - before
88
+ response.metadata = e.metadata
89
+ end
77
90
  end
78
91
 
79
92
  begin
80
- @responses.enq(response, !@block_on_responses)
93
+ @responses.enq(response, !@block_on_responses) if response
81
94
  rescue ThreadError
82
95
  # happens if the queue was full and block_on_send = false.
83
96
  end
84
97
  }
98
+ ensure
99
+ http_clients.each do |_, http|
100
+ http.close rescue nil
101
+ end
85
102
  end
86
103
 
87
104
  def close(drain)
@@ -1,3 +1,3 @@
1
1
  module Libhoney
2
- VERSION = "1.8.1"
2
+ VERSION = "1.9.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.8.1
4
+ version: 1.9.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: 2018-05-31 00:00:00.000000000 Z
11
+ date: 2018-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler