sequel-honeycomb 0.2.1 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sequel/extensions/honeycomb.rb +25 -19
- data/lib/sequel/honeycomb/version.rb +1 -1
- data/lib/sequel/honeycomb.rb +4 -1
- data/lib/sequel-honeycomb/auto_install.rb +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f65f45f97eb6323a3505d0d1d617ce6a4eeb4738ef284f79f3741f302b076d4d
|
4
|
+
data.tar.gz: 3f965ee5b5a402a3d2120a97d14620f3f590731339d7c94b0581f1a22906be94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f37ad84cc4896478523b863e37f36375ef411d16a718ce62f8d89d27befd796f0863538fdfb02092f549b37dd8b5eb98abd9532eb869afb525f15183f7b20618
|
7
|
+
data.tar.gz: 292683937a9bf87c0b6715f0fe99ce1d8638a08186dfad842e5cba7ce7117953816de0154888271682d044704c2591d440e0c7d8dccd0dfd7cd2dd2e40acb62f
|
@@ -3,31 +3,37 @@ module Sequel
|
|
3
3
|
module Honeycomb
|
4
4
|
class << self
|
5
5
|
attr_accessor :client
|
6
|
+
attr_reader :builder
|
7
|
+
attr_accessor :logger
|
6
8
|
|
7
|
-
def included(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
mod.class_exec(@client) do |honeycomb_|
|
17
|
-
define_method(:builder) do
|
18
|
-
honeycomb_.builder.add(
|
19
|
-
'meta.package' => 'sequel',
|
20
|
-
'meta.package_version' => Sequel::VERSION,
|
21
|
-
'type' => 'db',
|
22
|
-
)
|
23
|
-
end
|
9
|
+
def included(klazz)
|
10
|
+
if @client
|
11
|
+
debug "initialized with #{@client.class.name} explicitly provided"
|
12
|
+
elsif defined?(::Honeycomb.client)
|
13
|
+
debug "initialized with #{::Honeycomb.client.class.name} from honeycomb-beeline"
|
14
|
+
@client = ::Honeycomb.client
|
15
|
+
else
|
16
|
+
raise "Please set #{self.name}.client before using this extension"
|
24
17
|
end
|
18
|
+
|
19
|
+
@builder ||= @client.builder.add(
|
20
|
+
'meta.package' => 'sequel',
|
21
|
+
'meta.package_version' => Sequel::VERSION,
|
22
|
+
'type' => 'db',
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def debug(msg)
|
28
|
+
@logger.debug("#{self.name}: #{msg}") if @logger
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
28
|
-
def
|
29
|
-
|
32
|
+
def builder
|
33
|
+
Sequel::Extensions::Honeycomb.builder
|
34
|
+
end
|
30
35
|
|
36
|
+
def execute(sql, opts=OPTS, &block)
|
31
37
|
event = builder.event
|
32
38
|
|
33
39
|
event.add_field 'db.table', first_source_table.to_s rescue nil
|
data/lib/sequel/honeycomb.rb
CHANGED
@@ -4,10 +4,13 @@ require 'sequel/extensions/honeycomb'
|
|
4
4
|
module Sequel
|
5
5
|
module Honeycomb
|
6
6
|
class << self
|
7
|
-
def
|
7
|
+
def install!(client: nil, logger: nil)
|
8
8
|
if client
|
9
9
|
Sequel::Extensions::Honeycomb.client = client
|
10
10
|
end
|
11
|
+
if logger
|
12
|
+
Sequel::Extensions::Honeycomb.logger = logger
|
13
|
+
end
|
11
14
|
|
12
15
|
Sequel::Database.extension :honeycomb
|
13
16
|
end
|
@@ -2,17 +2,19 @@ module Sequel
|
|
2
2
|
module Honeycomb
|
3
3
|
module AutoInstall
|
4
4
|
class << self
|
5
|
-
def available?(
|
5
|
+
def available?(logger: nil)
|
6
6
|
gem 'sequel'
|
7
|
+
logger.debug "#{self.name}: detected sequel, okay to autoinitialise" if logger
|
7
8
|
true
|
8
|
-
rescue Gem::LoadError
|
9
|
+
rescue Gem::LoadError => e
|
10
|
+
logger.debug "Didn't detect Sequel (#{e.class}: #{e.message}), not autoinitialising sequel-honeycomb" if logger
|
9
11
|
false
|
10
12
|
end
|
11
13
|
|
12
14
|
def auto_install!(honeycomb_client:, logger: nil)
|
13
15
|
require 'sequel/honeycomb'
|
14
16
|
|
15
|
-
Sequel::Honeycomb.
|
17
|
+
Sequel::Honeycomb.install!(client: honeycomb_client, logger: logger)
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel-honeycomb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
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-
|
11
|
+
date: 2018-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libhoney
|