Class: OpenTelemetry::Sampler::XRay::SamplingRule

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/sampler/xray/sampling_rule.rb

Overview

SamplingRule represent a Sampling Rule object for AWS X-Ray See: https://docs.aws.amazon.com/xray/latest/api/API_SamplingRule.html

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sampling_rule) ⇒ SamplingRule

Returns a new instance of SamplingRule.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/opentelemetry/sampler/xray/sampling_rule.rb', line 17

def initialize(sampling_rule)
  # The AWS API docs mark `rule_name` as an optional field but in practice it seems to always be
  # present, and sampling targets could not be computed without it. For now provide an arbitrary fallback just in
  # case the AWS API docs are correct.
  @rule_name = sampling_rule['RuleName'] || 'Default'
  @rule_arn = sampling_rule['RuleARN']
  @priority = sampling_rule['Priority']
  @reservoir_size = sampling_rule['ReservoirSize']
  @fixed_rate = sampling_rule['FixedRate']
  @service_name = sampling_rule['ServiceName']
  @service_type = sampling_rule['ServiceType']
  @host = sampling_rule['Host']
  @http_method = sampling_rule['HTTPMethod']
  @url_path = sampling_rule['URLPath']
  @resource_arn = sampling_rule['ResourceARN']
  @version = sampling_rule['Version']
  @attributes = sampling_rule['Attributes']
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



13
14
15
# File 'lib/opentelemetry/sampler/xray/sampling_rule.rb', line 13

def attributes
  @attributes
end

#fixed_rateObject

Returns the value of attribute fixed_rate.



13
14
15
# File 'lib/opentelemetry/sampler/xray/sampling_rule.rb', line 13

def fixed_rate
  @fixed_rate
end

#hostObject

Returns the value of attribute host.



13
14
15
# File 'lib/opentelemetry/sampler/xray/sampling_rule.rb', line 13

def host
  @host
end

#http_methodObject

Returns the value of attribute http_method.



13
14
15
# File 'lib/opentelemetry/sampler/xray/sampling_rule.rb', line 13

def http_method
  @http_method
end

#priorityObject

Returns the value of attribute priority.



13
14
15
# File 'lib/opentelemetry/sampler/xray/sampling_rule.rb', line 13

def priority
  @priority
end

#reservoir_sizeObject

Returns the value of attribute reservoir_size.



13
14
15
# File 'lib/opentelemetry/sampler/xray/sampling_rule.rb', line 13

def reservoir_size
  @reservoir_size
end

#resource_arnObject

Returns the value of attribute resource_arn.



13
14
15
# File 'lib/opentelemetry/sampler/xray/sampling_rule.rb', line 13

def resource_arn
  @resource_arn
end

#rule_arnObject

Returns the value of attribute rule_arn.



13
14
15
# File 'lib/opentelemetry/sampler/xray/sampling_rule.rb', line 13

def rule_arn
  @rule_arn
end

#rule_nameObject

Returns the value of attribute rule_name.



13
14
15
# File 'lib/opentelemetry/sampler/xray/sampling_rule.rb', line 13

def rule_name
  @rule_name
end

#service_nameObject

Returns the value of attribute service_name.



13
14
15
# File 'lib/opentelemetry/sampler/xray/sampling_rule.rb', line 13

def service_name
  @service_name
end

#service_typeObject

Returns the value of attribute service_type.



13
14
15
# File 'lib/opentelemetry/sampler/xray/sampling_rule.rb', line 13

def service_type
  @service_type
end

#url_pathObject

Returns the value of attribute url_path.



13
14
15
# File 'lib/opentelemetry/sampler/xray/sampling_rule.rb', line 13

def url_path
  @url_path
end

#versionObject

Returns the value of attribute version.



13
14
15
# File 'lib/opentelemetry/sampler/xray/sampling_rule.rb', line 13

def version
  @version
end

Instance Method Details

#equals?(other) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/opentelemetry/sampler/xray/sampling_rule.rb', line 36

def equals?(other)
  attributes_equals = if @attributes.nil? || other.attributes.nil?
                        @attributes == other.attributes
                      else
                        attributes_equal?(other.attributes)
                      end

  @fixed_rate == other.fixed_rate &&
    @http_method == other.http_method &&
    @host == other.host &&
    @priority == other.priority &&
    @reservoir_size == other.reservoir_size &&
    @resource_arn == other.resource_arn &&
    @rule_arn == other.rule_arn &&
    @rule_name == other.rule_name &&
    @service_name == other.service_name &&
    @service_type == other.service_type &&
    @url_path == other.url_path &&
    @version == other.version &&
    attributes_equals
end