opentelemetry-resource_detectors 0.20.0 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/opentelemetry/resource/detectors/auto_detector.rb +1 -0
- data/lib/opentelemetry/resource/detectors/azure.rb +69 -0
- data/lib/opentelemetry/resource/detectors/google_cloud_platform.rb +2 -2
- data/lib/opentelemetry/resource/detectors/version.rb +1 -1
- data/lib/opentelemetry/resource/detectors.rb +1 -0
- metadata +35 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61753b597d6d347b493d0af32b021a3963f6358628f477ce2773313625860892
|
4
|
+
data.tar.gz: b570fbb4a604ca863dc4362401d3d58bb85a977e2cffb0f0a941df8216b9a46e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e986c7783a1f813b10198db183ca299f09afa919f79562998336434cd36291a1c696fb31eea1fd63736c4f19ec056a44c909abdd3f8e772033e1e01df7e13e4
|
7
|
+
data.tar.gz: fc35ab07cf7df63aacd3ea981e9cf9fcc0cf38bf04f86c17105de8365c181b70a99d355242ae8bc59c57d98695773625c057230d6891e8989bb10f9691377793
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Release History: opentelemetry-resource_detectors
|
2
2
|
|
3
|
+
### v0.22.0 / 2023-01-14
|
4
|
+
|
5
|
+
* ADDED: Add azure resource detector.
|
6
|
+
* DOCS: Fix gem homepage
|
7
|
+
* DOCS: More gem documentation fixes
|
8
|
+
|
9
|
+
### v0.21.0 / 2022-06-09
|
10
|
+
|
11
|
+
* BREAKING CHANGE: This requires upgrading both the SDK and Instrumentation gem in tandem
|
12
|
+
|
13
|
+
|
3
14
|
### v0.20.0 / 2022-05-02
|
4
15
|
|
5
16
|
* ADDED: Added Google Cloud Function Resource Detection
|
@@ -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/
|
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
|
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,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.
|
4
|
+
version: 0.22.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:
|
11
|
+
date: 2023-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-cloud-env
|
@@ -28,30 +28,30 @@ dependencies:
|
|
28
28
|
name: opentelemetry-sdk
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
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: '
|
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: '
|
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: '
|
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:
|
89
|
+
version: 1.41.1
|
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:
|
96
|
+
version: 1.41.1
|
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.7.6
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 3.7.6
|
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://
|
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://
|
174
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-resource_detectors/0.22.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.22.0
|
163
178
|
post_install_message:
|
164
179
|
rdoc_options: []
|
165
180
|
require_paths:
|
@@ -168,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
168
183
|
requirements:
|
169
184
|
- - ">="
|
170
185
|
- !ruby/object:Gem::Version
|
171
|
-
version: 2.
|
186
|
+
version: 2.6.0
|
172
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
188
|
requirements:
|
174
189
|
- - ">="
|