app_profiler 0.2.2 → 0.2.3
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/sampler.rb +9 -9
- data/lib/app_profiler/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f312a0076c72716017684a2438e0a255250fda160f5e7450813869da8bcac922
|
4
|
+
data.tar.gz: cbec087431d3a5271599bb6e6b2238aa4e67d7f51c79e7d1f3a50a3da3d12feb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55c7acf18a8c4933e348e80ac6f58201797c1f2935b928c1749fca01fec1d65bf4414648240aeac65fdd5044838565b46a002c4ea87f6472c543478946221c3e
|
7
|
+
data.tar.gz: a5b18127dff76a6482f30d17b18bb9dcb4f3db42a5c0434b6dc764e57f6383ba86417fa1fa9f5e6ce0dcae007aa0470a294f566346c07c87b30a733021451483
|
data/lib/app_profiler/sampler.rb
CHANGED
@@ -5,16 +5,15 @@ module AppProfiler
|
|
5
5
|
module Sampler
|
6
6
|
class << self
|
7
7
|
def profile_params(request, config)
|
8
|
-
|
9
|
-
return unless sample?(random, config, request)
|
8
|
+
return unless sample?(config, request)
|
10
9
|
|
11
|
-
get_profile_params(config
|
10
|
+
get_profile_params(config)
|
12
11
|
end
|
13
12
|
|
14
13
|
private
|
15
14
|
|
16
|
-
def sample?(
|
17
|
-
return false if
|
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
|
26
|
-
backend_name = select_random(config.backends_probability
|
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
|
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
|
44
|
+
def select_random(options)
|
45
|
+
random = Kernel.rand
|
46
46
|
current = 0
|
47
47
|
options = options.sort_by do |_, probability|
|
48
48
|
probability
|
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.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-
|
16
|
+
date: 2024-08-28 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: activesupport
|