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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48500ccad4e9926d90a6f5e7d113680f599af1dd4d438ec70733b9b07a377bf8
4
- data.tar.gz: 9930ce6b12ef0bfb4982e8522d898eece22b454b7ee0dc82b7a71b37be5096ca
3
+ metadata.gz: f65f45f97eb6323a3505d0d1d617ce6a4eeb4738ef284f79f3741f302b076d4d
4
+ data.tar.gz: 3f965ee5b5a402a3d2120a97d14620f3f590731339d7c94b0581f1a22906be94
5
5
  SHA512:
6
- metadata.gz: 06acd7ce8c4100e06efbe9726fb4df04d30d82981a3cfd9b7e7292b39cf94f2a86b1632dfcd7936ccaa7e8e5da503607e29d1747d998812a83fc3dd3ce31922f
7
- data.tar.gz: ac0167afb29ca3cf072858f1fecf54cfb9e6595919cdf9d58badee03513957cd476849c0efcdf785fb8b569900d1b530a55a0c5acff5f247bfa5257af0c62c2e
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(mod)
8
- # TODO ugh clean this up
9
- @client ||= begin
10
- if defined?(::Honeycomb.client)
11
- ::Honeycomb.client
12
- else
13
- raise "Can't work without magic global Honeycomb.client at the moment"
14
- end
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 execute(sql, opts=OPTS, &block)
29
- raise 'something went horribly wrong' unless builder # TODO
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
@@ -1,6 +1,6 @@
1
1
  module Sequel
2
2
  module Honeycomb
3
3
  GEM_NAME = 'sequel-honeycomb'
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.1'
5
5
  end
6
6
  end
@@ -4,10 +4,13 @@ require 'sequel/extensions/honeycomb'
4
4
  module Sequel
5
5
  module Honeycomb
6
6
  class << self
7
- def register!(client: nil, logger: nil)
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.register!(client: honeycomb_client, logger: logger)
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.2.1
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-05-24 00:00:00.000000000 Z
11
+ date: 2018-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libhoney