Sha256: 194ebbaeb70e90364a6f0f75b9a2122672b88cab1d280cb6678a6689b0e813f3

Contents?: true

Size: 899 Bytes

Versions: 5

Compression:

Stored size: 899 Bytes

Contents

# typed: true
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.54.2 lib/ddtrace/profiling/buffer.rb
ddtrace-0.54.1 lib/ddtrace/profiling/buffer.rb
ddtrace-0.54.0 lib/ddtrace/profiling/buffer.rb
ddtrace-0.53.0 lib/ddtrace/profiling/buffer.rb
ddtrace-0.52.0 lib/ddtrace/profiling/buffer.rb