0
votes

My New Relic Insights is logging pageviews and User Agent info from local machine in dev environment. I have another dev in another city who is also having the development enviroment pageviews and other info being logged.

When I pull up samples, I see localhost:3000, which is my port.

However, the production info is also being logged.

I have New Relic running using Heroku's default set up. It automatically sets the license key as an environment variable. I do not have the license key anywhere in the app, it only set through an environment variable.

If I pull up my local development environment, navigate to port 3000, and refresh, then query New Relic Insights for events in the last minute, I see my city, my user agent info, my visited url and pageview. Our product is in beta, there is really no chance that an actual user in my location is hitting the same random page.

I have tried turning development mode off, monitor off. I cannot understand how this can be happening.

I do have some files hosted on AWS (images and some js), if that matters

Gemfile

group :production do
  gem 'rails_12factor'
  gem 'newrelic_rpm'
end

config/newrelic.yml

common: &default_settings
  license_key: <%= ENV["NEW_RELIC_LICENSE_KEY"] %>

  log_level: info

development:
  <<: *default_settings
  app_name: app-dev
  developer_mode: false
  monitor_mode: false
  agent_enabled: false
test:
  <<: *default_settings
  monitor_mode: false
  developer_mode: false
  agent_enabled: false

production:
  app_name: app-prod
  monitor_mode: true
  agent_enabled: false

  <<: *default_settings

config/puma.rb

  require 'puma_worker_killer'
  ActiveRecord::Base.connection_pool.disconnect!

  PumaWorkerKiller.config do |config|
    config.ram           =  ENV['PUMA_WORKER_KILLER_RAM'] || 1024 # mb
    config.frequency     = 5    # seconds
    config.percent_usage = 0.98
    config.rolling_restart_frequency = 12 * 3600 # 12 hours in seconds
  end

  PumaWorkerKiller.start
end

workers Integer(ENV['WEB_CONCURRENCY'] || 5)

min_threads_count = Integer(ENV['MIN_THREADS'] || 1)

threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)

threads min_threads_count, threads_count

preload_app!

rackup      DefaultRackup
port        ENV['PORT']     || 3000
environment ENV['RACK_ENV'] || 'development'

on_worker_boot do
  # Worker specific setup for Rails 4.1+
  # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
  # @sidekiq_pid ||= spawn('bundle exec sidekiq -c 2 -q default -q mailers')


  ActiveSupport.on_load(:active_record) do
    ActiveRecord::Base.establish_connection
  end
end

config/initializers/sidekiq.rb

require 'sidekiq'
redis_url = ENV['REDISTOGO_URL']

redis_config = {
  url: redis_url,
  namespace: 'oct',
}

Sidekiq.configure_server do |config|
  config.redis = {
     url:  ENV["REDISTOGO_URL"], namespace: 'app', 
    size:  ENV["SIDEKIQ_SERVER_CONNECTIONS"].to_i || 6
  }

  config.error_handlers << Proc.new do |exception, context_hash|
    SidekiqErrorService.new(exception, context_hash).notify
  end
end

Sidekiq.configure_client do |config|
  config.redis = { 
    url:  ENV["REDISTOGO_URL"], namespace: 'app', 
    size:  ENV["REDIS_CLIENT_CONNECTION_SIZE"].to_i || 2
  }
end
1

1 Answers

0
votes

So I believe it was the New Relic Browser JS that I included in the head of my pages. Once I set that to - if production_environment? (my helper method), then I only saw production environment traffic.

I believe that something in that JS was pinging my New Relic.

Fixed now.