Sha256: c5716c11a10d2d94c76d9802fec11792bbb75df9ff010093e0ba554d223d5d6e

Contents?: true

Size: 956 Bytes

Versions: 12

Compression:

Stored size: 956 Bytes

Contents

# typed: true

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

12 entries across 12 versions & 1 rubygems

Version Path
ddtrace-1.9.0 lib/datadog/profiling/buffer.rb
ddtrace-1.8.0 lib/datadog/profiling/buffer.rb
ddtrace-1.7.0 lib/datadog/profiling/buffer.rb
ddtrace-1.6.1 lib/datadog/profiling/buffer.rb
ddtrace-1.6.0 lib/datadog/profiling/buffer.rb
ddtrace-1.5.2 lib/datadog/profiling/buffer.rb
ddtrace-1.5.1 lib/datadog/profiling/buffer.rb
ddtrace-1.5.0 lib/datadog/profiling/buffer.rb
ddtrace-1.4.2 lib/datadog/profiling/buffer.rb
ddtrace-1.4.1 lib/datadog/profiling/buffer.rb
ddtrace-1.4.0 lib/datadog/profiling/buffer.rb
ddtrace-1.3.0 lib/datadog/profiling/buffer.rb