activerecord-honeycomb 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5513e1bf298b293e26b56aeaeb4d01d1f30f1f886523af3d7207c94c3649b191
4
- data.tar.gz: 44d8d740273a31a1c0474f5225ee6879a43afa903fbfdf7854e6a6c5372eb1e8
3
+ metadata.gz: e2bc4eab86d0578bcb7c93ef32c30c4b49b68a8b5140611253d9cc45572a1f66
4
+ data.tar.gz: 8c597b10ed77363ea930a794ccbf9f7bb91f93b1782e42671bcf115b7983b7b2
5
5
  SHA512:
6
- metadata.gz: d4c0dc2140357e734883e1da31c64d13917b1d8e8cb45f7438b524ebfd6fd7918874e2324b7b8296c0222e02a21465981f3c0114acada918f3c62daae1e1b9e0
7
- data.tar.gz: 8f0bfed8173a460fe3fe505191aeb7b1236b55a26e127b7b911675e94d19493347f65bf2381f1964ad9a0312b3882a082eec191555199057176050ac5fc41ce4
6
+ metadata.gz: 5320563ca868a56c0245042e13e4a0cd5eb0321e35f60cf06ab711571d6ac1ac49683f33ce2fb0675ff4de4f750d652dc5e783200f7ea492858b0a2f8bd85acd
7
+ data.tar.gz: d65ea71e23b8a0cc71d1e4579687dac3393ec11a7d3ec38213d0876ed0e94ae417adc527a68fc1dd8ed696f7cc4e3a52ee1ddf44ccb0c1fe80861da6b7b7d06f
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Honeycomb Tracing for ActiveRecord
2
+
3
+ [![Build Status](https://travis-ci.org/honeycombio/activerecord-honeycomb.svg?branch=master)](https://travis-ci.org/honeycombio/activerecord-honeycomb)
4
+ [![Gem Version](https://badge.fury.io/rb/activerecord-honeycomb.svg)](https://badge.fury.io/rb/activerecord-honeycomb)
5
+
6
+ This package makes it easy to instrument your ActiveRecord queries in your ruby application to send useful events to [Honeycomb](https://www.honeycomb.io), a service for debugging your software in production.
7
+ - [Usage and Examples](https://docs.honeycomb.io/getting-data-in/beelines/ruby-beeline/)
8
+
9
+ Sign up for a [Honeycomb
10
+ trial](https://ui.honeycomb.io/signup) to obtain an API key before starting.
11
+
12
+ ## Compatible with
13
+
14
+ Requires Ruby version 2.2 or later
15
+
16
+ ActiveRecord 4 or later
17
+
18
+ ## Get in touch
19
+
20
+ Please reach out to [support@honeycomb.io](mailto:support@honeycomb.io) or ping
21
+ us with the chat bubble on [our website](https://www.honeycomb.io) for any
22
+ assistance. We also welcome [bug reports](https://github.com/honeycombio/activerecord-honeycomb/issues).
23
+
24
+ ## Contributions
25
+
26
+ Features, bug fixes and other changes to `activerecord-honeycomb` are gladly accepted. Please
27
+ open issues or a pull request with your change. Remember to add your name to the
28
+ CONTRIBUTORS file!
29
+
30
+ All contributions will be released under the Apache License 2.0.
@@ -69,7 +69,7 @@ module ActiveRecord
69
69
 
70
70
  def execute(sql, name = nil, *args)
71
71
  sending_honeycomb_event(sql, name, []) do |event|
72
- adding_span_metadata_if_available(event) do
72
+ with_tracing_if_available(event) do
73
73
  super
74
74
  end
75
75
  end
@@ -77,7 +77,7 @@ module ActiveRecord
77
77
 
78
78
  def exec_query(sql, name = 'SQL', binds = [], *args)
79
79
  sending_honeycomb_event(sql, name, binds) do |event|
80
- adding_span_metadata_if_available(event) do
80
+ with_tracing_if_available(event) do
81
81
  super
82
82
  end
83
83
  end
@@ -85,7 +85,7 @@ module ActiveRecord
85
85
 
86
86
  def exec_insert(sql, name, binds, *args)
87
87
  sending_honeycomb_event(sql, name, binds) do |event|
88
- adding_span_metadata_if_available(event) do
88
+ with_tracing_if_available(event) do
89
89
  super
90
90
  end
91
91
  end
@@ -93,7 +93,7 @@ module ActiveRecord
93
93
 
94
94
  def exec_delete(sql, name, binds = [], *args)
95
95
  sending_honeycomb_event(sql, name, binds) do |event|
96
- adding_span_metadata_if_available(event) do
96
+ with_tracing_if_available(event) do
97
97
  super
98
98
  end
99
99
  end
@@ -101,7 +101,7 @@ module ActiveRecord
101
101
 
102
102
  def exec_update(sql, name, binds = [], *args)
103
103
  sending_honeycomb_event(sql, name, binds) do |event|
104
- adding_span_metadata_if_available(event) do
104
+ with_tracing_if_available(event) do
105
105
  super
106
106
  end
107
107
  end
@@ -159,17 +159,32 @@ module ActiveRecord
159
159
  sql.sub(/\s+.*/, '').upcase
160
160
  end
161
161
 
162
- def adding_span_metadata_if_available(event)
163
- return yield unless event && defined?(::Honeycomb.trace_id)
162
+ def with_tracing_if_available(event)
163
+ # return if we are not using the ruby beeline
164
+ return yield unless event && defined?(::Honeycomb)
164
165
 
165
- trace_id = ::Honeycomb.trace_id
166
+ # beeline version <= 0.5.0
167
+ if ::Honeycomb.respond_to? :trace_id
168
+ trace_id = ::Honeycomb.trace_id
169
+ event.add_field 'trace.trace_id', trace_id if trace_id
170
+ span_id = SecureRandom.uuid
171
+ event.add_field 'trace.span_id', span_id
166
172
 
167
- event.add_field 'trace.trace_id', trace_id if trace_id
168
- span_id = SecureRandom.uuid
169
- event.add_field 'trace.span_id', span_id
170
-
171
- ::Honeycomb.with_span_id(span_id) do |parent_span_id|
172
- event.add_field 'trace.parent_id', parent_span_id
173
+ ::Honeycomb.with_span_id(span_id) do |parent_span_id|
174
+ event.add_field 'trace.parent_id', parent_span_id
175
+ yield
176
+ end
177
+ # beeline version > 0.5.0
178
+ elsif ::Honeycomb.respond_to? :span_for_existing_event
179
+ ::Honeycomb.span_for_existing_event(
180
+ event,
181
+ name: nil, # leave blank since we set it above
182
+ type: 'db',
183
+ ) do
184
+ yield
185
+ end
186
+ # fallback if we don't detect any known beeline tracing methods
187
+ else
173
188
  yield
174
189
  end
175
190
  end
@@ -1,6 +1,6 @@
1
1
  module ActiveRecord
2
2
  module Honeycomb
3
3
  GEM_NAME = 'activerecord-honeycomb'
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-honeycomb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.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-11-16 00:00:00.000000000 Z
11
+ date: 2018-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libhoney
@@ -143,6 +143,7 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
+ - README.md
146
147
  - lib/active_record/connection_adapters/honeycomb_adapter.rb
147
148
  - lib/active_record/honeycomb.rb
148
149
  - lib/active_record/honeycomb/version.rb