sequel-honeycomb 0.0.2 → 0.1.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: 80b4b58cc0b669df320f3d0ed02002b65df1456a956845de5985894a1e35903c
4
- data.tar.gz: 3ef61613425170120459d6d37f2bcf76a16140388cfb6ab3819e1d2b098cb66f
3
+ metadata.gz: dd6bba551d991b93f6d674181f560d1da0b1d0029e91af6c031efe3a30aedb81
4
+ data.tar.gz: afe106f001b62a578d2aa790c48e326229ae6d0ebee80faef75bccc2790915df
5
5
  SHA512:
6
- metadata.gz: 8e44054feb8392fc11b889387da001de855cb2a7bfd0cbc231fb7c6432dfde2caef51a780b97db1c83f1381a173230d53c4018a2ac3b97854255123e761e84b8
7
- data.tar.gz: 0e8a9d092b3961b58facdffcae89406e9b0e0e8099e86b7bd30353bb5f66b6f3a299ac031c448ff66305db3882492d4d6f4c61affc2a5313d4c271f4ae942196
6
+ metadata.gz: 2ea2a4bbfa77eb08d9538bf00ee453bb273ade0b8cbdd45cb99c489812172caeb1c56044018b76608d5bb42be048ca06a107091b0f305f27c58a53a319741512
7
+ data.tar.gz: 73120d7414a2d93d382cf41f6bb214beb80400f98636c234f153de4b996f57488ccf05210d3caf5c0f09d8f0760d23b0fa6ebaa25c271252c7bc92b31e71a5a3
@@ -12,7 +12,7 @@ module Sequel
12
12
  def auto_install!(honeycomb_client:, logger: nil)
13
13
  require 'sequel/honeycomb'
14
14
 
15
- Sequel::Honeycomb.register!(honeycomb_client: honeycomb_client)
15
+ Sequel::Honeycomb.register!(client: honeycomb_client, logger: logger)
16
16
  end
17
17
  end
18
18
  end
@@ -14,49 +14,58 @@ module Sequel
14
14
  end
15
15
  end
16
16
  mod.class_exec(@client) do |honeycomb_|
17
- define_method(:honeycomb) { 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
18
24
  end
19
25
  end
20
26
  end
21
27
 
22
28
  def execute(sql, opts=OPTS, &block)
23
- raise 'something went horribly wrong' unless honeycomb # TODO
29
+ raise 'something went horribly wrong' unless builder # TODO
24
30
 
25
- event = honeycomb.event
31
+ event = builder.event
26
32
 
27
- event.add_field :table, first_source_table rescue nil
28
- event.add_field :sql, sql
33
+ event.add_field 'db.table', first_source_table.to_s rescue nil
34
+ event.add_field 'db.sql', sql
35
+ event.add_field 'name', query_name(sql)
29
36
  start = Time.now
30
37
  adding_span_metadata_if_available(event) do
31
38
  super
32
39
  end
33
40
  rescue Exception => e
34
41
  if event
35
- event.add_field :exception_class, e.class
36
- event.add_field :exception_message, e.message
42
+ event.add_field 'db.error', e.class.name
43
+ event.add_field 'db.error_detail', e.message
37
44
  end
38
45
  raise
39
46
  ensure
40
47
  if start && event
41
48
  finish = Time.now
42
49
  duration = finish - start
43
- event.add_field :durationMs, duration * 1000
50
+ event.add_field 'duration_ms', duration * 1000
44
51
  event.send
45
52
  end
46
53
  end
47
54
 
48
55
  private
56
+ def query_name(sql)
57
+ sql.sub(/\s+.*/, '').upcase
58
+ end
59
+
49
60
  def adding_span_metadata_if_available(event)
50
61
  return yield unless defined?(::Honeycomb.trace_id)
51
62
 
52
63
  trace_id = ::Honeycomb.trace_id
53
- name = first_source_table rescue 'sql'
54
64
 
55
65
  event.add_field :traceId, trace_id if trace_id
56
66
  span_id = SecureRandom.uuid
57
67
  event.add_field :id, span_id
58
68
  event.add_field :serviceName, 'sequel'
59
- event.add_field :name, name if name
60
69
 
61
70
  ::Honeycomb.with_span_id(span_id) do |parent_span_id|
62
71
  event.add_field :parentId, parent_span_id
@@ -4,9 +4,9 @@ require 'sequel/extensions/honeycomb'
4
4
  module Sequel
5
5
  module Honeycomb
6
6
  class << self
7
- def register!(honeycomb_client: nil)
8
- if honeycomb_client
9
- Sequel::Extensions::Honeycomb.client = honeycomb_client
7
+ def register!(client: nil)
8
+ if client
9
+ Sequel::Extensions::Honeycomb.client = client
10
10
  end
11
11
 
12
12
  Sequel::Database.extension :honeycomb
@@ -1,6 +1,6 @@
1
1
  module Sequel
2
2
  module Honeycomb
3
3
  GEM_NAME = 'sequel-honeycomb'
4
- VERSION = '0.0.2'
4
+ VERSION = '0.1.0'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-honeycomb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.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-21 00:00:00.000000000 Z
11
+ date: 2018-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: libhoney
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: sequel
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +52,20 @@ dependencies:
38
52
  - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pg
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: rake
43
71
  requirement: !ruby/object:Gem::Requirement