Sha256: 43aaabaeba9261bb5dca086a023c3446f579b03f0d3753a5b14958ef0625e757

Contents?: true

Size: 941 Bytes

Versions: 2

Compression:

Stored size: 941 Bytes

Contents

require_relative '../core/buffer/thread_safe'
require_relative '../core/utils/object_set'
require_relative '../core/utils/string_table'

module Datadog
  module Profiling
    # Profiling buffer that stores profiling events. The buffer has a maximum size and when
    # the buffer is full, a random event is discarded. This class is thread-safe.
    class Buffer < Core::Buffer::ThreadSafe
      def initialize(*args)
        super
        @caches = {}
        @string_table = Core::Utils::StringTable.new
      end

      def cache(cache_name)
        synchronize do
          @caches[cache_name] ||= Core::Utils::ObjectSet.new
        end
      end

      def string_table
        synchronize do
          @string_table
        end
      end

      protected

      def drain!
        items = super

        # Clear caches
        @caches = {}
        @string_table = Core::Utils::StringTable.new

        items
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ddtrace-1.10.1 lib/datadog/profiling/buffer.rb
ddtrace-1.10.0 lib/datadog/profiling/buffer.rb