Class: XRay::LocalSamplingRule
- Inherits:
-
Object
- Object
- XRay::LocalSamplingRule
- Defined in:
- lib/aws-xray-sdk/sampling/local/sampling_rule.rb
Overview
One SamplingRule object represents one rule defined from the rules hash definition. It can be either a custom rule or the default rule.
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#fixed_target ⇒ Object
readonly
Returns the value of attribute fixed_target.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#rate ⇒ Object
readonly
Returns the value of attribute rate.
-
#reservoir ⇒ Object
readonly
Returns the value of attribute reservoir.
Instance Method Summary collapse
-
#applies?(sampling_req) ⇒ Boolean
Determines whether or not this sampling rule applies to the incoming request based on some of the request’s parameters.
-
#initialize(rule_definition:, default: false) ⇒ LocalSamplingRule
constructor
A new instance of LocalSamplingRule.
Constructor Details
#initialize(rule_definition:, default: false) ⇒ LocalSamplingRule
Returns a new instance of LocalSamplingRule.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/aws-xray-sdk/sampling/local/sampling_rule.rb', line 14 def initialize(rule_definition:, default: false) @fixed_target = rule_definition[:fixed_target] @rate = rule_definition[:rate] @host = rule_definition[:host] @method = rule_definition[:http_method] @path = rule_definition[:url_path] @default = default validate @reservoir = LocalReservoir.new traces_per_sec: @fixed_target end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
9 10 11 |
# File 'lib/aws-xray-sdk/sampling/local/sampling_rule.rb', line 9 def default @default end |
#fixed_target ⇒ Object (readonly)
Returns the value of attribute fixed_target.
9 10 11 |
# File 'lib/aws-xray-sdk/sampling/local/sampling_rule.rb', line 9 def fixed_target @fixed_target end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
9 10 11 |
# File 'lib/aws-xray-sdk/sampling/local/sampling_rule.rb', line 9 def host @host end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
9 10 11 |
# File 'lib/aws-xray-sdk/sampling/local/sampling_rule.rb', line 9 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/aws-xray-sdk/sampling/local/sampling_rule.rb', line 9 def path @path end |
#rate ⇒ Object (readonly)
Returns the value of attribute rate.
9 10 11 |
# File 'lib/aws-xray-sdk/sampling/local/sampling_rule.rb', line 9 def rate @rate end |
#reservoir ⇒ Object (readonly)
Returns the value of attribute reservoir.
9 10 11 |
# File 'lib/aws-xray-sdk/sampling/local/sampling_rule.rb', line 9 def reservoir @reservoir end |
Instance Method Details
#applies?(sampling_req) ⇒ Boolean
Determines whether or not this sampling rule applies to the incoming request based on some of the request’s parameters. Any None parameters provided will be considered an implicit match.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aws-xray-sdk/sampling/local/sampling_rule.rb', line 30 def applies?(sampling_req) return false if sampling_req.nil? || sampling_req.empty? host = sampling_req[:host] url_path = sampling_req[:url_path] http_method = sampling_req[:http_method] host_match = !host || SearchPattern.wildcard_match?(pattern: @host, text: host) path_match = !url_path || SearchPattern.wildcard_match?(pattern: @path, text: url_path) method_match = !http_method || SearchPattern.wildcard_match?(pattern: @method, text: http_method) host_match && path_match && method_match end |