libhoney 1.7.0 → 1.8.1
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 +4 -4
- data/lib/libhoney/client.rb +20 -7
- data/lib/libhoney/log_client.rb +1 -0
- data/lib/libhoney/null_client.rb +22 -0
- data/lib/libhoney/null_transmission.rb +13 -0
- data/lib/libhoney/test_client.rb +1 -0
- data/lib/libhoney/version.rb +1 -1
- data/lib/libhoney.rb +1 -2
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d74e33b8302fc833dd35b082d3737fa7fdab5778619ebe32847f5a15f422e49b
|
4
|
+
data.tar.gz: 6312eef683fe6d91daad288b75d0066dea4bf24ba19748fd57c0d720438c2e6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7de2ddd45d25a2678d2c0d7d3ae8bf951bb68f395373fdc4beffc95f0ae83e28f802a71970eda66ef39eee8398710e1c4365d84c3009f898d70df3b57d9fe4ad
|
7
|
+
data.tar.gz: 61dff7d76a2da82da52e5c4d0f94314393a34039c647008b6238e2c544007e7454479241320e7bde40cebe6fdbe08e7fb38453b0fd6e1515c32b33fe4d47c62b
|
data/lib/libhoney/client.rb
CHANGED
@@ -3,6 +3,8 @@ require 'time'
|
|
3
3
|
require 'json'
|
4
4
|
require 'http'
|
5
5
|
|
6
|
+
require 'libhoney/null_transmission'
|
7
|
+
|
6
8
|
# define a few additions that proxy access through Client's builder. makes Client much tighter.
|
7
9
|
class Class
|
8
10
|
def builder_attr_accessor(*args)
|
@@ -38,8 +40,8 @@ module Libhoney
|
|
38
40
|
# honey.close
|
39
41
|
#
|
40
42
|
# Arguments:
|
41
|
-
# * *writekey* is the key to use the Honeycomb service
|
42
|
-
# * *dataset* is the dataset to write into
|
43
|
+
# * *writekey* is the key to use the Honeycomb service (required)
|
44
|
+
# * *dataset* is the dataset to write into (required)
|
43
45
|
# * *sample_rate* is how many samples you want to keep. IE: 1 means you want 1 out of 1 samples kept, or all of them. 10 means you want 1 out of 10 samples kept. And so on.
|
44
46
|
# * *url* is the url to connect to Honeycomb
|
45
47
|
# * *num_workers* is the number of threads working on the queue of events you are generating
|
@@ -49,15 +51,15 @@ module Libhoney
|
|
49
51
|
class Client
|
50
52
|
# Instantiates libhoney and prepares it to send events to Honeycomb.
|
51
53
|
#
|
52
|
-
# @param writekey [String] the write key from your honeycomb team
|
53
|
-
# @param dataset [String] the dataset you want
|
54
|
+
# @param writekey [String] the write key from your honeycomb team (required)
|
55
|
+
# @param dataset [String] the dataset you want (required)
|
54
56
|
# @param sample_rate [Fixnum] cause libhoney to send 1 out of sampleRate events. overrides the libhoney instance's value.
|
55
57
|
# @param api_host [String] the base url to send events to
|
56
58
|
# @param transmission [Object] transport used to actually send events. If nil (the default), will be lazily initialized with a {TransmissionClient} on first event send.
|
57
59
|
# @param block_on_send [Boolean] if more than pending_work_capacity events are written, block sending further events
|
58
60
|
# @param block_on_responses [Boolean] if true, block if there is no thread reading from the response queue
|
59
|
-
def initialize(writekey:
|
60
|
-
dataset:
|
61
|
+
def initialize(writekey: nil,
|
62
|
+
dataset: nil,
|
61
63
|
sample_rate: 1,
|
62
64
|
api_host: 'https://api.honeycomb.io/',
|
63
65
|
user_agent_addition: nil,
|
@@ -79,6 +81,18 @@ module Libhoney
|
|
79
81
|
@builder.sample_rate = sample_rate
|
80
82
|
@builder.api_host = api_host
|
81
83
|
|
84
|
+
@tx = transmission
|
85
|
+
if !@tx && !(writekey && dataset)
|
86
|
+
# if no writekey or dataset are configured, and we didn't override the
|
87
|
+
# transmission (e.g. to a MockTransmissionClient), that's almost
|
88
|
+
# certainly a misconfiguration, even though it's possible to override
|
89
|
+
# them on a per-event basis. So let's handle the misconfiguration
|
90
|
+
# early rather than potentially throwing thousands of exceptions at
|
91
|
+
# runtime.
|
92
|
+
warn "#{self.class.name}: no #{writekey ? 'dataset' : 'writekey'} configured, disabling sending events"
|
93
|
+
@tx = NullTransmissionClient.new
|
94
|
+
end
|
95
|
+
|
82
96
|
@user_agent_addition = user_agent_addition
|
83
97
|
|
84
98
|
@block_on_send = block_on_send
|
@@ -88,7 +102,6 @@ module Libhoney
|
|
88
102
|
@max_concurrent_batches = max_concurrent_batches
|
89
103
|
@pending_work_capacity = pending_work_capacity
|
90
104
|
@responses = SizedQueue.new(2 * @pending_work_capacity)
|
91
|
-
@tx = transmission
|
92
105
|
@lock = Mutex.new
|
93
106
|
|
94
107
|
self
|
data/lib/libhoney/log_client.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'libhoney/client'
|
2
|
+
require 'libhoney/null_transmission'
|
3
|
+
|
4
|
+
module Libhoney
|
5
|
+
|
6
|
+
# A no-op client that silently drops events. Does not send events to
|
7
|
+
# Honeycomb, or to anywhere else for that matter.
|
8
|
+
#
|
9
|
+
# This class is intended as a fallback for callers that wanted to instantiate
|
10
|
+
# a regular Client but had insufficient config to do so (e.g. missing
|
11
|
+
# writekey).
|
12
|
+
#
|
13
|
+
# @api private
|
14
|
+
class NullClient < Client
|
15
|
+
def initialize(*args, **kwargs)
|
16
|
+
super(*args,
|
17
|
+
transmission: NullTransmissionClient.new,
|
18
|
+
**kwargs)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Libhoney
|
2
|
+
# A no-op version of TransmissionClient that silently drops events (without
|
3
|
+
# sending them to Honeycomb, or anywhere else for that matter).
|
4
|
+
#
|
5
|
+
# @api private
|
6
|
+
class NullTransmissionClient
|
7
|
+
def add(event)
|
8
|
+
end
|
9
|
+
|
10
|
+
def close(drain)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/libhoney/test_client.rb
CHANGED
data/lib/libhoney/version.rb
CHANGED
data/lib/libhoney.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'libhoney/client'
|
2
2
|
require 'libhoney/log_client'
|
3
|
+
require 'libhoney/null_client'
|
3
4
|
require 'libhoney/test_client'
|
4
5
|
require 'libhoney/version'
|
5
6
|
require 'libhoney/builder'
|
6
7
|
require 'libhoney/response'
|
7
8
|
require 'libhoney/transmission'
|
8
|
-
require 'libhoney/log_transmission'
|
9
|
-
require 'libhoney/mock_transmission'
|
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.
|
4
|
+
version: 1.8.1
|
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-
|
11
|
+
date: 2018-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -144,6 +144,8 @@ files:
|
|
144
144
|
- lib/libhoney/log_client.rb
|
145
145
|
- lib/libhoney/log_transmission.rb
|
146
146
|
- lib/libhoney/mock_transmission.rb
|
147
|
+
- lib/libhoney/null_client.rb
|
148
|
+
- lib/libhoney/null_transmission.rb
|
147
149
|
- lib/libhoney/response.rb
|
148
150
|
- lib/libhoney/test_client.rb
|
149
151
|
- lib/libhoney/transmission.rb
|
@@ -169,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
171
|
version: '0'
|
170
172
|
requirements: []
|
171
173
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.7.
|
174
|
+
rubygems_version: 2.7.7
|
173
175
|
signing_key:
|
174
176
|
specification_version: 4
|
175
177
|
summary: send data to Honeycomb
|