I'm having trouble sending events in production with a Puma server. This problem has been raised in #37 but the solution outlined there doesn't seem to work anymore.
My understanding of the desired behavior here is that we'd want a global $AnalyticsBackend instance that is shared across threads, in order to benefit from the batching mechanism.
Any idea of where to dig further?
Configuration:
- Rails 5.2.2
- Ruby 2.5.3
- Puma 3.12.0
class Analytics
class_attribute :backend, instance_writer: false, default: $AnalyticsBackend
def track(event:, properties: {})
# ...
end
# ...
end
# initializers/analytics.rb
$AnalyticsBackend = Segment::Analytics.new({
write_key: "...",
on_error: Proc.new { |status, msg| print msg }
})
# config/puma.rb
threads 5, 5
workers 2
on_worker_shutdown do
Analytics.flush
end
preload_app!
# ...
I'm having trouble sending events in production with a Puma server. This problem has been raised in #37 but the solution outlined there doesn't seem to work anymore.
My understanding of the desired behavior here is that we'd want a global
$AnalyticsBackendinstance that is shared across threads, in order to benefit from the batching mechanism.Any idea of where to dig further?
Configuration: