Sha256: 2bb1a41f0bafe5742f18b8497865b4099b97e4580f8172f8e5c0a25715cbabfe

Contents?: true

Size: 761 Bytes

Versions: 3

Compression:

Stored size: 761 Bytes

Contents

module Datadog
  module Contrib
    module Redis
      # Quantize contains Redis-specific resource quantization tools.
      module Quantize
        PLACEHOLDER = '?'.freeze
        TOO_LONG_MARK = '...'.freeze
        VALUE_MAX_LEN = 100
        CMD_MAX_LEN = 1000

        module_function

        def format_arg(arg)
          str = arg.to_s
          Utils.truncate(str, VALUE_MAX_LEN, TOO_LONG_MARK)
        rescue StandardError => e
          Datadog::Tracer.log.debug("non formattable Redis arg #{str}: #{e}")
          PLACEHOLDER
        end

        def format_command_args(command_args)
          cmd = command_args.map { |x| format_arg(x) }.join(' ')
          Utils.truncate(cmd, CMD_MAX_LEN, TOO_LONG_MARK)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ddtrace-0.9.2 lib/ddtrace/contrib/redis/quantize.rb
ddtrace-0.9.1 lib/ddtrace/contrib/redis/quantize.rb
ddtrace-0.9.0 lib/ddtrace/contrib/redis/quantize.rb