Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump sentry-ruby from 5.16.1 to 5.17.3 #616

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Apr 12, 2024

Bumps sentry-ruby from 5.16.1 to 5.17.3.

Changelog

Sourced from sentry-ruby's changelog.

5.17.3

Features

  • Update key, unit and tags sanitization logic for metrics #2292
  • Consolidate client report and rate limit handling with data categories #2294
  • Record :network_error client reports for send_envelope #2295

Bug Fixes

  • Make sure isolated envelopes respect config.enabled_environments #2291

5.17.2

Features

  • Add Mechanism interface and default to unhandled for integration exceptions #2280

Bug Fixes

  • Don't instantiate connection in ActiveRecordSubscriber (#2278)

5.17.1

Bug Fixes

  • Fix NoMethodError / Make session_tracking check consistent (#2269)

5.17.0

Features

  • Add support for distributed tracing in sentry-delayed_job #2233
  • Fix warning about default gems on Ruby 3.3.0 (#2225)
  • Add hint: support to Sentry::Rails::ErrorSubscriber #2235
  • Add Metrics support
    • Add main APIs and Aggregator thread #2247

    • Add Sentry::Metrics.timing API for measuring block duration #2254

    • Add metric summaries on spans #2255

    • Add config.metrics.before_emit callback #2258

    • Add code locations for metrics #2263

      The SDK now supports recording and aggregating metrics. A new thread will be started for aggregation and will flush the pending data to Sentry every 5 seconds.

      To enable this behavior, use:

      Sentry.init do |config|

... (truncated)

Commits

Dependabot compatibility score

You can trigger a rebase of this PR by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Note
Automatic rebases have been disabled on this pull request as it has been open for over 30 days.

@dependabot dependabot bot added dependencies ruby Pull requests that update Ruby code labels Apr 12, 2024
Copy link

Copy link

gem compare sentry-ruby 5.16.1 5.17.3

Compared versions: ["5.16.1", "5.17.3"]
  DIFFERENT date:
    5.16.1: 2024-01-09 00:00:00 UTC
    5.17.3: 2024-04-11 00:00:00 UTC
  DIFFERENT version:
    5.16.1: 5.16.1
    5.17.3: 5.17.3
  DIFFERENT files:
    5.16.1->5.17.3:
      * Added:
            lib/sentry/interfaces/mechanism.rb +20/-0
            lib/sentry/metrics.rb +55/-0
            lib/sentry/metrics/aggregator.rb +276/-0
            lib/sentry/metrics/configuration.rb +47/-0
            lib/sentry/metrics/counter_metric.rb +25/-0
            lib/sentry/metrics/distribution_metric.rb +25/-0
            lib/sentry/metrics/gauge_metric.rb +35/-0
            lib/sentry/metrics/local_aggregator.rb +53/-0
            lib/sentry/metrics/metric.rb +19/-0
            lib/sentry/metrics/set_metric.rb +28/-0
            lib/sentry/metrics/timing.rb +43/-0
      * Changed:
            README.md +1/-1
            Rakefile +1/-1
            lib/sentry-ruby.rb +15/-3
            lib/sentry/background_worker.rb +1/-1
            lib/sentry/backtrace.rb +7/-3
            lib/sentry/check_in_event.rb +1/-1
            lib/sentry/client.rb +42/-9
            lib/sentry/configuration.rb +19/-11
            lib/sentry/cron/monitor_schedule.rb +1/-1
            lib/sentry/dsn.rb +1/-1
            lib/sentry/envelope.rb +18/-1
            lib/sentry/error_event.rb +2/-2
            lib/sentry/event.rb +8/-8
            lib/sentry/hub.rb +1/-1
            lib/sentry/integrable.rb +4/-0
            lib/sentry/interface.rb +1/-0
            lib/sentry/interfaces/exception.rb +5/-3
            lib/sentry/interfaces/request.rb +2/-2
            lib/sentry/interfaces/single_exception.rb +6/-4
            lib/sentry/interfaces/stacktrace_builder.rb +8/-0
            lib/sentry/propagation_context.rb +9/-8
            lib/sentry/puma.rb +1/-1
            lib/sentry/rack/capture_exceptions.rb +6/-1
            lib/sentry/rake.rb +3/-1
            lib/sentry/scope.rb +7/-2
            lib/sentry/session.rb +2/-2
            lib/sentry/session_flusher.rb +1/-6
            lib/sentry/span.rb +16/-2
            lib/sentry/transaction.rb +15/-14
            lib/sentry/transaction_event.rb +5/-0
            lib/sentry/transport.rb +7/-21
            lib/sentry/transport/configuration.rb +0/-1
            lib/sentry/utils/argument_checking_helper.rb +6/-0
            lib/sentry/utils/real_ip.rb +1/-1
            lib/sentry/utils/request_id.rb +1/-1
            lib/sentry/version.rb +1/-1
            sentry-ruby.gemspec +1/-0
  DIFFERENT extra_rdoc_files:
    5.16.1->5.17.3:
      * Changed:
            README.md +1/-1
  DIFFERENT runtime dependencies:
    5.16.1->5.17.3:
      * Added:
            bigdecimal [">= 0"] (runtime)

Copy link

gem compare --diff sentry-ruby 5.16.1 5.17.3

Compared versions: ["5.16.1", "5.17.3"]
  DIFFERENT files:
    5.16.1->5.17.3:
      * Added:
        lib/sentry/interfaces/mechanism.rb
                --- /tmp/20240412-1908-c69xyl	2024-04-12 02:16:54.982697243 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/interfaces/mechanism.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -0,0 +1,20 @@
                +# frozen_string_literal: true
                +
                +module Sentry
                +  class Mechanism < Interface
                +    # Generic identifier, mostly the source integration for this exception.
                +    # @return [String]
                +    attr_accessor :type
                +
                +    # A manually captured exception has handled set to true,
                +    # false if coming from an integration where we intercept an uncaught exception.
                +    # Defaults to true here and will be set to false explicitly in integrations.
                +    # @return [Boolean]
                +    attr_accessor :handled
                +
                +    def initialize(type: 'generic', handled: true)
                +      @type = type
                +      @handled = handled
                +    end
                +  end
                +end
        lib/sentry/metrics.rb
                --- /tmp/20240412-1908-d2xllp	2024-04-12 02:16:54.986697225 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/metrics.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -0,0 +1,55 @@
                +# frozen_string_literal: true
                +
                +require 'sentry/metrics/metric'
                +require 'sentry/metrics/counter_metric'
                +require 'sentry/metrics/distribution_metric'
                +require 'sentry/metrics/gauge_metric'
                +require 'sentry/metrics/set_metric'
                +require 'sentry/metrics/timing'
                +require 'sentry/metrics/aggregator'
                +
                +module Sentry
                +  module Metrics
                +    DURATION_UNITS = %w[nanosecond microsecond millisecond second minute hour day week]
                +    INFORMATION_UNITS = %w[bit byte kilobyte kibibyte megabyte mebibyte gigabyte gibibyte terabyte tebibyte petabyte pebibyte exabyte exbibyte]
                +    FRACTIONAL_UNITS = %w[ratio percent]
                +
                +    OP_NAME = 'metric.timing'
                +
                +    class << self
                +      def increment(key, value = 1.0, unit: 'none', tags: {}, timestamp: nil)
                +        Sentry.metrics_aggregator&.add(:c, key, value, unit: unit, tags: tags, timestamp: timestamp)
                +      end
                +
                +      def distribution(key, value, unit: 'none', tags: {}, timestamp: nil)
                +        Sentry.metrics_aggregator&.add(:d, key, value, unit: unit, tags: tags, timestamp: timestamp)
                +      end
                +
                +      def set(key, value, unit: 'none', tags: {}, timestamp: nil)
                +        Sentry.metrics_aggregator&.add(:s, key, value, unit: unit, tags: tags, timestamp: timestamp)
                +      end
                +
                +      def gauge(key, value, unit: 'none', tags: {}, timestamp: nil)
                +        Sentry.metrics_aggregator&.add(:g, key, value, unit: unit, tags: tags, timestamp: timestamp)
                +      end
                +
                +      def timing(key, unit: 'second', tags: {}, timestamp: nil, &block)
                +        return unless block_given?
                +        return yield unless DURATION_UNITS.include?(unit)
                +
                +        result, value = Sentry.with_child_span(op: OP_NAME, description: key) do |span|
                +          tags.each { |k, v| span.set_tag(k, v.is_a?(Array) ? v.join(', ') : v.to_s) } if span
                +
                +          start = Timing.send(unit.to_sym)
                +          result = yield
                +          value = Timing.send(unit.to_sym) - start
                +
                +          [result, value]
                +        end
                +
                +        Sentry.metrics_aggregator&.add(:d, key, value, unit: unit, tags: tags, timestamp: timestamp)
                +        result
                +      end
                +    end
                +  end
                +end
        lib/sentry/metrics/aggregator.rb
                --- /tmp/20240412-1908-u53z9x	2024-04-12 02:16:54.986697225 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/metrics/aggregator.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -0,0 +1,276 @@
                +# frozen_string_literal: true
                +
                +module Sentry
                +  module Metrics
                +    class Aggregator
                +      include LoggingHelper
                +
                +      FLUSH_INTERVAL = 5
                +      ROLLUP_IN_SECONDS = 10
                +
                +      # this is how far removed from user code in the backtrace we are
                +      # when we record code locations
                +      DEFAULT_STACKLEVEL = 4
                +
                +      KEY_SANITIZATION_REGEX = /[^a-zA-Z0-9_\-.]+/
                +      UNIT_SANITIZATION_REGEX = /[^a-zA-Z0-9_]+/
                +      TAG_KEY_SANITIZATION_REGEX = /[^a-zA-Z0-9_\-.\/]+/
                +
                +      TAG_VALUE_SANITIZATION_MAP = {
                +        "\n" => "\\n",
                +        "\r" => "\\r",
                +        "\t" => "\\t",
                +        "\\" => "\\\\",
                +        "|" => "\\u{7c}",
                +        "," => "\\u{2c}"
                +      }
                +
                +      METRIC_TYPES = {
                +        c: CounterMetric,
                +        d: DistributionMetric,
                +        g: GaugeMetric,
                +        s: SetMetric
                +      }
                +
                +      # exposed only for testing
                +      attr_reader :client, :thread, :buckets, :flush_shift, :code_locations
                +
                +      def initialize(configuration, client)
                +        @client = client
                +        @logger = configuration.logger
                +        @before_emit = configuration.metrics.before_emit
                +        @enable_code_locations = configuration.metrics.enable_code_locations
                +        @stacktrace_builder = configuration.stacktrace_builder
                +
                +        @default_tags = {}
                +        @default_tags['release'] = configuration.release if configuration.release
                +        @default_tags['environment'] = configuration.environment if configuration.environment
                +
                +        @thread = nil
                +        @exited = false
                +        @mutex = Mutex.new
                +
                +        # a nested hash of timestamp -> bucket keys -> Metric instance
                +        @buckets = {}
                +
                +        # the flush interval needs to be shifted once per startup to create jittering
                +        @flush_shift = Random.rand * ROLLUP_IN_SECONDS
                +
                +        # a nested hash of timestamp (start of day) -> meta keys -> frame
                +        @code_locations = {}
                +      end
                +
                +      def add(type,
                +              key,
                +              value,
                +              unit: 'none',
                +              tags: {},
                +              timestamp: nil,
                +              stacklevel: nil)
                +        return unless ensure_thread
                +        return unless METRIC_TYPES.keys.include?(type)
                +
                +        updated_tags = get_updated_tags(tags)
                +        return if @before_emit && !@before_emit.call(key, updated_tags)
                +
                +        timestamp ||= Sentry.utc_now
                +
                +        # this is integer division and thus takes the floor of the division
                +        # and buckets into 10 second intervals
                +        bucket_timestamp = (timestamp.to_i / ROLLUP_IN_SECONDS) * ROLLUP_IN_SECONDS
                +
                +        serialized_tags = serialize_tags(updated_tags)
                +        bucket_key = [type, key, unit, serialized_tags]
                +
                +        added = @mutex.synchronize do
                +          record_code_location(type, key, unit, timestamp, stacklevel: stacklevel) if @enable_code_locations
                +          process_bucket(bucket_timestamp, bucket_key, type, value)
                +        end
                +
                +        # for sets, we pass on if there was a new entry to the local gauge
                +        local_value = type == :s ? added : value
                +        process_span_aggregator(bucket_key, local_value)
                +      end
                +
                +      def flush(force: false)
                +        flushable_buckets = get_flushable_buckets!(force)
                +        code_locations = get_code_locations!
                +        return if flushable_buckets.empty? && code_locations.empty?
                +
                +        envelope = Envelope.new
                +
                +        unless flushable_buckets.empty?
                +          payload = serialize_buckets(flushable_buckets)
                +          envelope.add_item(
                +            { type: 'statsd', length: payload.bytesize },
                +            payload
                +          )
                +        end
                +
                +        unless code_locations.empty?
                +          code_locations.each do |timestamp, locations|
                +            payload = serialize_locations(timestamp, locations)
                +            envelope.add_item(
                +              { type: 'metric_meta', content_type: 'application/json' },
                +              payload
                +            )
                +          end
                +        end
                +
                +        @client.capture_envelope(envelope)
                +      end
                +
                +      def kill
                +        log_debug('[Metrics::Aggregator] killing thread')
                +
                +        @exited = true
                +        @thread&.kill
                +      end
                +
                +      private
                +
                +      def ensure_thread
                +        return false if @exited
                +        return true if @thread&.alive?
                +
                +        @thread = Thread.new do
                +          loop do
                +            # TODO-neel-metrics use event for force flush later
                +            sleep(FLUSH_INTERVAL)
                +            flush
                +          end
                +        end
                +
                +        true
                +      rescue ThreadError
                +        log_debug('[Metrics::Aggregator] thread creation failed')
                +        @exited = true
                +        false
                +      end
                +
                +      # important to sort for key consistency
                +      def serialize_tags(tags)
                +        tags.flat_map do |k, v|
                +          if v.is_a?(Array)
                +            v.map { |x| [k.to_s, x.to_s] }
                +          else
                +            [[k.to_s, v.to_s]]
                +          end
                +        end.sort
                +      end
                +
                +      def get_flushable_buckets!(force)
                +        @mutex.synchronize do
                +          flushable_buckets = {}
                +
                +          if force
                +            flushable_buckets = @buckets
                +            @buckets = {}
                +          else
                +            cutoff = Sentry.utc_now.to_i - ROLLUP_IN_SECONDS - @flush_shift
                +            flushable_buckets = @buckets.select { |k, _| k <= cutoff }
                +            @buckets.reject! { |k, _| k <= cutoff }
                +          end
                +
                +          flushable_buckets
                +        end
                +      end
                +
                +      def get_code_locations!
                +        @mutex.synchronize do
                +          code_locations = @code_locations
                +          @code_locations = {}
                +          code_locations
                +        end
                +      end
                +
                +      # serialize buckets to statsd format
                +      def serialize_buckets(buckets)
                +        buckets.map do |timestamp, timestamp_buckets|
                +          timestamp_buckets.map do |metric_key, metric|
                +            type, key, unit, tags = metric_key
                +            values = metric.serialize.join(':')
                +            sanitized_tags = tags.map { |k, v| "#{sanitize_tag_key(k)}:#{sanitize_tag_value(v)}" }.join(',')
                +
                +            "#{sanitize_key(key)}@#{sanitize_unit(unit)}:#{values}|#{type}|\##{sanitized_tags}|T#{timestamp}"
                +          end
                +        end.flatten.join("\n")
                +      end
                +
                +      def serialize_locations(timestamp, locations)
                +        mapping = locations.map do |meta_key, location|
                +          type, key, unit = meta_key
                +          mri = "#{type}:#{sanitize_key(key)}@#{sanitize_unit(unit)}"
                +
                +          # note this needs to be an array but it really doesn't serve a purpose right now
                +          [mri, [location.merge(type: 'location')]]
                +        end.to_h
                +
                +        { timestamp: timestamp, mapping: mapping }
                +      end
                +
                +      def sanitize_key(key)
                +        key.gsub(KEY_SANITIZATION_REGEX, '_')
                +      end
                +
                +      def sanitize_unit(unit)
                +        unit.gsub(UNIT_SANITIZATION_REGEX, '')
                +      end
                +
                +      def sanitize_tag_key(key)
                +        key.gsub(TAG_KEY_SANITIZATION_REGEX, '')
                +      end
                +
                +      def sanitize_tag_value(value)
                +        value.chars.map { |c| TAG_VALUE_SANITIZATION_MAP[c] || c }.join
                +      end
                +
                +      def get_transaction_name
                +        scope = Sentry.get_current_scope
                +        return nil unless scope && scope.transaction_name
                +        return nil if scope.transaction_source_low_quality?
                +
                +        scope.transaction_name
                +      end
                +
                +      def get_updated_tags(tags)
                +        updated_tags = @default_tags.merge(tags)
                +
                +        transaction_name = get_transaction_name
                +        updated_tags['transaction'] = transaction_name if transaction_name
                +
                +        updated_tags
                +      end
                +
                +      def process_span_aggregator(key, value)
                +        scope = Sentry.get_current_scope
                +        return nil unless scope && scope.span
                +        return nil if scope.transaction_source_low_quality?
                +
                +        scope.span.metrics_local_aggregator.add(key, value)
                +      end
                +
                +      def process_bucket(timestamp, key, type, value)
                +        @buckets[timestamp] ||= {}
                +
                +        if (metric = @buckets[timestamp][key])
                +          old_weight = metric.weight
                +          metric.add(value)
                +          metric.weight - old_weight
                +        else
                +          metric = METRIC_TYPES[type].new(value)
                +          @buckets[timestamp][key] = metric
                +          metric.weight
                +        end
                +      end
                +
                +      def record_code_location(type, key, unit, timestamp, stacklevel: nil)
                +        meta_key =  [type, key, unit]
                +        start_of_day = Time.utc(timestamp.year, timestamp.month, timestamp.day).to_i
                +
                +        @code_locations[start_of_day] ||= {}
                +        @code_locations[start_of_day][meta_key] ||= @stacktrace_builder.metrics_code_location(caller[stacklevel || DEFAULT_STACKLEVEL])
                +      end
                +    end
                +  end
                +end
        lib/sentry/metrics/configuration.rb
                --- /tmp/20240412-1908-8p5p8e	2024-04-12 02:16:54.990697208 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/metrics/configuration.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -0,0 +1,47 @@
                +# frozen_string_literal: true
                +
                +module Sentry
                +  module Metrics
                +    class Configuration
                +      include ArgumentCheckingHelper
                +
                +      # Enable metrics usage.
                +      # Starts a new {Sentry::Metrics::Aggregator} instance to aggregate metrics
                +      # and a thread to aggregate flush every 5 seconds.
                +      # @return [Boolean]
                +      attr_accessor :enabled
                +
                +      # Enable code location reporting.
                +      # Will be sent once per day.
                +      # True by default.
                +      # @return [Boolean]
                +      attr_accessor :enable_code_locations
                +
                +      # Optional Proc, called before emitting a metric to the aggregator.
                +      # Use it to filter keys (return false/nil) or update tags.
                +      # Make sure to return true at the end.
                +      #
                +      # @example
                +      #   config.metrics.before_emit = lambda do |key, tags|
                +      #     return nil if key == 'foo'
                +      #     tags[:bar] = 42
                +      #     tags.delete(:baz)
                +      #     true
                +      #   end
                +      #
                +      # @return [Proc, nil]
                +      attr_reader :before_emit
                +
                +      def initialize
                +        @enabled = false
                +        @enable_code_locations = true
                +      end
                +
                +      def before_emit=(value)
                +        check_callable!("metrics.before_emit", value)
                +
                +        @before_emit = value
                +      end
                +    end
                +  end
                +end
        lib/sentry/metrics/counter_metric.rb
                --- /tmp/20240412-1908-cy05nw	2024-04-12 02:16:54.990697208 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/metrics/counter_metric.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -0,0 +1,25 @@
                +# frozen_string_literal: true
                +
                +module Sentry
                +  module Metrics
                +    class CounterMetric < Metric
                +      attr_reader :value
                +
                +      def initialize(value)
                +        @value = value.to_f
                +      end
                +
                +      def add(value)
                +        @value += value.to_f
                +      end
                +
                +      def serialize
                +        [value]
                +      end
                +
                +      def weight
                +        1
                +      end
                +    end
                +  end
                +end
        lib/sentry/metrics/distribution_metric.rb
                --- /tmp/20240412-1908-4yi4cw	2024-04-12 02:16:54.990697208 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/metrics/distribution_metric.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -0,0 +1,25 @@
                +# frozen_string_literal: true
                +
                +module Sentry
                +  module Metrics
                +    class DistributionMetric < Metric
                +      attr_reader :value
                +
                +      def initialize(value)
                +        @value = [value.to_f]
                +      end
                +
                +      def add(value)
                +        @value << value.to_f
                +      end
                +
                +      def serialize
                +        value
                +      end
                +
                +      def weight
                +        value.size
                +      end
                +    end
                +  end
                +end
        lib/sentry/metrics/gauge_metric.rb
                --- /tmp/20240412-1908-mh0yx2	2024-04-12 02:16:54.994697190 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/metrics/gauge_metric.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -0,0 +1,35 @@
                +# frozen_string_literal: true
                +
                +module Sentry
                +  module Metrics
                +    class GaugeMetric < Metric
                +      attr_reader :last, :min, :max, :sum, :count
                +
                +      def initialize(value)
                +        value = value.to_f
                +        @last = value
                +        @min = value
                +        @max = value
                +        @sum = value
                +        @count = 1
                +      end
                +
                +      def add(value)
                +        value = value.to_f
                +        @last = value
                +        @min = [@min, value].min
                +        @max = [@max, value].max
                +        @sum += value
                +        @count += 1
                +      end
                +
                +      def serialize
                +        [last, min, max, sum, count]
                +      end
                +
                +      def weight
                +        5
                +      end
                +    end
                +  end
                +end
        lib/sentry/metrics/local_aggregator.rb
                --- /tmp/20240412-1908-ty35bg	2024-04-12 02:16:54.994697190 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/metrics/local_aggregator.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -0,0 +1,53 @@
                +# frozen_string_literal: true
                +
                +module Sentry
                +  module Metrics
                +    class LocalAggregator
                +      # exposed only for testing
                +      attr_reader :buckets
                +
                +      def initialize
                +        @buckets = {}
                +      end
                +
                +      def add(key, value)
                +        if @buckets[key]
                +          @buckets[key].add(value)
                +        else
                +          @buckets[key] = GaugeMetric.new(value)
                +        end
                +      end
                +
                +      def to_hash
                +        return nil if @buckets.empty?
                +
                +        @buckets.map do |bucket_key, metric|
                +          type, key, unit, tags = bucket_key
                +
                +          payload_key = "#{type}:#{key}@#{unit}"
                +          payload_value = {
                +            tags: deserialize_tags(tags),
                +            min: metric.min,
                +            max: metric.max,
                +            count: metric.count,
                +            sum: metric.sum
                +          }
                +
                +          [payload_key, payload_value]
                +        end.to_h
                +      end
                +
                +      private
                +
                +      def deserialize_tags(tags)
                +        tags.inject({}) do |h, tag|
                +          k, v = tag
                +          old = h[k]
                +          # make it an array if key repeats
                +          h[k] = old ? (old.is_a?(Array) ? old << v : [old, v]) : v
                +          h
                +        end
                +      end
                +    end
                +  end
                +end
        lib/sentry/metrics/metric.rb
                --- /tmp/20240412-1908-bimm0	2024-04-12 02:16:54.994697190 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/metrics/metric.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -0,0 +1,19 @@
                +# frozen_string_literal: true
                +
                +module Sentry
                +  module Metrics
                +    class Metric
                +      def add(value)
                +        raise NotImplementedError
                +      end
                +
                +      def serialize
                +        raise NotImplementedError
                +      end
                +
                +      def weight
                +        raise NotImplementedError
                +      end
                +    end
                +  end
                +end
        lib/sentry/metrics/set_metric.rb
                --- /tmp/20240412-1908-bqnhkp	2024-04-12 02:16:54.998697172 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/metrics/set_metric.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -0,0 +1,28 @@
                +# 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
        lib/sentry/metrics/timing.rb
                --- /tmp/20240412-1908-ylz190	2024-04-12 02:16:54.998697172 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/metrics/timing.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -0,0 +1,43 @@
                +# frozen_string_literal: true
                +
                +module Sentry
                +  module Metrics
                +    module Timing
                +      class << self
                +        def nanosecond
                +          time = Sentry.utc_now
                +          time.to_i * (10 ** 9) + time.nsec
                +        end
                +
                +        def microsecond
                +          time = Sentry.utc_now
                +          time.to_i * (10 ** 6) + time.usec
                +        end
                +
                +        def millisecond
                +          Sentry.utc_now.to_i * (10 ** 3)
                +        end
                +
                +        def second
                +          Sentry.utc_now.to_i
                +        end
                +
                +        def minute
                +          Sentry.utc_now.to_i / 60.0
                +        end
                +
                +        def hour
                +          Sentry.utc_now.to_i / 3600.0
                +        end
                +
                +        def day
                +          Sentry.utc_now.to_i / (3600.0 * 24.0)
                +        end
                +
                +        def week
                +          Sentry.utc_now.to_i / (3600.0 * 24.0 * 7.0)
                +        end
                +      end
                +    end
                +  end
                +end
      * Changed:
        README.md
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/README.md	2024-04-12 02:16:54.958697348 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/README.md	2024-04-12 02:16:54.970697295 +0000
                @@ -93 +93 @@
                -- [OpenTemeletry](https://docs.sentry.io/platforms/ruby/performance/instrumentation/opentelemetry/)
                +- [OpenTelemetry](https://docs.sentry.io/platforms/ruby/performance/instrumentation/opentelemetry/)
        Rakefile
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/Rakefile	2024-04-12 02:16:54.962697331 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/Rakefile	2024-04-12 02:16:54.970697295 +0000
                @@ -20 +20 @@
                -task :default => [:spec, :isolated_specs]
                +task default: [:spec, :isolated_specs]
        lib/sentry-ruby.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry-ruby.rb	2024-04-12 02:16:54.962697331 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry-ruby.rb	2024-04-12 02:16:54.970697295 +0000
                @@ -25,0 +26 @@
                +require "sentry/metrics"
                @@ -29 +30 @@
                -  "sentry/rack",
                +  "sentry/rack"
                @@ -79,0 +81,4 @@
                +    # @!attribute [r] metrics_aggregator
                +    #   @return [Metrics::Aggregator, nil]
                +    attr_reader :metrics_aggregator
                +
                @@ -225 +230 @@
                -      @session_flusher = config.auto_session_tracking ? Sentry::SessionFlusher.new(config, client) : nil
                +      @session_flusher = config.session_tracking? ? Sentry::SessionFlusher.new(config, client) : nil
                @@ -226,0 +232 @@
                +      @metrics_aggregator = config.metrics.enabled ? Sentry::Metrics::Aggregator.new(config, client) : nil
                @@ -246,0 +253,6 @@
                +      if @metrics_aggregator
                +        @metrics_aggregator.flush(force: true)
                +        @metrics_aggregator.kill
                +        @metrics_aggregator = nil
                +      end
                +
                @@ -248 +260 @@
                -        client.transport.flush
                +        client.flush
        lib/sentry/background_worker.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/background_worker.rb	2024-04-12 02:16:54.962697331 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/background_worker.rb	2024-04-12 02:16:54.970697295 +0000
                @@ -34 +34 @@
                -          log_debug("Initializing the background worker with #{@number_of_threads} threads")
                +          log_debug("Initializing the Sentry background worker with #{@number_of_threads} threads")
        lib/sentry/backtrace.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/backtrace.rb	2024-04-12 02:16:54.962697331 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/backtrace.rb	2024-04-12 02:16:54.970697295 +0000
                @@ -2,0 +3,2 @@
                +require "rubygems"
                +
                @@ -13 +15 @@
                -        (?: :in \s `([^']+)')?$
                +        (?: :in\s('|`)([^']+)')?$
                @@ -36 +38 @@
                -      def self.parse(unparsed_line, in_app_pattern)
                +      def self.parse(unparsed_line, in_app_pattern = nil)
                @@ -39 +41 @@
                -          _, file, number, method = ruby_match.to_a
                +          _, file, number, _, method = ruby_match.to_a
                @@ -57,0 +60,2 @@
                +        return false unless in_app_pattern
                +
        lib/sentry/check_in_event.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/check_in_event.rb	2024-04-12 02:16:54.962697331 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/check_in_event.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -30 +30 @@
                -    VALID_STATUSES = %i(ok in_progress error)
                +    VALID_STATUSES = %i[ok in_progress error]
        lib/sentry/client.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/client.rb	2024-04-12 02:16:54.962697331 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/client.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -52 +52 @@
                -        transport.record_lost_event(:sample_rate, 'event')
                +        transport.record_lost_event(:sample_rate, 'error')
                @@ -56,0 +57 @@
                +      data_category = Envelope::Item.data_category(event_type)
                @@ -61 +62 @@
                -        transport.record_lost_event(:event_processor, event_type)
                +        transport.record_lost_event(:event_processor, data_category)
                @@ -69 +70 @@
                -        transport.record_lost_event(:queue_overflow, event_type) unless queued
                +        transport.record_lost_event(:queue_overflow, data_category) unless queued
                @@ -79,0 +81,14 @@
                +    # Capture an envelope directly.
                +    # @param envelope [Envelope] the envelope to be captured.
                +    # @return [void]
                +    def capture_envelope(envelope)
                +      Sentry.background_worker.perform { send_envelope(envelope) }
                +    end
                +
                +    # Flush pending events to Sentry.
                +    # @return [void]
                +    def flush
                +      transport.flush if configuration.sending_to_dsn_allowed?
                +      spotlight_transport.flush if spotlight_transport
                +    end
                +
                @@ -90,0 +106 @@
                +      mechanism = hint.delete(:mechanism) { Mechanism.new }
                @@ -93 +109 @@
                -        event.add_exception_interface(exception)
                +        event.add_exception_interface(exception, mechanism: mechanism)
                @@ -153,0 +170 @@
                +      data_category = Envelope::Item.data_category(event_type)
                @@ -160 +177 @@
                -          transport.record_lost_event(:before_send, 'event')
                +          transport.record_lost_event(:before_send, data_category)
                @@ -170 +187 @@
                -          transport.record_lost_event(:before_send, 'transaction')
                +          transport.record_lost_event(:before_send, data_category)
                @@ -175,2 +192,2 @@
                -      transport.send_event(event)
                -      spotlight_transport&.send_event(event)
                +      transport.send_event(event) if configuration.sending_to_dsn_allowed?
                +      spotlight_transport.send_event(event) if spotlight_transport
                @@ -181 +198,17 @@
                -      transport.record_lost_event(:network_error, event_type)
                +      transport.record_lost_event(:network_error, data_category)
                +      raise
                +    end
                +
                +    # Send an envelope directly to Sentry.
                +    # @param envelope [Envelope] the envelope to be sent.
                +    # @return [void]
                +    def send_envelope(envelope)
                +      transport.send_envelope(envelope) if configuration.sending_to_dsn_allowed?
                +      spotlight_transport.send_envelope(envelope) if spotlight_transport
                +    rescue => e
                +      log_error("Envelope sending failed", e, debug: configuration.debug)
                +
                +      envelope.items.map(&:data_category).each do |data_category|
                +        transport.record_lost_event(:network_error, data_category)
                +      end
                +
        lib/sentry/configuration.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/configuration.rb	2024-04-12 02:16:54.962697331 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/configuration.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -10,0 +11 @@
                +require "sentry/metrics/configuration"
                @@ -237,0 +239,4 @@
                +    # Metrics related configuration.
                +    # @return [Metrics::Configuration]
                +    attr_reader :metrics
                +
                @@ -314 +319 @@
                -    RACK_ENV_WHITELIST_DEFAULT = %w(
                +    RACK_ENV_WHITELIST_DEFAULT = %w[
                @@ -318 +323 @@
                -    ).freeze
                +    ].freeze
                @@ -331 +336 @@
                -    DEFAULT_PATCHES = %i(redis puma http).freeze
                +    DEFAULT_PATCHES = %i[redis puma http].freeze
                @@ -340 +345 @@
                -    # allow extensions to add their hooks to the Configuration class
                +      # allow extensions to add their hooks to the Configuration class
                @@ -388,0 +394 @@
                +      @metrics = Metrics::Configuration.new
                @@ -481,0 +488,4 @@
                +      spotlight || sending_to_dsn_allowed?
                +    end
                +
                +    def sending_to_dsn_allowed?
                @@ -484 +494 @@
                -      spotlight || (valid? && capture_in_environment?)
                +      valid? && capture_in_environment?
                @@ -492,0 +503,4 @@
                +    def session_tracking?
                +      auto_session_tracking && enabled_in_current_env?
                +    end
                +
                @@ -568,6 +581,0 @@
                -
                -    def check_callable!(name, value)
                -      unless value == nil || value.respond_to?(:call)
                -        raise ArgumentError, "#{name} must be callable (or nil to disable)"
                -      end
                -    end
        lib/sentry/cron/monitor_schedule.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/cron/monitor_schedule.rb	2024-04-12 02:16:54.962697331 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/cron/monitor_schedule.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -29 +29 @@
                -        VALID_UNITS = %i(year month week day hour minute)
                +        VALID_UNITS = %i[year month week day hour minute]
        lib/sentry/dsn.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/dsn.rb	2024-04-12 02:16:54.962697331 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/dsn.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -8 +8 @@
                -    REQUIRED_ATTRIBUTES = %w(host path public_key project_id).freeze
                +    REQUIRED_ATTRIBUTES = %w[host path public_key project_id].freeze
        lib/sentry/envelope.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/envelope.rb	2024-04-12 02:16:54.962697331 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/envelope.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -20,0 +21,17 @@
                +      # rate limits and client reports use the data_category rather than envelope item type
                +      def self.data_category(type)
                +        case type
                +        when 'session', 'attachment', 'transaction', 'profile' then type
                +        when 'sessions' then 'session'
                +        when 'check_in' then 'monitor'
                +        when 'statsd', 'metric_meta' then 'metric_bucket'
                +        when 'event' then 'error'
                +        when 'client_report' then 'internal'
                +        else 'default'
                +        end
                +      end
                +
                +      def data_category
                +        self.class.data_category(type)
                +      end
                +
                @@ -22 +39 @@
                -        [JSON.generate(@headers), JSON.generate(@payload)].join("\n")
                +        [JSON.generate(@headers), @payload.is_a?(String) ? @payload : JSON.generate(@payload)].join("\n")
        lib/sentry/error_event.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/error_event.rb	2024-04-12 02:16:54.962697331 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/error_event.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -30 +30 @@
                -    def add_exception_interface(exception)
                +    def add_exception_interface(exception, mechanism:)
                @@ -35 +35 @@
                -      @exception = Sentry::ExceptionInterface.build(exception: exception, stacktrace_builder: @stacktrace_builder)
                +      @exception = Sentry::ExceptionInterface.build(exception: exception, stacktrace_builder: @stacktrace_builder, mechanism: mechanism)
        lib/sentry/event.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/event.rb	2024-04-12 02:16:54.962697331 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/event.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -17 +17 @@
                -    SERIALIZEABLE_ATTRIBUTES = %i(
                +    SERIALIZEABLE_ATTRIBUTES = %i[
                @@ -23 +23 @@
                -    )
                +    ]
                @@ -26 +26 @@
                -    WRITER_ATTRIBUTES = SERIALIZEABLE_ATTRIBUTES - %i(type timestamp level)
                +    WRITER_ATTRIBUTES = SERIALIZEABLE_ATTRIBUTES - %i[type timestamp level]
                @@ -148,5 +148,5 @@
                -        :remote_addr => env["REMOTE_ADDR"],
                -        :client_ip => env["HTTP_CLIENT_IP"],
                -        :real_ip => env["HTTP_X_REAL_IP"],
                -        :forwarded_for => env["HTTP_X_FORWARDED_FOR"],
                -        :trusted_proxies => @trusted_proxies
                +        remote_addr: env["REMOTE_ADDR"],
                +        client_ip: env["HTTP_CLIENT_IP"],
                +        real_ip: env["HTTP_X_REAL_IP"],
                +        forwarded_for: env["HTTP_X_FORWARDED_FOR"],
                +        trusted_proxies: @trusted_proxies
        lib/sentry/hub.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/hub.rb	2024-04-12 02:16:54.962697331 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/hub.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -248 +248 @@
                -      return yield unless configuration.auto_session_tracking
                +      return yield unless configuration.session_tracking?
        lib/sentry/integrable.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/integrable.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/integrable.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -16,0 +17,4 @@
                +
                +      # within an integration, we usually intercept uncaught exceptions so we set handled to false.
                +      options[:hint][:mechanism] ||= Sentry::Mechanism.new(type: integration_name, handled: false)
                +
        lib/sentry/interface.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/interface.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/interface.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -16,0 +17 @@
                +require "sentry/interfaces/mechanism"
        lib/sentry/interfaces/exception.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/interfaces/exception.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/interfaces/exception.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -1,0 +2 @@
                +
                @@ -25,0 +27 @@
                +    # @param mechanism [Mechanism]
                @@ -27 +29 @@
                -    def self.build(exception:, stacktrace_builder:)
                +    def self.build(exception:, stacktrace_builder:, mechanism:)
                @@ -34 +36 @@
                -          SingleExceptionInterface.build_with_stacktrace(exception: e, stacktrace_builder: stacktrace_builder)
                +          SingleExceptionInterface.build_with_stacktrace(exception: e, stacktrace_builder: stacktrace_builder, mechanism: mechanism)
                @@ -36 +38 @@
                -          SingleExceptionInterface.new(exception: exception)
                +          SingleExceptionInterface.new(exception: exception, mechanism: mechanism)
        lib/sentry/interfaces/request.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/interfaces/request.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/interfaces/request.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -5,2 +5,2 @@
                -    REQUEST_ID_HEADERS = %w(action_dispatch.request_id HTTP_X_REQUEST_ID).freeze
                -    CONTENT_HEADERS = %w(CONTENT_TYPE CONTENT_LENGTH).freeze
                +    REQUEST_ID_HEADERS = %w[action_dispatch.request_id HTTP_X_REQUEST_ID].freeze
                +    CONTENT_HEADERS = %w[CONTENT_TYPE CONTENT_LENGTH].freeze
        lib/sentry/interfaces/single_exception.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/interfaces/single_exception.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/interfaces/single_exception.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -14 +14 @@
                -    attr_reader :type, :module, :thread_id, :stacktrace
                +    attr_reader :type, :module, :thread_id, :stacktrace, :mechanism
                @@ -17 +17 @@
                -    def initialize(exception:, stacktrace: nil)
                +    def initialize(exception:, mechanism:, stacktrace: nil)
                @@ -31,0 +32 @@
                +      @mechanism = mechanism
                @@ -36,0 +38 @@
                +      data[:mechanism] = data[:mechanism].to_hash
                @@ -42 +44 @@
                -    def self.build_with_stacktrace(exception:, stacktrace_builder:)
                +    def self.build_with_stacktrace(exception:, stacktrace_builder:, mechanism:)
                @@ -64 +66 @@
                -      new(exception: exception, stacktrace: stacktrace)
                +      new(exception: exception, stacktrace: stacktrace, mechanism: mechanism)
        lib/sentry/interfaces/stacktrace_builder.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/interfaces/stacktrace_builder.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/interfaces/stacktrace_builder.rb	2024-04-12 02:16:54.974697278 +0000
                @@ -64,0 +65,8 @@
                +    # Get the code location hash for a single line for where metrics where added.
                +    # @return [Hash]
                +    def metrics_code_location(unparsed_line)
                +      parsed_line = Backtrace::Line.parse(unparsed_line)
                +      frame = convert_parsed_line_into_frame(parsed_line)
                +      frame.to_hash.reject { |k, _| %i[project_root in_app].include?(k) }
                +    end
                +
        lib/sentry/propagation_context.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/propagation_context.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/propagation_context.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -53,8 +53,9 @@
                -            @baggage = if baggage_header && !baggage_header.empty?
                -                        Baggage.from_incoming_header(baggage_header)
                -                      else
                -                        # If there's an incoming sentry-trace but no incoming baggage header,
                -                        # for instance in traces coming from older SDKs,
                -                        # baggage will be empty and frozen and won't be populated as head SDK.
                -                        Baggage.new({})
                -                      end
                +            @baggage =
                +              if baggage_header && !baggage_header.empty?
                +                Baggage.from_incoming_header(baggage_header)
                +              else
                +                # If there's an incoming sentry-trace but no incoming baggage header,
                +                # for instance in traces coming from older SDKs,
                +                # baggage will be empty and frozen and won't be populated as head SDK.
                +                Baggage.new({})
                +              end
        lib/sentry/puma.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/puma.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/puma.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -10 +10 @@
                -      def lowlevel_error(e, env, status=500)
                +      def lowlevel_error(e, env, status = 500)
        lib/sentry/rack/capture_exceptions.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/rack/capture_exceptions.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/rack/capture_exceptions.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -6,0 +7 @@
                +      MECHANISM_TYPE = "rack"
                @@ -59 +60 @@
                -        Sentry.capture_exception(exception).tap do |event|
                +        Sentry.capture_exception(exception, hint: { mechanism: mechanism }).tap do |event|
                @@ -75,0 +77,4 @@
                +      end
                +
                +      def mechanism
                +        Sentry::Mechanism.new(type: MECHANISM_TYPE, handled: false)
        lib/sentry/rake.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/rake.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/rake.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -11 +11,3 @@
                -        Sentry.capture_exception(ex) do |scope|
                +        mechanism = Sentry::Mechanism.new(type: 'rake', handled: false)
                +
                +        Sentry.capture_exception(ex, hint: { mechanism: mechanism }) do |scope|
        lib/sentry/scope.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/scope.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/scope.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -254,0 +255,6 @@
                +    # These are high cardinality and thus bad.
                +    # @return [Boolean]
                +    def transaction_source_low_quality?
                +      transaction_source == :url
                +    end
                +
                @@ -298 +304 @@
                -      @contexts = { :os => self.class.os_context, :runtime => self.class.runtime_context }
                +      @contexts = { os: self.class.os_context, runtime: self.class.runtime_context }
                @@ -358 +363,0 @@
                -
        lib/sentry/session.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/session.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/session.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -8,2 +8,2 @@
                -    STATUSES = %i(ok errored exited)
                -    AGGREGATE_STATUSES = %i(errored exited)
                +    STATUSES = %i[ok errored exited]
                +    AGGREGATE_STATUSES = %i[errored exited]
        lib/sentry/session_flusher.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/session_flusher.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/session_flusher.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -23,5 +22,0 @@
                -      envelope = pending_envelope
                -
                -      Sentry.background_worker.perform do
                -        @client.transport.send_envelope(envelope)
                -      end
                @@ -28,0 +24 @@
                +      @client.capture_envelope(pending_envelope)
                @@ -88 +83,0 @@
                -
        lib/sentry/span.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/span.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/span.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -3,0 +4 @@
                +require "sentry/metrics/local_aggregator"
                @@ -7 +7,0 @@
                -
                @@ -153 +153 @@
                -      {
                +      hash = {
                @@ -164,0 +165,5 @@
                +
                +      summary = metrics_summary
                +      hash[:_metrics_summary] = summary if summary
                +
                +      hash
                @@ -270,0 +276,9 @@
                +    end
                +
                +    # Collects gauge metrics on the span for metric summaries.
                +    def metrics_local_aggregator
                +      @metrics_local_aggregator ||= Sentry::Metrics::LocalAggregator.new
                +    end
                +
                +    def metrics_summary
                +      @metrics_local_aggregator&.to_hash
        lib/sentry/transaction.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/transaction.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/transaction.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -16 +16 @@
                -    SOURCES = %i(custom url route view component task)
                +    SOURCES = %i[custom url route view component task]
                @@ -113,8 +113,9 @@
                -      baggage = if baggage && !baggage.empty?
                -                  Baggage.from_incoming_header(baggage)
                -                else
                -                  # If there's an incoming sentry-trace but no incoming baggage header,
                -                  # for instance in traces coming from older SDKs,
                -                  # baggage will be empty and frozen and won't be populated as head SDK.
                -                  Baggage.new({})
                -                end
                +      baggage =
                +        if baggage && !baggage.empty?
                +          Baggage.from_incoming_header(baggage)
                +        else
                +          # If there's an incoming sentry-trace but no incoming baggage header,
                +          # for instance in traces coming from older SDKs,
                +          # baggage will be empty and frozen and won't be populated as head SDK.
                +          Baggage.new({})
                +        end
                @@ -303,0 +305,5 @@
                +    # These are high cardinality and thus bad
                +    def source_low_quality?
                +      source == :url
                +    end
                +
                @@ -337,5 +342,0 @@
                -    end
                -
                -    # These are high cardinality and thus bad
                -    def source_low_quality?
                -      source == :url
        lib/sentry/transaction_event.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/transaction_event.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/transaction_event.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -19,0 +20,3 @@
                +    # @return [Hash, nil]
                +    attr_accessor :metrics_summary
                +
                @@ -31,0 +35 @@
                +      self.metrics_summary = transaction.metrics_summary
                @@ -51,0 +56 @@
                +      data[:_metrics_summary] = @metrics_summary if @metrics_summary
        lib/sentry/transport.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/transport.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/transport.rb	2024-04-12 02:16:54.978697261 +0000
                @@ -4 +3,0 @@
                -require "base64"
                @@ -92 +91 @@
                -    def is_rate_limited?(item_type)
                +    def is_rate_limited?(data_category)
                @@ -94,10 +93 @@
                -      category_delay =
                -        case item_type
                -        when "transaction"
                -          @rate_limits["transaction"]
                -        when "sessions"
                -          @rate_limits["session"]
                -        else
                -          @rate_limits["error"]
                -        end
                -
                +      category_delay = @rate_limits[data_category]
                @@ -164 +154 @@
                -    def record_lost_event(reason, item_type)
                +    def record_lost_event(reason, data_category)
                @@ -168 +158 @@
                -      @discarded_events[[reason, item_type]] += 1
                +      @discarded_events[[reason, data_category]] += 1
                @@ -188,5 +178 @@
                -        reason, type = key
                -
                -        # 'event' has to be mapped to 'error'
                -        category = type == 'event' ? 'error' : type
                -
                +        reason, category = key
                @@ -210 +196 @@
                -        if is_rate_limited?(item.type)
                +        if is_rate_limited?(item.data_category)
                @@ -212 +198 @@
                -          record_lost_event(:ratelimit_backoff, item.type)
                +          record_lost_event(:ratelimit_backoff, item.data_category)
        lib/sentry/transport/configuration.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/transport/configuration.rb	2024-04-12 02:16:54.966697313 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/transport/configuration.rb	2024-04-12 02:16:54.982697243 +0000
                @@ -6 +5,0 @@
                -
        lib/sentry/utils/argument_checking_helper.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/utils/argument_checking_helper.rb	2024-04-12 02:16:54.970697295 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/utils/argument_checking_helper.rb	2024-04-12 02:16:54.982697243 +0000
                @@ -17,0 +18,6 @@
                +
                +    def check_callable!(name, value)
                +      unless value == nil || value.respond_to?(:call)
                +        raise ArgumentError, "#{name} must be callable (or nil to disable)"
                +      end
                +    end
        lib/sentry/utils/real_ip.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/utils/real_ip.rb	2024-04-12 02:16:54.970697295 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/utils/real_ip.rb	2024-04-12 02:16:54.982697243 +0000
                @@ -18 +18 @@
                -        "192.168.0.0/16", # private IPv4 range 192.168.x.x
                +        "192.168.0.0/16" # private IPv4 range 192.168.x.x
        lib/sentry/utils/request_id.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/utils/request_id.rb	2024-04-12 02:16:54.970697295 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/utils/request_id.rb	2024-04-12 02:16:54.982697243 +0000
                @@ -6 +6 @@
                -      REQUEST_ID_HEADERS = %w(action_dispatch.request_id HTTP_X_REQUEST_ID).freeze
                +      REQUEST_ID_HEADERS = %w[action_dispatch.request_id HTTP_X_REQUEST_ID].freeze
        lib/sentry/version.rb
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/lib/sentry/version.rb	2024-04-12 02:16:54.970697295 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/lib/sentry/version.rb	2024-04-12 02:16:54.982697243 +0000
                @@ -4 +4 @@
                -  VERSION = "5.16.1"
                +  VERSION = "5.17.3"
        sentry-ruby.gemspec
                --- /tmp/d20240412-1908-r4yisk/sentry-ruby-5.16.1/sentry-ruby.gemspec	2024-04-12 02:16:54.970697295 +0000
                +++ /tmp/d20240412-1908-r4yisk/sentry-ruby-5.17.3/sentry-ruby.gemspec	2024-04-12 02:16:54.982697243 +0000
                @@ -23,0 +24 @@
                +  spec.add_dependency "bigdecimal"

@dependabot dependabot bot force-pushed the dependabot/bundler/sentry-ruby-5.17.3 branch from 8f36d0e to 48f01f6 Compare April 26, 2024 17:09
Bumps [sentry-ruby](https://github.com/getsentry/sentry-ruby) from 5.16.1 to 5.17.3.
- [Release notes](https://github.com/getsentry/sentry-ruby/releases)
- [Changelog](https://github.com/getsentry/sentry-ruby/blob/master/CHANGELOG.md)
- [Commits](getsentry/sentry-ruby@5.16.1...5.17.3)

---
updated-dependencies:
- dependency-name: sentry-ruby
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot force-pushed the dependabot/bundler/sentry-ruby-5.17.3 branch from 48f01f6 to dd2f638 Compare April 26, 2024 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies ruby Pull requests that update Ruby code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

0 participants