Sha256: 3f689c65906af51f2d5818f61514278884716c844a3bf444a180dcc52e5bf7c0

Contents?: true

Size: 885 Bytes

Versions: 5

Compression:

Stored size: 885 Bytes

Contents

require 'ddtrace/buffer'
require 'ddtrace/utils/string_table'
require 'ddtrace/utils/object_set'

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 < Datadog::ThreadSafeBuffer
      def initialize(*args)
        super
        @caches = {}
        @string_table = Utils::StringTable.new
      end

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

      def string_table
        synchronize do
          @string_table
        end
      end

      protected

      def drain!
        items = super

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

        items
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ddtrace-0.51.1 lib/ddtrace/profiling/buffer.rb
ddtrace-0.51.0 lib/ddtrace/profiling/buffer.rb
ddtrace-0.50.0 lib/ddtrace/profiling/buffer.rb
ddtrace-0.49.0 lib/ddtrace/profiling/buffer.rb
ddtrace-0.48.0 lib/ddtrace/profiling/buffer.rb