opentelemetry-resource_detectors 0.21.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db98369930c24852e9231f16db04359dcd8f71348b6da67d897b4a66cbad641c
4
- data.tar.gz: c11ea7988ee128ea4a8b6d947415b4fdea68a8ef9e6012f82ca8a42794079bb8
3
+ metadata.gz: a0b9d2f6461890917886af47e0e2d49d94eb214e0d560dd22c2165f05a642f9d
4
+ data.tar.gz: d63c54874580213651aca1766412eabbd25abf878a02603eda4221893237094c
5
5
  SHA512:
6
- metadata.gz: 7020f663835bf164493582f16eb0e955836a86bf0ff741f9933edd7adb5db4d96cd2c2549e954418faf9fcb605aaabd7a94e9828cf8ac9160b648746acd036f3
7
- data.tar.gz: cdc869c6031a6b6512b374bf8286c927a54bdd214ae5760c2edb0dfe77a8c8a0d62732964e9c4533edbe3666032e1fefdb2f3f8f2f1c22913afcc3a86a02f91b
6
+ metadata.gz: 349a4aea1f2e4996644aab9d2a7dbad6c1029a2318c84dbd40d9367da254f5686bcce283af4eada287a5b84b6db05893f024fcc48420028bd8fed86303c2d358
7
+ data.tar.gz: c44fc71376aadd08f1435b71348025f84a268566a9e98d29ee99dda1da1a9b081a228e3bbb8ecc3fb3b2e6025cad8075202d22d8750aa53301e804dae2a8865c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Release History: opentelemetry-resource_detectors
2
2
 
3
+ ### v0.23.0 / 2023-04-17
4
+
5
+ * BREAKING CHANGE: Drop support for EoL Ruby 2.7
6
+
7
+ * ADDED: Drop support for EoL Ruby 2.7
8
+
9
+ ### v0.22.0 / 2023-01-14
10
+
11
+ * ADDED: Add azure resource detector.
12
+ * DOCS: Fix gem homepage
13
+ * DOCS: More gem documentation fixes
14
+
3
15
  ### v0.21.0 / 2022-06-09
4
16
 
5
17
  * BREAKING CHANGE: This requires upgrading both the SDK and Instrumentation gem in tandem
@@ -12,6 +12,7 @@ module OpenTelemetry
12
12
  extend self
13
13
 
14
14
  DETECTORS = [
15
+ OpenTelemetry::Resource::Detectors::Azure,
15
16
  OpenTelemetry::Resource::Detectors::GoogleCloudPlatform
16
17
  ].freeze
17
18
 
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright The OpenTelemetry Authors
4
+ #
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ require 'net/http'
8
+
9
+ module OpenTelemetry
10
+ module Resource
11
+ module Detectors
12
+ # Azure contains detect class method for determining Azure environment resource attributes
13
+ module Azure
14
+ extend self
15
+
16
+ AZURE_METADATA_URI = 'http://169.254.169.254/metadata/instance/compute?api-version=2019-08-15'
17
+
18
+ def detect
19
+ metadata = azure_metadata
20
+ resource_attributes = {}
21
+
22
+ unless metadata.nil?
23
+ resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_PROVIDER] = 'azure'
24
+ resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_ACCOUNT_ID] = metadata['subscriptionId']
25
+ resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_PLATFORM] = cloud_platform(metadata['provider'])
26
+ resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_REGION] = metadata['location']
27
+ resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_AVAILABILITY_ZONE] = metadata['zone']
28
+
29
+ resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_ID] = metadata['vmId']
30
+ resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_IMAGE_ID] = metadata.dig('storageProfile', 'imageReference', 'id')
31
+ resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_TYPE] = metadata['vmSize']
32
+ resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_NAME] = metadata['name']
33
+ end
34
+
35
+ resource_attributes.delete_if { |_key, value| value.nil? || value.empty? }
36
+ OpenTelemetry::SDK::Resources::Resource.create(resource_attributes)
37
+ end
38
+
39
+ private
40
+
41
+ def azure_metadata
42
+ uri = URI(AZURE_METADATA_URI)
43
+
44
+ req = Net::HTTP::Get.new(uri)
45
+ req['Metadata'] = 'true'
46
+
47
+ response = Net::HTTP.start(uri.hostname, uri.port, open_timeout: 2) do |http|
48
+ http.request(req)
49
+ end
50
+
51
+ return unless response.code == '200'
52
+
53
+ JSON.parse(response.body)
54
+ rescue Errno::EHOSTDOWN, Net::OpenTimeout, SocketError
55
+ nil
56
+ end
57
+
58
+ def cloud_platform(metadata)
59
+ case metadata
60
+ when 'Microsoft.Compute'
61
+ 'azure_vm'
62
+ else
63
+ ''
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -13,7 +13,7 @@ module OpenTelemetry
13
13
  module GoogleCloudPlatform
14
14
  extend self
15
15
 
16
- def detect # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
16
+ def detect # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
17
17
  gcp_env = Google::Cloud::Env.new
18
18
  resource_attributes = {}
19
19
 
@@ -35,7 +35,7 @@ module OpenTelemetry
35
35
  resource_attributes[OpenTelemetry::SemanticConventions::Resource::K8S_POD_NAME] = ENV['HOSTNAME'] || safe_gethostname
36
36
  resource_attributes[OpenTelemetry::SemanticConventions::Resource::K8S_NODE_NAME] = gcp_env.lookup_metadata('instance', 'hostname')
37
37
 
38
- resource_attributes[OpenTelemetry::SemanticConventions::Resource::CONTAINER_NAME] = ENV['CONTAINER_NAME']
38
+ resource_attributes[OpenTelemetry::SemanticConventions::Resource::CONTAINER_NAME] = ENV.fetch('CONTAINER_NAME', nil)
39
39
  end
40
40
 
41
41
  if gcp_env.knative?
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Resource
9
9
  module Detectors
10
- VERSION = '0.21.0'
10
+ VERSION = '0.23.0'
11
11
  end
12
12
  end
13
13
  end
@@ -7,6 +7,7 @@
7
7
  require 'opentelemetry/sdk'
8
8
  require 'opentelemetry/resource/detectors/version'
9
9
  require 'opentelemetry/resource/detectors/google_cloud_platform'
10
+ require 'opentelemetry/resource/detectors/azure'
10
11
  require 'opentelemetry/resource/detectors/auto_detector'
11
12
 
12
13
  # OpenTelemetry is an open source observability framework, providing a
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-resource_detectors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-09 00:00:00.000000000 Z
11
+ date: 2023-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-env
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.17'
47
+ version: '2.4'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.17'
54
+ version: '2.4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '12.0'
75
+ version: '13.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '12.0'
82
+ version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.73.0
89
+ version: 1.49.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.73.0
96
+ version: 1.49.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: simplecov
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.17'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 3.18.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 3.18.1
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: yard
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -150,16 +164,17 @@ files:
150
164
  - lib/opentelemetry-resource_detectors.rb
151
165
  - lib/opentelemetry/resource/detectors.rb
152
166
  - lib/opentelemetry/resource/detectors/auto_detector.rb
167
+ - lib/opentelemetry/resource/detectors/azure.rb
153
168
  - lib/opentelemetry/resource/detectors/google_cloud_platform.rb
154
169
  - lib/opentelemetry/resource/detectors/version.rb
155
- homepage: https://github.com/open-telemetry/opentelemetry-ruby
170
+ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
156
171
  licenses:
157
172
  - Apache-2.0
158
173
  metadata:
159
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-resource_detectors/v0.21.0/file.CHANGELOG.html
160
- source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/resource_detectors
161
- bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
162
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-resource_detectors/v0.21.0
174
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-resource_detectors/0.23.0/file/CHANGELOG.md
175
+ source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/resource_detectors
176
+ bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
177
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-resource_detectors/0.23.0
163
178
  post_install_message:
164
179
  rdoc_options: []
165
180
  require_paths:
@@ -168,14 +183,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
183
  requirements:
169
184
  - - ">="
170
185
  - !ruby/object:Gem::Version
171
- version: 2.6.0
186
+ version: '3.0'
172
187
  required_rubygems_version: !ruby/object:Gem::Requirement
173
188
  requirements:
174
189
  - - ">="
175
190
  - !ruby/object:Gem::Version
176
191
  version: '0'
177
192
  requirements: []
178
- rubygems_version: 3.1.6
193
+ rubygems_version: 3.2.33
179
194
  signing_key:
180
195
  specification_version: 4
181
196
  summary: Resource detection helpers for OpenTelemetry