google-cloud-ruby: Stackdriver Debugger breaks grpc connections when working with Puma's forking/workers

Edit Here’s a StackOverflow question: https://stackoverflow.com/questions/47558606/google-stackdriver-working-with-pumas-cluster-mode-workers-outside-of-google-cl

I’m attempting to get the stackdriver logging gem working with puma’s cluster mode on my own server (e.g. outside of Google Cloud). My set up is a brand new rails 5.1.4 ruby 2.4 app with only the stackdriver gem added. I am able to see all logs in the Stackdriver interface when I run in single-mode, but when I run in cluster-mode I do not see any logs. My application.rb and puma.rb are below. Is there something I need to do with puma’s forking callbacks to enable stackdriver on each forked worker process?

application.rb

require_relative 'boot'

require 'rails/all'

Bundler.require(*Rails.groups)

require "google/cloud/logging/rails"

module StackTest
  class Application < Rails::Application
    config.google_cloud.logging.project_id = "valid-project-id"
    config.google_cloud.logging.keyfile = "config/stackdriver.json"
    config.google_cloud.use_logging = true
    config.google_cloud.logging.log_name = 'stackdriver-puma-test'
  end
end

puma.rb

project_dir = File.expand_path(File.expand_path(File.dirname(__FILE__)) + "/../")
threads_count = Integer(ENV['MAX_THREADS'] || 16)
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads threads_count, threads_count

activate_control_app

rackup DefaultRackup

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 24 (14 by maintainers)

Most upvoted comments

I had problems getting the logging working on a Rails app running on Passenger from GKE (currently only staging). Thought it might be this issue.

However, it turned out to be config.google_cloud.use_debugger = true that was stopping the other services working when using the stackdriver gem. When set to false, the logging now works. I think it’s a service account permissions issue.

Also worth noting is that by default the stackdriver gem is only enabled for production, so an explicit config.google_cloud.use_logging = true is required for staging.

https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/stackdriver/v0.14.0/guides/instrumentation_configuration

@dazuma Can you give us an update?