app_profiler 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15a1a7b3bd1e60dc10753ce4b8e4f2907461b09417aecde43fce3d4565d5f211
4
- data.tar.gz: 811e16e5383f85f4e2aef6aaf50e832b8cf5714c2cacd730ce4f184c9d1f26c4
3
+ metadata.gz: f312a0076c72716017684a2438e0a255250fda160f5e7450813869da8bcac922
4
+ data.tar.gz: cbec087431d3a5271599bb6e6b2238aa4e67d7f51c79e7d1f3a50a3da3d12feb
5
5
  SHA512:
6
- metadata.gz: 6b6cd68d552a8ac41eebef2cec56ac8e1917c1e321c759297649a62d6c03a3ce7c6ffa06bee820320f62ac4abdde8b8fa26f539508841ea9440d7231160534a8
7
- data.tar.gz: c320d9e84ceca4834b7c5400dd46cef4ce3f04a7e49530b4381461f1ccb91b91da9cdc2e6eff86202b218efc1ef96754a5f8b40e7bbe433d73f2b3486ea86522
6
+ metadata.gz: 55c7acf18a8c4933e348e80ac6f58201797c1f2935b928c1749fca01fec1d65bf4414648240aeac65fdd5044838565b46a002c4ea87f6472c543478946221c3e
7
+ data.tar.gz: a5b18127dff76a6482f30d17b18bb9dcb4f3db42a5c0434b6dc764e57f6383ba86417fa1fa9f5e6ce0dcae007aa0470a294f566346c07c87b30a733021451483
@@ -5,16 +5,15 @@ module AppProfiler
5
5
  module Sampler
6
6
  class << self
7
7
  def profile_params(request, config)
8
- random = Kernel.rand
9
- return unless sample?(random, config, request)
8
+ return unless sample?(config, request)
10
9
 
11
- get_profile_params(config, random)
10
+ get_profile_params(config)
12
11
  end
13
12
 
14
13
  private
15
14
 
16
- def sample?(random, config, request)
17
- return false if random > config.sample_rate
15
+ def sample?(config, request)
16
+ return false if Kernel.rand > config.sample_rate
18
17
 
19
18
  path = request.path
20
19
  return false unless config.paths.any? { |p| path.match?(p) }
@@ -22,11 +21,11 @@ module AppProfiler
22
21
  true
23
22
  end
24
23
 
25
- def get_profile_params(config, random)
26
- backend_name = select_random(config.backends_probability, random)
24
+ def get_profile_params(config)
25
+ backend_name = select_random(config.backends_probability)
27
26
  backend_config = config.get_backend_config(backend_name)
28
27
 
29
- mode = select_random(backend_config.modes_probability, random)
28
+ mode = select_random(backend_config.modes_probability)
30
29
  interval = backend_config.interval_for(mode)
31
30
 
32
31
  AppProfiler::Parameters.new(
@@ -42,7 +41,8 @@ module AppProfiler
42
41
  # it will return :c
43
42
  # Assumes all probabilities sum to 1
44
43
 
45
- def select_random(options, random)
44
+ def select_random(options)
45
+ random = Kernel.rand
46
46
  current = 0
47
47
  options = options.sort_by do |_, probability|
48
48
  probability
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppProfiler
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
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.2
4
+ version: 0.2.3
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-08-26 00:00:00.000000000 Z
16
+ date: 2024-08-28 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activesupport