app_profiler 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/app_profiler/backend/base_backend.rb +1 -1
- data/lib/app_profiler/profile/stackprof.rb +4 -0
- data/lib/app_profiler/profile/vernier.rb +4 -0
- data/lib/app_profiler/profile.rb +1 -1
- data/lib/app_profiler/sampler/config.rb +5 -3
- data/lib/app_profiler/sampler.rb +7 -0
- data/lib/app_profiler/version.rb +1 -1
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 36a0afed63f70a16ab782039e981583c16e80f846eb6caf6cefce219d7934d0d
         | 
| 4 | 
            +
              data.tar.gz: eda36bd2a579b25757db0e872c3f2aa1cbdda60ddf486b4bd3ad90f34f74829c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 8ef999eb872722bca7b910b88df8a091c756b4d9f0e95da4ac770aacfb0b5454a160ca37b8c13852e25e5fd8aecf698f6bc06f6669104cbbb02c5af033b66a80
         | 
| 7 | 
            +
              data.tar.gz: 2896ca3138e8b631445b628bcd6206e77bcd94fbef57c00560b0a63f8677b3103555eef97aabbb936722406d5667ec6c8885c9224fe85cd82d2619f45fdb9051
         | 
| @@ -40,7 +40,7 @@ module AppProfiler | |
| 40 40 | 
             
                  end
         | 
| 41 41 |  | 
| 42 42 | 
             
                  def release_run_lock
         | 
| 43 | 
            -
                    self.class.run_lock.unlock
         | 
| 43 | 
            +
                    self.class.run_lock.unlock if self.class.run_lock.locked?
         | 
| 44 44 | 
             
                  rescue ThreadError
         | 
| 45 45 | 
             
                    AppProfiler.logger.warn("[AppProfiler] run lock not released as it was never acquired")
         | 
| 46 46 | 
             
                  end
         | 
    
        data/lib/app_profiler/profile.rb
    CHANGED
    
    
| @@ -5,12 +5,12 @@ require "app_profiler/sampler/vernier_config" | |
| 5 5 | 
             
            module AppProfiler
         | 
| 6 6 | 
             
              module Sampler
         | 
| 7 7 | 
             
                class Config
         | 
| 8 | 
            -
                  attr_reader :sample_rate, :targets, :cpu_interval, :backends_probability
         | 
| 8 | 
            +
                  attr_reader :sample_rate, :targets, :exclude_targets, :cpu_interval, :backends_probability
         | 
| 9 9 |  | 
| 10 10 | 
             
                  SAMPLE_RATE = 0.001 # 0.1%
         | 
| 11 11 | 
             
                  TARGETS = ["/"]
         | 
| 12 12 | 
             
                  BACKEND_PROBABILITES = { stackprof: 1.0, vernier: 0.0 }
         | 
| 13 | 
            -
                   | 
| 13 | 
            +
                  EMPTY_ARRAY = []
         | 
| 14 14 |  | 
| 15 15 | 
             
                  def initialize(sample_rate: SAMPLE_RATE,
         | 
| 16 16 | 
             
                    targets: TARGETS,
         | 
| @@ -18,7 +18,8 @@ module AppProfiler | |
| 18 18 | 
             
                    backends_config: {
         | 
| 19 19 | 
             
                      stackprof: StackprofConfig.new,
         | 
| 20 20 | 
             
                    },
         | 
| 21 | 
            -
                    paths: nil | 
| 21 | 
            +
                    paths: nil,
         | 
| 22 | 
            +
                    exclude_targets: EMPTY_ARRAY)
         | 
| 22 23 |  | 
| 23 24 | 
             
                    if sample_rate < 0.0 || sample_rate > 1.0
         | 
| 24 25 | 
             
                      raise ArgumentError, "sample_rate must be between 0 and 1"
         | 
| @@ -32,6 +33,7 @@ module AppProfiler | |
| 32 33 | 
             
                    @targets = paths || targets
         | 
| 33 34 | 
             
                    @backends_config = backends_config
         | 
| 34 35 | 
             
                    @backends_probability = backends_probability
         | 
| 36 | 
            +
                    @exclude_targets = exclude_targets
         | 
| 35 37 | 
             
                  end
         | 
| 36 38 |  | 
| 37 39 | 
             
                  def get_backend_config(backend_name)
         | 
    
        data/lib/app_profiler/sampler.rb
    CHANGED
    
    | @@ -3,6 +3,7 @@ | |
| 3 3 | 
             
            require "app_profiler/sampler/config"
         | 
| 4 4 | 
             
            module AppProfiler
         | 
| 5 5 | 
             
              module Sampler
         | 
| 6 | 
            +
                @excluded_cache = {}
         | 
| 6 7 | 
             
                class << self
         | 
| 7 8 | 
             
                  def profile_params(request, config)
         | 
| 8 9 | 
             
                    profile_params_for(request.path, config)
         | 
| @@ -18,6 +19,12 @@ module AppProfiler | |
| 18 19 |  | 
| 19 20 | 
             
                  def sample?(config, target)
         | 
| 20 21 | 
             
                    return false if Kernel.rand > config.sample_rate
         | 
| 22 | 
            +
                    return false if @excluded_cache[target]
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                    if config.exclude_targets.any? { |t| target.match?(t) }
         | 
| 25 | 
            +
                      @excluded_cache[target] = true
         | 
| 26 | 
            +
                      return false
         | 
| 27 | 
            +
                    end
         | 
| 21 28 |  | 
| 22 29 | 
             
                    return false unless config.targets.any? { |t| target.match?(t) }
         | 
| 23 30 |  | 
    
        data/lib/app_profiler/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: app_profiler
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.2. | 
| 4 | 
            +
              version: 0.2.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Gannon McGibbon
         | 
| @@ -13,7 +13,7 @@ authors: | |
| 13 13 | 
             
            autorequire:
         | 
| 14 14 | 
             
            bindir: bin
         | 
| 15 15 | 
             
            cert_chain: []
         | 
| 16 | 
            -
            date: 2024- | 
| 16 | 
            +
            date: 2024-10-15 00:00:00.000000000 Z
         | 
| 17 17 | 
             
            dependencies:
         | 
| 18 18 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 19 19 | 
             
              name: activesupport
         | 
| @@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 184 184 | 
             
                - !ruby/object:Gem::Version
         | 
| 185 185 | 
             
                  version: '0'
         | 
| 186 186 | 
             
            requirements: []
         | 
| 187 | 
            -
            rubygems_version: 3.5. | 
| 187 | 
            +
            rubygems_version: 3.5.21
         | 
| 188 188 | 
             
            signing_key:
         | 
| 189 189 | 
             
            specification_version: 4
         | 
| 190 190 | 
             
            summary: Collect performance profiles for your Rails application.
         |