DEV: Bypass linux-only features when running in macOS

DEV: Bypass linux-only features when running in macOS

diff --git a/lib/internal_metric/global.rb b/lib/internal_metric/global.rb
index d9ebc19..cf7fa3f 100644
--- a/lib/internal_metric/global.rb
+++ b/lib/internal_metric/global.rb
@@ -52,7 +52,7 @@ module DiscoursePrometheus::InternalMetric
         redis_slave_running = test_redis(:slave, redis_config[:slave_host], redis_config[:slave_port], redis_config[:password])
       end
 
-      net_stats = Raindrops::Linux::tcp_listener_stats("0.0.0.0:3000")["0.0.0.0:3000"]
+      net_stats = Raindrops::Linux::tcp_listener_stats("0.0.0.0:3000")["0.0.0.0:3000"] unless RbConfig::CONFIG["arch"] =~ /darwin/
 
       @postgres_readonly_mode = primary_site_readonly?
       @transient_readonly_mode = recently_readonly?
@@ -62,8 +62,8 @@ module DiscoursePrometheus::InternalMetric
       @postgres_replica_available = postgres_replica_running
 
       # active and queued are special metrics that track max
-      @active_app_reqs = [@active_app_reqs, net_stats.active].max
-      @queued_app_reqs = [@queued_app_reqs, net_stats.queued].max
+      @active_app_reqs = [@active_app_reqs, net_stats.active].max if net_stats
+      @queued_app_reqs = [@queued_app_reqs, net_stats.queued].max if net_stats
 
       @sidekiq_jobs_enqueued = begin
         stats = {}
diff --git a/spec/lib/collector_spec.rb b/spec/lib/collector_spec.rb
index 86546a8..98a757b 100644
--- a/spec/lib/collector_spec.rb
+++ b/spec/lib/collector_spec.rb
@@ -68,6 +68,7 @@ module DiscoursePrometheus
     end
 
     it "Can handle process metrics" do
+      skip("skipped because /proc does not exist on macOS") if RbConfig::CONFIG["arch"] =~ /darwin/
       collector = Collector.new
       reporter = Reporter::Process.new(:web)
       collector.process(reporter.collect.to_json)
diff --git a/spec/lib/reporter/process_spec.rb b/spec/lib/reporter/process_spec.rb
index c29686c..470bf65 100644
--- a/spec/lib/reporter/process_spec.rb
+++ b/spec/lib/reporter/process_spec.rb
@@ -6,6 +6,7 @@ module DiscoursePrometheus
   describe Reporter::Process do
     def check_for(metric, *args)
       args.each do |arg|
+        next if arg == :rss && RbConfig::CONFIG["arch"] =~ /darwin/ # macos does not support these metrics
         expect(metric.send arg).to be > 0
       end
     end

GitHub sha: ff422cff