Skip to content

Commit a267b6d

Browse files
committed
Disable honeycomb and newrelic in test env
1 parent e7c2423 commit a267b6d

File tree

8 files changed

+40
-29
lines changed

8 files changed

+40
-29
lines changed

Gemfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ git_source(:github) do |repo_name|
1010
end
1111

1212
group :production do
13+
gem "honeycomb-rails"
1314
gem "nakayoshi_fork"
1415
end
1516

@@ -50,7 +51,6 @@ gem "front_matter_parser", "~> 0.2"
5051
gem "gemoji", "~> 3.0.0"
5152
gem "gibbon", "~> 2.2"
5253
gem "google-api-client", "~> 0.27"
53-
gem "honeycomb-rails"
5454
gem "html_truncator", "~> 0.4"
5555
gem "httparty", "~> 0.16"
5656
gem "inline_svg", "~> 1.3"
@@ -59,7 +59,6 @@ gem "jquery-rails", "~> 4.3"
5959
gem "kaminari", "~> 1.1"
6060
gem "libhoney", "~> 1.11"
6161
gem "liquid", "~> 4.0"
62-
gem 'newrelic_rpm', "~> 9.6"
6362
gem "nokogiri", "~> 1.10"
6463
gem "octokit", "~> 4.13"
6564
gem "omniauth", "~> 1.9"
@@ -108,6 +107,7 @@ gem "webpush", "~> 0.3"
108107

109108
group :localproduction, :development do
110109
gem 'meta_request', "~> 0.7"
110+
gem 'newrelic_rpm', "~> 9.6"
111111
end
112112

113113
group :development do
@@ -154,14 +154,14 @@ group :test do
154154
gem "launchy", "~> 2.4"
155155
gem "pundit-matchers", "~> 1.6"
156156
gem "rails-controller-testing", "~> 1.0"
157-
gem "ruby-prof", "~> 0.17", require: false
157+
gem "ruby-prof", "~> 1.6", require: false
158158
gem "selenium-webdriver", "~> 3.141"
159159
gem "shoulda-matchers", "4.0.0.rc1", require: false
160160
gem "simplecov", "~> 0.16", require: false
161161
gem "sinatra", "~> 2.0"
162162
gem "stackprof", "~> 0.2", require: false, platforms: :ruby
163163
gem "stripe-ruby-mock", "~> 2.5", require: "stripe_mock"
164-
gem "test-prof", "~> 0.7"
164+
gem "test-prof", "~> 1.3"
165165
gem "timecop", "~> 0.9"
166166
gem "webmock", "~> 3.5"
167167
gem "zonebie", "~> 0.6.1"

Gemfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ GEM
806806
rubocop-rspec (1.31.0)
807807
rubocop (>= 0.60.0)
808808
ruby-next-core (0.15.3)
809-
ruby-prof (0.17.0)
809+
ruby-prof (1.6.3)
810810
ruby-progressbar (1.10.0)
811811
ruby_dep (1.5.0)
812812
rubyzip (1.3.0)
@@ -886,7 +886,7 @@ GEM
886886
activesupport (>= 4.0)
887887
sprockets (>= 3.0.0)
888888
staccato (0.5.1)
889-
stackprof (0.2.12)
889+
stackprof (0.2.25)
890890
storext (2.2.2)
891891
rails (>= 4.0, < 6.0)
892892
virtus
@@ -897,7 +897,7 @@ GEM
897897
dante (>= 0.2.0)
898898
multi_json (~> 1.0)
899899
stripe (>= 2.0.3)
900-
test-prof (0.7.3)
900+
test-prof (1.3.0)
901901
thor (0.20.3)
902902
thread_safe (0.3.6)
903903
tilt (2.0.9)
@@ -1079,7 +1079,7 @@ DEPENDENCIES
10791079
rspec-retry (~> 0.6)
10801080
rubocop (~> 0.63)
10811081
rubocop-rspec (~> 1.31)
1082-
ruby-prof (~> 0.17)
1082+
ruby-prof (~> 1.6)
10831083
rubyzip (~> 1.2, >= 1.2.2)
10841084
s3_direct_upload (~> 0.1)
10851085
sail (~> 1.5)
@@ -1102,7 +1102,7 @@ DEPENDENCIES
11021102
storext (~> 2.2)
11031103
stripe (~> 4.8)
11041104
stripe-ruby-mock (~> 2.5)
1105-
test-prof (~> 0.7)
1105+
test-prof (~> 1.3)
11061106
timber (~> 2.6)
11071107
timecop (~> 0.9)
11081108
tty-command (~> 0.10)

config/environments/test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
logger = Timber::Logger.new(nil)
5454
logger.level = config.log_level
5555
# config.logger = ActiveSupport::TaggedLogging.new(logger)
56-
config.logger = Logger.new(nil)
56+
config.logger = ActiveSupport::TaggedLogging.new(Logger.new(nil))
5757
config.log_level = :fatal
5858
end

config/initializers/honeycomb.rb

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
require "libhoney"
1+
unless Rails.env.test?
2+
require "libhoney"
23

3-
key = ApplicationConfig["HONEYCOMB_API_KEY"]
4-
dataset = "dev.to-#{Rails.env}"
4+
key = ApplicationConfig["HONEYCOMB_API_KEY"]
5+
dataset = "dev.to-#{Rails.env}"
56

6-
$libhoney = if Rails.env.development? || Rails.env.localproduction? || Rails.env.test?
7-
Libhoney::NullClient.new
8-
else
9-
Libhoney::Client.new(
10-
writekey: key,
11-
dataset: dataset,
12-
user_agent_addition: HoneycombRails::USER_AGENT_SUFFIX,
13-
)
14-
end
7+
$libhoney = if Rails.env.development? || Rails.env.localproduction?
8+
Libhoney::NullClient.new
9+
else
10+
Libhoney::Client.new(
11+
writekey: key,
12+
dataset: dataset,
13+
user_agent_addition: HoneycombRails::USER_AGENT_SUFFIX,
14+
)
15+
end
1516

16-
HoneycombRails.configure do |conf|
17-
conf.writekey = key
18-
conf.dataset = dataset
19-
conf.db_dataset = "dev.to-db-#{Rails.env}"
20-
conf.client = $libhoney
17+
HoneycombRails.configure do |conf|
18+
conf.writekey = key
19+
conf.dataset = dataset
20+
conf.db_dataset = "dev.to-db-#{Rails.env}"
21+
conf.client = $libhoney
22+
end
2123
end

config/newrelic.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ localproduction:
5858
app_name: 'DEV.to fork (Local Production)'
5959

6060
test:
61-
<<: *default_settings
6261
# It doesn't make sense to report to New Relic from automated test runs.
6362
monitor_mode: false
6463

lib/instrumentation.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
module Instrumentation
22
def add_param_context(*keys)
3+
return if Rails.env.test?
4+
35
keys.each do |key|
46
honeycomb_metadata[key] = params[key]
57
end
68
end
79

810
def add_context(metadata)
11+
return if Rails.env.test?
12+
913
metadata.each do |key, value|
1014
honeycomb_metadata[key] = value
1115
end
1216
end
1317

1418
def append_to_honeycomb(request, controller_name)
19+
return if Rails.env.test?
1520
return if honeycomb_metadata.nil?
1621

1722
honeycomb_metadata["trace.trace_id"] = request.request_id

spec/rails_helper.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
require "pundit/rspec"
1313
require "webmock/rspec"
1414
require "test_prof/recipes/rspec/before_all"
15+
require "test_prof/recipes/rspec/sample"
1516

1617
# Requires supporting ruby files with custom matchers and macros, etc, in
1718
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
@@ -37,6 +38,10 @@
3738
# Disable internet connection with Webmock
3839
WebMock.disable_net_connect!(allow_localhost: true)
3940

41+
TestProf::StackProf.configure do |config|
42+
config.format = 'json'
43+
end
44+
4045
RSpec.configure do |config|
4146
config.fixture_path = "#{::Rails.root}/spec/fixtures"
4247

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require "simplecov"
1+
# require "simplecov"
22
require "zonebie/rspec"
33

44
# This file was generated by the `rails generate rspec:install` command. Conventionally, all

0 commit comments

Comments
 (0)