Sha256: 82b235ebc7dd0b176c15df57e1f9c8dcbc71257595a049591e7e3cb47d5eb143

Contents?: true

Size: 972 Bytes

Versions: 57

Compression:

Stored size: 972 Bytes

Contents

# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2021

require 'singleton'

module Instana
  module Backend
    # Keeps track of garbage collector related metrics
    # @since 1.197.0
    class GCSnapshot
      include Singleton

      def initialize
        ::GC::Profiler.enable

        @last_major_count = 0
        @last_minor_count = 0
      end

      def report
        stats = ::GC.stat
        total_time = ::GC::Profiler.total_time * 1000

        ::GC::Profiler.clear

        payload = {
          totalTime: total_time,
          heap_live: stats[:heap_live_slots] || stats[:heap_live_num],
          heap_free: stats[:heap_free_slots] || stats[:heap_free_num],
          minorGcs: stats[:minor_gc_count] - @last_minor_count,
          majorGcs: stats[:major_gc_count] - @last_major_count
        }

        @last_major_count = stats[:major_gc_count]
        @last_minor_count = stats[:minor_gc_count]

        payload
      end
    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
instana-1.209.6 lib/instana/backend/gc_snapshot.rb
instana-1.209.5 lib/instana/backend/gc_snapshot.rb
instana-1.209.4 lib/instana/backend/gc_snapshot.rb
instana-1.209.3 lib/instana/backend/gc_snapshot.rb
instana-1.209.2 lib/instana/backend/gc_snapshot.rb
instana-1.209.1 lib/instana/backend/gc_snapshot.rb
instana-1.209.0.pre3 lib/instana/backend/gc_snapshot.rb
instana-1.209.0.pre2 lib/instana/backend/gc_snapshot.rb
instana-1.209.0.pre1 lib/instana/backend/gc_snapshot.rb
instana-1.208.0 lib/instana/backend/gc_snapshot.rb
instana-1.207.0 lib/instana/backend/gc_snapshot.rb
instana-1.206.0 lib/instana/backend/gc_snapshot.rb
instana-1.205.0 lib/instana/backend/gc_snapshot.rb
instana-1.204.0 lib/instana/backend/gc_snapshot.rb
instana-1.204.0.pre3 lib/instana/backend/gc_snapshot.rb
instana-1.204.0.pre2 lib/instana/backend/gc_snapshot.rb
instana-1.204.0.pre1 lib/instana/backend/gc_snapshot.rb
instana-1.203.2 lib/instana/backend/gc_snapshot.rb
instana-1.203.1 lib/instana/backend/gc_snapshot.rb
instana-1.203.0 lib/instana/backend/gc_snapshot.rb