Skip to content

Commit 224417d

Browse files
committed
update versions and add constant for otel resource prefix
1 parent 1a36d55 commit 224417d

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

resources/aws/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ group :test do
1212
gem 'bundler', '~> 2.4'
1313
gem 'minitest', '~> 5.0'
1414
gem 'rake', '~> 13.0'
15-
gem 'rubocop', '~> 1.73.2'
15+
gem 'rubocop', '~> 1.75.2'
1616
gem 'rubocop-performance', '~> 1.24.0'
1717
gem 'simplecov', '~> 0.22.0'
1818
gem 'webmock', '~> 3.24'

resources/aws/lib/opentelemetry/resource/detector/aws/ec2.rb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ module EC2
2929
# Timeout in seconds for HTTP requests
3030
HTTP_TIMEOUT = 1
3131

32+
# Create a constant for resource semantic conventions
33+
RESOURCE = OpenTelemetry::SemanticConventions::Resource
34+
3235
def detect
3336
# Implementation for EC2 detection supporting both IMDSv1 and IMDSv2
3437
resource_attributes = {}
@@ -46,15 +49,15 @@ def detect
4649
hostname = fetch_hostname(token)
4750

4851
# Set resource attributes from the identity document
49-
resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_PROVIDER] = 'aws'
50-
resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_PLATFORM] = 'aws_ec2'
51-
resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_ACCOUNT_ID] = identity['accountId']
52-
resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_REGION] = identity['region']
53-
resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_AVAILABILITY_ZONE] = identity['availabilityZone']
54-
55-
resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_ID] = identity['instanceId']
56-
resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_TYPE] = identity['instanceType']
57-
resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_NAME] = hostname
52+
resource_attributes[RESOURCE::CLOUD_PROVIDER] = 'aws'
53+
resource_attributes[RESOURCE::CLOUD_PLATFORM] = 'aws_ec2'
54+
resource_attributes[RESOURCE::CLOUD_ACCOUNT_ID] = identity['accountId']
55+
resource_attributes[RESOURCE::CLOUD_REGION] = identity['region']
56+
resource_attributes[RESOURCE::CLOUD_AVAILABILITY_ZONE] = identity['availabilityZone']
57+
58+
resource_attributes[RESOURCE::HOST_ID] = identity['instanceId']
59+
resource_attributes[RESOURCE::HOST_TYPE] = identity['instanceType']
60+
resource_attributes[RESOURCE::HOST_NAME] = hostname
5861
rescue StandardError => e
5962
OpenTelemetry.logger.debug("EC2 resource detection failed: #{e.message}")
6063
return OpenTelemetry::SDK::Resources::Resource.create({})

resources/aws/lib/opentelemetry/resource/detector/aws/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module OpenTelemetry
88
module Resource
99
module Detector
1010
module AWS
11-
VERSION = '0.1.0'
11+
VERSION = '0.0.0'
1212
end
1313
end
1414
end

resources/aws/opentelemetry-resource-detector-aws.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
2222
spec.files = Dir.glob('lib/**/*.rb') +
2323
['LICENSE', 'README.md']
2424
spec.require_paths = ['lib']
25-
spec.required_ruby_version = '>= 2.5.0'
25+
spec.required_ruby_version = ">= #{File.read(File.expand_path('../../gemspecs/RUBY_REQUIREMENT', __dir__))}"
2626

2727
spec.add_dependency 'opentelemetry-sdk', '~> 1.0'
2828
end

0 commit comments

Comments
 (0)