Sha256: 41a1dd6de303b13ff737852537e204910e22c1e38b4ce31d6a2fa00ad3412fc8

Contents?: true

Size: 972 Bytes

Versions: 8

Compression:

Stored size: 972 Bytes

Contents

# frozen_string_literal: 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

8 entries across 8 versions & 1 rubygems

Version Path
ddtrace-1.14.0 lib/datadog/profiling/buffer.rb
ddtrace-1.13.1 lib/datadog/profiling/buffer.rb
ddtrace-1.13.0 lib/datadog/profiling/buffer.rb
ddtrace-1.12.1 lib/datadog/profiling/buffer.rb
ddtrace-1.12.0 lib/datadog/profiling/buffer.rb
ddtrace-1.11.1 lib/datadog/profiling/buffer.rb
ddtrace-1.11.0 lib/datadog/profiling/buffer.rb
ddtrace-1.11.0.beta1 lib/datadog/profiling/buffer.rb