honeycomb-rails 0.2.0 → 0.3.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: 8c95c50f630565d5361f03554f7b905a373e1a2eb6e3f365e0d94bfd4822089d
4
- data.tar.gz: 573d2276a9733acacc498eb925e6d16e42ec9b6ca54e24d391fe2a234f9f87ce
3
+ metadata.gz: 20540b339eef388e9906ce50a0c3b7efbb8cb282189400bf7230d1005f166ea7
4
+ data.tar.gz: 855af5e90804fdab8f7f2aba2641352673ef5e6ce1abff2953f9926077b2b968
5
5
  SHA512:
6
- metadata.gz: 63883618d112d94d725847a25b216e5420319a2d6b14487475696fce3a6f9d3d4885e64ada33a6eb3ec4d3553bdbaa91b898b3d078d5b10427ee8c90367f4f3f
7
- data.tar.gz: e2919d3b901f50d46b9488559e06d116b337057495c134abeb0d7942e1ffac8fedcd9374388537ba19e3a6df1ca271cd259bbf362302a5c9737a60641e6d4708
6
+ metadata.gz: be8cb30c03e21a4ca871d85817526dc627b5c35b8192f047a5342a86656bf45fde7bcf1ac8270603a1d8daec7ac02e54f356a3d0e7449f0f3fbffb668e7ecefa
7
+ data.tar.gz: ce2c4b9085ac5e8471619b3747cc99eb07e7a759ebdd5f8a223bd9decc3ad368fc07789fbd46416cd31caf44f6279c624b1a6f972a384f8bb49c1563976d2582
@@ -8,6 +8,7 @@ module HoneycombRails
8
8
  @db_dataset = 'active_record'
9
9
  @record_flash = true
10
10
  @record_user = :detect
11
+ @logger = Rails.logger
11
12
  end
12
13
 
13
14
  # Whether to record flash messages (default: true).
@@ -17,6 +18,10 @@ module HoneycombRails
17
18
  !!@record_flash
18
19
  end
19
20
 
21
+ # If set, routes HoneycombRails-specific log output to this logger
22
+ # (defaults to Rails.logger)
23
+ attr_accessor :logger
24
+
20
25
  # If set, determines how to record the current user during request processing (default: :detect). Set to nil or false to disable.
21
26
  #
22
27
  # Valid values:
@@ -30,10 +35,14 @@ module HoneycombRails
30
35
  # about the current user.
31
36
  attr_accessor :record_user
32
37
 
33
- # The Honeycomb dataset to send request events to (default: 'rails').
38
+ # Send request events to the Honeycomb dataset with this name (default:
39
+ # 'rails'). Set to nil or an empty string to disable.
34
40
  attr_accessor :dataset
35
- # The Honeycomb dataset to send ActiveRecord query events to (default: 'active_record').
41
+
42
+ # Send ActiveRecord query events to the Honeycomb dataset with this name
43
+ # (default: 'active_record'). Set to nil or empty string to disable.
36
44
  attr_accessor :db_dataset
45
+
37
46
  # The Honeycomb write key for your team (must be specified).
38
47
  attr_accessor :writekey
39
48
  end
@@ -44,7 +44,7 @@ module HoneycombRails
44
44
  end
45
45
 
46
46
  def honeycomb_user_metadata_devise
47
- if current_user
47
+ if respond_to?(:current_user) and current_user
48
48
  {
49
49
  current_user_id: current_user.id,
50
50
  current_user_email: current_user.email,
@@ -18,18 +18,29 @@ module HoneycombRails
18
18
  # the app's config/initializers has taken effect.
19
19
  config.after_initialize do
20
20
  writekey = HoneycombRails.config.writekey
21
- dataset = HoneycombRails.config.dataset
22
- @libhoney = Libhoney::Client.new(writekey: writekey, dataset: dataset)
21
+ @libhoney = Libhoney::Client.new(writekey: writekey)
23
22
  end
24
23
 
25
24
  config.after_initialize do
26
- db_builder = @libhoney.builder
27
- db_builder.dataset = HoneycombRails.config.db_dataset
25
+ subscribers = []
28
26
 
29
- [
30
- Subscribers::ProcessAction.new(@libhoney),
31
- Subscribers::ActiveRecord.new(db_builder),
32
- ].each(&:subscribe!)
27
+ if !HoneycombRails.config.dataset.blank?
28
+ req_builder = @libhoney.builder
29
+ req_builder.dataset = HoneycombRails.config.dataset
30
+ subscribers.push(Subscribers::ProcessAction.new(req_builder))
31
+ end
32
+
33
+ if !HoneycombRails.config.db_dataset.blank?
34
+ db_builder = @libhoney.builder
35
+ db_builder.dataset = HoneycombRails.config.db_dataset
36
+ subscribers.push(Subscribers::ActiveRecord.new(db_builder))
37
+ end
38
+
39
+ if subscribers.empty?
40
+ HoneycombRails.config.logger.warn("No subscribers defined (are both HoneycombRails.config.dataset and HoneycombRails.config.db_dataset both blank?")
41
+ end
42
+
43
+ subscribers.each(&:subscribe!)
33
44
  end
34
45
  end
35
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeycomb-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stokes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-11-17 00:00:00.000000000 Z
12
+ date: 2017-12-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: libhoney
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  version: '0'
153
153
  requirements: []
154
154
  rubyforge_project:
155
- rubygems_version: 2.7.2
155
+ rubygems_version: 2.7.3
156
156
  signing_key:
157
157
  specification_version: 4
158
158
  summary: Easily instrument your Rails apps with Honeycomb