Skip to content

Commit 58e6eb4

Browse files
committed
fix rubocop offenses
1 parent f11d75d commit 58e6eb4

File tree

8 files changed

+24
-32
lines changed

8 files changed

+24
-32
lines changed

resources/aws/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ group :test do
2222
gem 'base64'
2323
gem 'mutex_m'
2424
end
25-
end
25+
end

resources/aws/Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ if RUBY_ENGINE == 'truffleruby'
2525
task default: %i[test]
2626
else
2727
task default: %i[test rubocop yard]
28-
end
28+
end

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ module AWS
1515

1616
def detect
1717
# This will be a composite of all the AWS platform detectors
18-
ec2_resource = EC2.detect
18+
EC2.detect
1919

2020
# For now, return the EC2 resource directly
2121
# In the future, we'll implement detection for EC2, ECS, EKS, etc.
22-
return ec2_resource
2322
end
2423
end
2524
end

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def detect
5050
resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_ACCOUNT_ID] = identity['accountId']
5151
resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_REGION] = identity['region']
5252
resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_AVAILABILITY_ZONE] = identity['availabilityZone']
53-
53+
5454
resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_ID] = identity['instanceId']
5555
resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_TYPE] = identity['instanceType']
5656
resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_NAME] = hostname
@@ -65,7 +65,7 @@ def detect
6565
end
6666

6767
private
68-
68+
6969
# Fetches an IMDSv2 token from the EC2 metadata service
7070
#
7171
# @return [String, nil] The token or nil if the request failed

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,4 @@ Gem::Specification.new do |spec|
2525
spec.required_ruby_version = '>= 2.5.0'
2626

2727
spec.add_dependency 'opentelemetry-sdk', '~> 1.0'
28-
29-
spec.add_development_dependency 'bundler', '>= 1.17'
30-
spec.add_development_dependency 'minitest', '~> 5.0'
31-
spec.add_development_dependency 'rake', '~> 12.0'
32-
spec.add_development_dependency 'rubocop', '~> 1.42.0'
33-
spec.add_development_dependency 'simplecov', '~> 0.17'
34-
spec.add_development_dependency 'webmock', '~> 3.7'
35-
spec.add_development_dependency 'yard', '~> 0.9'
3628
end

resources/aws/test/opentelemetry/resource/detector/aws/ec2_test.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
let(:token_path) { '/latest/api/token' }
1313
let(:identity_document_path) { '/latest/dynamic/instance-identity/document' }
1414
let(:hostname_path) { '/latest/meta-data/hostname' }
15-
15+
1616
let(:mock_token) { 'mock-token-123456' }
1717
let(:mock_identity_document) do
1818
{
@@ -53,12 +53,12 @@
5353
stub_request(:put, "http://#{ec2_metadata_host}#{token_path}")
5454
.with(headers: { 'X-aws-ec2-metadata-token-ttl-seconds' => '60' })
5555
.to_return(status: 200, body: mock_token)
56-
56+
5757
# Stub identity document request
5858
stub_request(:get, "http://#{ec2_metadata_host}#{identity_document_path}")
5959
.with(headers: { 'X-aws-ec2-metadata-token' => mock_token })
6060
.to_return(status: 200, body: mock_identity_document.to_json)
61-
61+
6262
# Stub hostname request
6363
stub_request(:get, "http://#{ec2_metadata_host}#{hostname_path}")
6464
.with(headers: { 'X-aws-ec2-metadata-token' => mock_token })
@@ -116,7 +116,7 @@
116116
stub_request(:put, "http://#{ec2_metadata_host}#{token_path}")
117117
.with(headers: { 'X-aws-ec2-metadata-token-ttl-seconds' => '60' })
118118
.to_return(status: 200, body: mock_token)
119-
119+
120120
# Identity document request fails
121121
stub_request(:get, "http://#{ec2_metadata_host}#{identity_document_path}")
122122
.with(headers: { 'X-aws-ec2-metadata-token' => mock_token })
@@ -135,7 +135,7 @@
135135
stub_request(:put, "http://#{ec2_metadata_host}#{token_path}")
136136
.with(headers: { 'X-aws-ec2-metadata-token-ttl-seconds' => '60' })
137137
.to_return(status: 200, body: mock_token)
138-
138+
139139
# Identity document is invalid JSON
140140
stub_request(:get, "http://#{ec2_metadata_host}#{identity_document_path}")
141141
.with(headers: { 'X-aws-ec2-metadata-token' => mock_token })
@@ -154,12 +154,12 @@
154154
stub_request(:put, "http://#{ec2_metadata_host}#{token_path}")
155155
.with(headers: { 'X-aws-ec2-metadata-token-ttl-seconds' => '60' })
156156
.to_return(status: 200, body: mock_token)
157-
157+
158158
# Successful identity document request
159159
stub_request(:get, "http://#{ec2_metadata_host}#{identity_document_path}")
160160
.with(headers: { 'X-aws-ec2-metadata-token' => mock_token })
161161
.to_return(status: 200, body: mock_identity_document.to_json)
162-
162+
163163
# Hostname request times out
164164
stub_request(:get, "http://#{ec2_metadata_host}#{hostname_path}")
165165
.with(headers: { 'X-aws-ec2-metadata-token' => mock_token })
@@ -174,7 +174,7 @@
174174
'cloud.region' => 'mock-west-2',
175175
'cloud.availability_zone' => 'mock-west-2a',
176176
'host.id' => 'i-1234ab56cd7e89f01',
177-
'host.type' => 't2.micro-mock',
177+
'host.type' => 't2.micro-mock'
178178
# host.name is missing because the request failed
179179
}
180180
end

resources/aws/test/opentelemetry/resource/detector/aws_test.rb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313
before do
1414
WebMock.disable_net_connect!
1515
# You'll add stubs for AWS endpoints here
16-
stub_request(:put, "http://169.254.169.254/latest/api/token").
17-
with(
16+
stub_request(:put, 'http://169.254.169.254/latest/api/token')
17+
.with(
1818
headers: {
19-
'Accept'=>'*/*',
20-
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
21-
'Host'=>'169.254.169.254',
22-
'User-Agent'=>'Ruby',
23-
'X-Aws-Ec2-Metadata-Token-Ttl-Seconds'=>'60'
24-
}).
25-
to_return(status: 404, body: "Not Found", headers: {})
19+
'Accept' => '*/*',
20+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
21+
'Host' => '169.254.169.254',
22+
'User-Agent' => 'Ruby',
23+
'X-Aws-Ec2-Metadata-Token-Ttl-Seconds' => '60'
24+
}
25+
)
26+
.to_return(status: 404, body: 'Not Found', headers: {})
2627
end
2728

2829
after do

resources/aws/test/test_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
require 'minitest/autorun'
1313
require 'webmock/minitest'
1414

15-
OpenTelemetry.logger = Logger.new($stderr, level: ENV.fetch('OTEL_LOG_LEVEL', 'fatal').to_sym)
15+
OpenTelemetry.logger = Logger.new($stderr, level: ENV.fetch('OTEL_LOG_LEVEL', 'fatal').to_sym)

0 commit comments

Comments
 (0)