@@ -20,6 +20,7 @@ class SamplingRuleApplier
2020 attr_reader :sampling_rule
2121
2222 MAX_DATE_TIME_SECONDS = Time . at ( 8_640_000_000_000 )
23+ SEMCONV = OpenTelemetry ::SemanticConventions
2324
2425 def initialize ( sampling_rule , statistics = OpenTelemetry ::Sampler ::XRay ::Statistics . new , target = nil )
2526 @sampling_rule = sampling_rule
@@ -38,10 +39,10 @@ def matches?(attributes, resource)
3839 http_host = nil
3940
4041 unless attributes . nil?
41- http_target = attributes [ OpenTelemetry :: SemanticConventions ::Trace ::HTTP_TARGET ]
42- http_url = attributes [ OpenTelemetry :: SemanticConventions ::Trace ::HTTP_URL ]
43- http_method = attributes [ OpenTelemetry :: SemanticConventions ::Trace ::HTTP_METHOD ]
44- http_host = attributes [ OpenTelemetry :: SemanticConventions ::Trace ::HTTP_HOST ]
42+ http_target = attributes [ SEMCONV ::Trace ::HTTP_TARGET ]
43+ http_url = attributes [ SEMCONV ::Trace ::HTTP_URL ]
44+ http_method = attributes [ SEMCONV ::Trace ::HTTP_METHOD ]
45+ http_host = attributes [ SEMCONV ::Trace ::HTTP_HOST ]
4546 end
4647
4748 service_type = nil
@@ -50,8 +51,8 @@ def matches?(attributes, resource)
5051 resource_hash = resource . attribute_enumerator . to_h
5152
5253 if resource
53- service_name = resource_hash [ OpenTelemetry :: SemanticConventions ::Resource ::SERVICE_NAME ] || ''
54- cloud_platform = resource_hash [ OpenTelemetry :: SemanticConventions ::Resource ::CLOUD_PLATFORM ]
54+ service_name = resource_hash [ SEMCONV ::Resource ::SERVICE_NAME ] || ''
55+ cloud_platform = resource_hash [ SEMCONV ::Resource ::CLOUD_PLATFORM ]
5556 service_type = OpenTelemetry ::Sampler ::XRay ::Utils ::CLOUD_PLATFORM_MAPPING [ cloud_platform ] if cloud_platform . is_a? ( String )
5657 resource_arn = get_arn ( resource , attributes )
5758 end
@@ -99,11 +100,11 @@ def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:
99100
100101 def get_arn ( resource , attributes )
101102 resource_hash = resource . attribute_enumerator . to_h
102- arn = resource_hash [ OpenTelemetry :: SemanticConventions ::Resource ::AWS_ECS_CONTAINER_ARN ] ||
103- resource_hash [ OpenTelemetry :: SemanticConventions ::Resource ::AWS_ECS_CLUSTER_ARN ] ||
104- resource_hash [ OpenTelemetry :: SemanticConventions ::Resource ::AWS_EKS_CLUSTER_ARN ]
103+ arn = resource_hash [ SEMCONV ::Resource ::AWS_ECS_CONTAINER_ARN ] ||
104+ resource_hash [ SEMCONV ::Resource ::AWS_ECS_CLUSTER_ARN ] ||
105+ resource_hash [ SEMCONV ::Resource ::AWS_EKS_CLUSTER_ARN ]
105106
106- arn = attributes [ OpenTelemetry :: SemanticConventions :: Trace ::AWS_LAMBDA_INVOKED_ARN ] || resource_hash [ OpenTelemetry :: SemanticConventions ::Resource ::FAAS_ID ] if arn . nil?
107+ arn = attributes [ SEMCONV :: Trace ::AWS_LAMBDA_INVOKED_ARN ] || resource_hash [ SEMCONV ::Resource ::FAAS_ID ] if arn . nil?
107108 arn
108109 end
109110 end
0 commit comments