Class: XRay::SamplingRule
- Inherits:
-
Object
- Object
- XRay::SamplingRule
- Defined in:
- lib/aws-xray-sdk/sampling/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.
-
#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.
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
Instance Method Summary collapse
-
#applies?(target_name:, target_path:, target_method:) ⇒ 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) ⇒ SamplingRule
constructor
A new instance of SamplingRule.
Constructor Details
#initialize(rule_definition:, default: false) ⇒ SamplingRule
Returns a new instance of SamplingRule.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/aws-xray-sdk/sampling/sampling_rule.rb', line 14 def initialize(rule_definition:, default: false) @fixed_target = rule_definition[:fixed_target] @rate = rule_definition[:rate] @service_name = rule_definition[:service_name] @method = rule_definition[:http_method] @path = rule_definition[:url_path] @default = default validate @reservoir = Reservoir.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/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/sampling_rule.rb', line 9 def fixed_target @fixed_target end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
9 10 11 |
# File 'lib/aws-xray-sdk/sampling/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/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/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/sampling_rule.rb', line 9 def reservoir @reservoir end |
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
9 10 11 |
# File 'lib/aws-xray-sdk/sampling/sampling_rule.rb', line 9 def service_name @service_name end |
Instance Method Details
#applies?(target_name:, target_path:, target_method:) ⇒ 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 |
# File 'lib/aws-xray-sdk/sampling/sampling_rule.rb', line 30 def applies?(target_name:, target_path:, target_method:) name_match = !target_name || SearchPattern.wildcard_match?(pattern: @service_name, text: target_name) path_match = !target_path || SearchPattern.wildcard_match?(pattern: @path, text: target_path) method_match = !target_method || SearchPattern.wildcard_match?(pattern: @method, text: target_method) name_match && path_match && method_match end |