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 +4 -4
- data/lib/sequel-honeycomb/auto_install.rb +1 -1
- data/lib/sequel/extensions/honeycomb.rb +19 -10
- data/lib/sequel/honeycomb.rb +3 -3
- data/lib/sequel/honeycomb/version.rb +1 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd6bba551d991b93f6d674181f560d1da0b1d0029e91af6c031efe3a30aedb81
|
4
|
+
data.tar.gz: afe106f001b62a578d2aa790c48e326229ae6d0ebee80faef75bccc2790915df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
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(:
|
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
|
29
|
+
raise 'something went horribly wrong' unless builder # TODO
|
24
30
|
|
25
|
-
event =
|
31
|
+
event = builder.event
|
26
32
|
|
27
|
-
event.add_field
|
28
|
-
event.add_field
|
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
|
36
|
-
event.add_field
|
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
|
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
|
data/lib/sequel/honeycomb.rb
CHANGED
@@ -4,9 +4,9 @@ require 'sequel/extensions/honeycomb'
|
|
4
4
|
module Sequel
|
5
5
|
module Honeycomb
|
6
6
|
class << self
|
7
|
-
def register!(
|
8
|
-
if
|
9
|
-
Sequel::Extensions::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
|
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
|
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-
|
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
|