Sha256: 844fddc8bf277b7a8850fb9a6a0e564314e5c3f612e07331b5672e18513043ae

Contents?: true

Size: 432 Bytes

Versions: 12

Compression:

Stored size: 432 Bytes

Contents

# frozen_string_literal: true

require "set"
require "zlib"

module Sentry
  module Metrics
    class SetMetric < Metric
      attr_reader :value

      def initialize(value)
        @value = Set[value]
      end

      def add(value)
        @value << value
      end

      def serialize
        value.map { |x| x.is_a?(String) ? Zlib.crc32(x) : x.to_i }
      end

      def weight
        value.size
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
sentry-ruby-core-5.22.2 lib/sentry/metrics/set_metric.rb
sentry-ruby-5.22.2 lib/sentry/metrics/set_metric.rb
sentry-ruby-core-5.22.1 lib/sentry/metrics/set_metric.rb
sentry-ruby-5.22.1 lib/sentry/metrics/set_metric.rb
sentry-ruby-5.22.0 lib/sentry/metrics/set_metric.rb
sentry-ruby-core-5.22.0 lib/sentry/metrics/set_metric.rb
sentry-ruby-5.21.0 lib/sentry/metrics/set_metric.rb
sentry-ruby-core-5.21.0 lib/sentry/metrics/set_metric.rb
sentry-ruby-5.20.1 lib/sentry/metrics/set_metric.rb
sentry-ruby-core-5.20.1 lib/sentry/metrics/set_metric.rb
sentry-ruby-5.20.0 lib/sentry/metrics/set_metric.rb
sentry-ruby-core-5.20.0 lib/sentry/metrics/set_metric.rb