honeycomb-beeline 0.1.0 → 0.2.0
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/README.md +12 -47
- data/lib/honeycomb-beeline.rb +2 -8
- data/lib/honeycomb/beeline/version.rb +1 -1
- data/lib/honeycomb/client.rb +43 -8
- data/lib/honeycomb/instrumentations.rb +25 -0
- metadata +3 -4
- data/lib/honeycomb-beeline/auto_install.rb +0 -48
- data/lib/honeycomb/env_config.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8226a2444f449e489670d844e544ec8986ff40b32016ae9199031ae2fef1df8
|
4
|
+
data.tar.gz: 11e5d5f9dc8dcc000e6a4cdb5dbebd35f0fe332c9ff5ab0a85f4b084f428f7bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5370b82bf792605cf79bcf67a5930a0430f498e84f0472e5046b3a027d52761d0fbc3410b21374a2fc32c61beb20738defa47db30a80a650b9ede888b09bc13a
|
7
|
+
data.tar.gz: c70d4cd7b0ea59c6642286db68b38bd0c637715e5468bfa096c8684486d93bcbebb0b7b037be01bb440f10c645199465a6500dfd54ab62fb602e467dea017a46
|
data/README.md
CHANGED
@@ -6,58 +6,19 @@ instruments them to send useful events to Honeycomb.
|
|
6
6
|
|
7
7
|
## Setup
|
8
8
|
|
9
|
-
Setup requires minimal changes to your app
|
10
|
-
app loads gems at startup.
|
11
|
-
|
12
|
-
### Automatic setup for apps that call `Bundler.require`
|
13
|
-
|
14
|
-
If your app calls `Bundler.require` at startup (you can verify by running `git
|
15
|
-
grep 'Bundler\.require'`) then setup just requires adding one line to your
|
16
|
-
Gemfile:
|
17
|
-
|
18
|
-
```ruby
|
19
|
-
gem 'honeycomb-beeline', require: 'honeycomb-beeline/auto_install'
|
20
|
-
```
|
21
|
-
|
22
|
-
Now run `bundle install` to install the gem.
|
23
|
-
|
24
|
-
### Automatic setup for other apps
|
25
|
-
|
26
|
-
If your app does not call `Bundler.require` at startup (you can verify by
|
27
|
-
running `git grep 'Bundler\.require'`) then you'll need to make two changes.
|
28
|
-
First add this line to your Gemfile:
|
29
|
-
|
30
|
-
```ruby
|
31
|
-
gem 'honeycomb-beeline'
|
32
|
-
```
|
33
|
-
|
34
|
-
Then require the gem somewhere in your app's startup script - e.g. for a Rack app
|
35
|
-
add it to your "config.ru":
|
36
|
-
|
37
|
-
```ruby
|
38
|
-
require 'honeycomb-beeline/auto_install'
|
39
|
-
```
|
40
|
-
|
41
|
-
Now run `bundle install` to install the gem.
|
42
|
-
|
43
|
-
### Manual setup
|
44
|
-
|
45
|
-
If the automatic setup doesn't work for your app, or you prefer to choose which
|
46
|
-
libraries to instrument, then you'll need to call `Honeycomb.init` manually.
|
47
|
-
|
48
|
-
First add this line to your Gemfile:
|
9
|
+
Setup requires minimal changes to your app. First add this line to your Gemfile:
|
49
10
|
|
50
11
|
```ruby
|
51
12
|
gem 'honeycomb-beeline'
|
52
13
|
```
|
53
14
|
|
54
|
-
Then
|
55
|
-
|
15
|
+
Then in your app's startup script - e.g. for a Rack app "config.ru" is a good
|
16
|
+
place - add the following code:
|
56
17
|
|
57
18
|
```ruby
|
58
19
|
require 'honeycomb-beeline'
|
59
20
|
|
60
|
-
Honeycomb.init
|
21
|
+
Honeycomb.init
|
61
22
|
```
|
62
23
|
|
63
24
|
Now run `bundle install` to install the gem.
|
@@ -68,17 +29,18 @@ You'll need to configure your Honeycomb writekey so that your app can
|
|
68
29
|
identify itself to Honeycomb. You can find your writekey on [your Account
|
69
30
|
page](https://ui.honeycomb.io/account).
|
70
31
|
|
71
|
-
You
|
72
|
-
to.
|
73
|
-
current directory.
|
32
|
+
You'll also need to configure the name of a dataset in your Honeycomb account to
|
33
|
+
send events to. The name of your app is a good choice.
|
74
34
|
|
75
35
|
You can specify the configuration either via environment variables, or by
|
76
|
-
|
36
|
+
passing arguments to `Honeycomb.init`:
|
77
37
|
|
78
38
|
### Configuration via environment variables
|
79
39
|
|
80
40
|
* `HONEYCOMB_WRITEKEY` - specifies the writekey
|
81
41
|
* `HONEYCOMB_DATASET` - specifies the dataset
|
42
|
+
* `HONEYCOMB_SERVICE` - specifies the name of your app (defaults to the dataset
|
43
|
+
name)
|
82
44
|
|
83
45
|
### Configuration via code
|
84
46
|
|
@@ -86,6 +48,9 @@ calling `Honeycomb.init` explicitly:
|
|
86
48
|
Honeycomb.init(writekey: '<MY HONEYCOMB WRITEKEY>', dataset: 'my-app')
|
87
49
|
```
|
88
50
|
|
51
|
+
Note that you should not check your Honeycomb writekey into version control, as
|
52
|
+
it is sensitive and allows sending data to your Honeycomb account.
|
53
|
+
|
89
54
|
## Development
|
90
55
|
|
91
56
|
### Releasing a new version
|
data/lib/honeycomb-beeline.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
|
-
# Main entrypoint for the 'honeycomb-beeline' gem
|
2
|
-
# lib/honeycomb-beeline/automagic.rb for an alternative entrypoint).
|
1
|
+
# Main entrypoint for the 'honeycomb-beeline' gem.
|
3
2
|
|
4
3
|
require 'libhoney'
|
5
4
|
|
6
5
|
require 'honeycomb/client'
|
6
|
+
require 'honeycomb/instrumentations'
|
7
7
|
require 'honeycomb/span'
|
8
|
-
|
9
|
-
require 'activerecord-honeycomb'
|
10
|
-
require 'faraday-honeycomb'
|
11
|
-
|
12
|
-
module Honeycomb
|
13
|
-
end
|
data/lib/honeycomb/client.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
require 'honeycomb/beeline/version'
|
2
|
+
|
3
|
+
require 'libhoney'
|
4
|
+
|
2
5
|
require 'socket'
|
3
6
|
|
4
7
|
module Honeycomb
|
@@ -6,8 +9,18 @@ module Honeycomb
|
|
6
9
|
|
7
10
|
class << self
|
8
11
|
attr_reader :client
|
12
|
+
attr_reader :service_name
|
13
|
+
|
14
|
+
def init(
|
15
|
+
writekey: ENV['HONEYCOMB_WRITEKEY'],
|
16
|
+
dataset: ENV['HONEYCOMB_DATASET'],
|
17
|
+
service_name: ENV['HONEYCOMB_SERVICE'] || dataset,
|
18
|
+
without: [],
|
19
|
+
logger: nil,
|
20
|
+
**options
|
21
|
+
)
|
22
|
+
reset
|
9
23
|
|
10
|
-
def init(writekey: nil, dataset: nil, service_name: dataset, logger: nil, without: [], **options)
|
11
24
|
@logger = logger
|
12
25
|
@without = without
|
13
26
|
@service_name = service_name
|
@@ -19,22 +32,24 @@ module Honeycomb
|
|
19
32
|
@logger.debug "Running hook '#{label}' after Honeycomb.init" if @logger
|
20
33
|
run_hook(label, block)
|
21
34
|
end
|
35
|
+
|
36
|
+
@initialized = true
|
22
37
|
end
|
23
38
|
|
24
39
|
def new_client(options)
|
25
|
-
|
40
|
+
client = options.delete :client
|
26
41
|
|
27
42
|
options = {user_agent_addition: USER_AGENT_SUFFIX}.merge(options)
|
28
|
-
|
43
|
+
client ||= begin
|
29
44
|
unless options[:writekey] && options[:dataset]
|
30
45
|
raise ArgumentError, "must specify writekey and dataset"
|
31
46
|
end
|
32
47
|
Libhoney::Client.new(options)
|
33
48
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
49
|
+
client.add_field 'meta.beeline_version', Beeline::VERSION
|
50
|
+
client.add_field 'meta.local_hostname', Socket.gethostname rescue nil
|
51
|
+
client.add_field 'service_name', @service_name
|
52
|
+
client
|
38
53
|
end
|
39
54
|
|
40
55
|
def after_init(label, &block)
|
@@ -48,7 +63,7 @@ module Honeycomb
|
|
48
63
|
block
|
49
64
|
end
|
50
65
|
|
51
|
-
if @initialized
|
66
|
+
if defined?(@initialized)
|
52
67
|
@logger.debug "Running hook '#{label}' as Honeycomb already initialized" if @logger
|
53
68
|
run_hook(label, hook)
|
54
69
|
else
|
@@ -56,6 +71,26 @@ module Honeycomb
|
|
56
71
|
end
|
57
72
|
end
|
58
73
|
|
74
|
+
def shutdown
|
75
|
+
if defined?(@client) && @client
|
76
|
+
@client.close
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# @api private
|
81
|
+
def reset
|
82
|
+
# TODO encapsulate all this into a Beeline object so we don't need
|
83
|
+
# explicit cleanup
|
84
|
+
|
85
|
+
shutdown
|
86
|
+
|
87
|
+
@logger = nil
|
88
|
+
@without = nil
|
89
|
+
@service_name = nil
|
90
|
+
@client = nil
|
91
|
+
@initialized = false
|
92
|
+
end
|
93
|
+
|
59
94
|
private
|
60
95
|
def after_init_hooks
|
61
96
|
@after_init_hooks ||= []
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'honeycomb/client'
|
2
|
+
|
3
|
+
require 'activerecord-honeycomb/auto_install'
|
4
|
+
require 'faraday-honeycomb/auto_install'
|
5
|
+
require 'rack-honeycomb/auto_install'
|
6
|
+
require 'sequel-honeycomb/auto_install'
|
7
|
+
|
8
|
+
module Honeycomb
|
9
|
+
INSTRUMENTATIONS = [
|
10
|
+
ActiveRecord::Honeycomb,
|
11
|
+
Faraday::Honeycomb,
|
12
|
+
Rack::Honeycomb,
|
13
|
+
Sequel::Honeycomb,
|
14
|
+
].freeze
|
15
|
+
|
16
|
+
INSTRUMENTATIONS.each do |instrumentation|
|
17
|
+
auto = instrumentation::AutoInstall
|
18
|
+
if auto.available?
|
19
|
+
hook_label = instrumentation.name.sub(/::Honeycomb$/, '').downcase.to_sym
|
20
|
+
after_init(hook_label) do |client|
|
21
|
+
auto.auto_install!(honeycomb_client: client, logger: @logger)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: honeycomb-beeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stokes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libhoney
|
@@ -246,10 +246,9 @@ extra_rdoc_files: []
|
|
246
246
|
files:
|
247
247
|
- README.md
|
248
248
|
- lib/honeycomb-beeline.rb
|
249
|
-
- lib/honeycomb-beeline/auto_install.rb
|
250
249
|
- lib/honeycomb/beeline/version.rb
|
251
250
|
- lib/honeycomb/client.rb
|
252
|
-
- lib/honeycomb/
|
251
|
+
- lib/honeycomb/instrumentations.rb
|
253
252
|
- lib/honeycomb/span.rb
|
254
253
|
homepage: https://github.com/honeycombio/beeline-ruby
|
255
254
|
licenses:
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# Alternative entrypoint for the 'honeycomb-beeline' gem that detects libraries
|
2
|
-
# we can instrument and automagically instrument them.
|
3
|
-
|
4
|
-
require 'libhoney'
|
5
|
-
|
6
|
-
require 'honeycomb/client'
|
7
|
-
require 'honeycomb/span'
|
8
|
-
|
9
|
-
require 'activerecord-honeycomb/auto_install'
|
10
|
-
require 'faraday-honeycomb/auto_install'
|
11
|
-
require 'rack-honeycomb/auto_install'
|
12
|
-
require 'sequel-honeycomb/auto_install'
|
13
|
-
|
14
|
-
require 'honeycomb/env_config'
|
15
|
-
|
16
|
-
module Honeycomb
|
17
|
-
module Beeline
|
18
|
-
LOGGER = if Honeycomb::DEBUG
|
19
|
-
require 'logger'
|
20
|
-
Logger.new($stderr).tap do |l|
|
21
|
-
l.level = Logger::Severity.const_get(Honeycomb::DEBUG)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
INSTRUMENTATIONS = [
|
26
|
-
ActiveRecord::Honeycomb,
|
27
|
-
Faraday::Honeycomb,
|
28
|
-
Rack::Honeycomb,
|
29
|
-
Sequel::Honeycomb,
|
30
|
-
].freeze
|
31
|
-
|
32
|
-
INSTRUMENTATIONS.each do |instrumentation|
|
33
|
-
auto = instrumentation::AutoInstall
|
34
|
-
if auto.available?(logger: LOGGER)
|
35
|
-
hook_label = instrumentation.name.sub(/::Honeycomb$/, '').downcase.to_sym
|
36
|
-
Honeycomb.after_init(hook_label) do |client|
|
37
|
-
auto.auto_install!(honeycomb_client: client, logger: LOGGER)
|
38
|
-
end
|
39
|
-
else
|
40
|
-
LOGGER.debug "Not autoinitialising #{instrumentation.name}" if LOGGER
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
if Honeycomb::ENV_CONFIG
|
47
|
-
Honeycomb.init(logger: Honeycomb::Beeline::LOGGER, **Honeycomb::ENV_CONFIG)
|
48
|
-
end
|
data/lib/honeycomb/env_config.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
module Honeycomb
|
2
|
-
ENV_CONFIG = begin
|
3
|
-
writekey = ENV['HONEYCOMB_WRITEKEY']
|
4
|
-
dataset = ENV['HONEYCOMB_DATASET'] || ENV['PWD'].split('/').last
|
5
|
-
|
6
|
-
withouts = ENV['HONEYCOMB_WITHOUT'] || ''
|
7
|
-
without = withouts.split(',').map(&:to_sym)
|
8
|
-
|
9
|
-
if writekey
|
10
|
-
{writekey: writekey, dataset: dataset, without: without}.freeze
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
DEBUG = if ENV.key?('HONEYCOMB_DEBUG')
|
15
|
-
ENV['HONEYCOMB_DEBUG'].upcase.to_sym
|
16
|
-
end
|
17
|
-
end
|