opentelemetry-resource_detectors 0.5.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/CHANGELOG.md +26 -0
- data/README.md +6 -16
- data/lib/opentelemetry/resource/detectors.rb +6 -0
- data/lib/opentelemetry/resource/detectors/google_cloud_platform.rb +20 -19
- data/lib/opentelemetry/resource/detectors/version.rb +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da73964cec06ce61e82b77febff0d16298c8cc32b8624cdd7fb3d97302c05e6f
|
4
|
+
data.tar.gz: becd0e1f53c97a0d3c98db73064c10b932abf8fa12ab10f1101a12429a4bf93e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e281670c868ddbd8f9fa3600136852f2fdbb30d2a4ba71230d681badfec2293dcc9ac7b3ed0aa0293ac0906295c6bebac43958840c6b627804e36b036079f16
|
7
|
+
data.tar.gz: bdad92a9f35999c5a33608e60cd12dffe1e0458142957809d09a6bc71bccc95e87e71bf1bc4acfd65aa00714a930e82f41619ca91ac14cb33200f27d75f0f3af
|
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Release History: opentelemetry-resource_detectors
|
2
|
+
|
3
|
+
### v0.10.0 / 2020-12-03
|
4
|
+
|
5
|
+
* (No significant changes)
|
6
|
+
|
7
|
+
### v0.9.0 / 2020-11-27
|
8
|
+
|
9
|
+
* BREAKING CHANGE: Add timeout for force_flush and shutdown
|
10
|
+
|
11
|
+
* ADDED: Add timeout for force_flush and shutdown
|
12
|
+
|
13
|
+
### v0.8.0 / 2020-10-27
|
14
|
+
|
15
|
+
* (No significant changes)
|
16
|
+
|
17
|
+
### v0.7.0 / 2020-10-07
|
18
|
+
|
19
|
+
* DOCS: Standardize toplevel docs structure and readme
|
20
|
+
|
21
|
+
### v0.6.0 / 2020-09-10
|
22
|
+
|
23
|
+
* BREAKING CHANGE: Rename Resource labels to attributes
|
24
|
+
|
25
|
+
* FIXED: Rename Resource labels to attributes
|
26
|
+
* ADDED: Environment variable resource detection
|
data/README.md
CHANGED
@@ -4,13 +4,13 @@ The `opentelemetry-resource-detectors` gem provides resource detectors for OpenT
|
|
4
4
|
|
5
5
|
## What is OpenTelemetry?
|
6
6
|
|
7
|
-
|
7
|
+
OpenTelemetry is an open source observability framework, providing a general-purpose API, SDK, and related tools required for the instrumentation of cloud-native software, frameworks, and libraries.
|
8
8
|
|
9
9
|
OpenTelemetry provides a single set of APIs, libraries, agents, and collector services to capture distributed traces and metrics from your application. You can analyze them using Prometheus, Jaeger, and other observability tools.
|
10
10
|
|
11
11
|
## How does this gem fit in?
|
12
12
|
|
13
|
-
The `opentelemetry-resource-detectors` gem provides a means of retrieving a
|
13
|
+
The `opentelemetry-resource-detectors` gem provides a means of retrieving a resource for supported environments following the resource semantic conventions.
|
14
14
|
|
15
15
|
## How do I get started?
|
16
16
|
|
@@ -21,7 +21,7 @@ gem install opentelemetry-sdk
|
|
21
21
|
gem install opentelemetry-resource-detectors
|
22
22
|
```
|
23
23
|
|
24
|
-
Or, if you use
|
24
|
+
Or, if you use Bundler, include `opentelemetry-sdk` and `opentelemetry-resource-detectors` in your `Gemfile`.
|
25
25
|
|
26
26
|
```rb
|
27
27
|
require 'opentelemetry/sdk'
|
@@ -40,20 +40,10 @@ end
|
|
40
40
|
|
41
41
|
## How can I get involved?
|
42
42
|
|
43
|
-
The `opentelemetry-resource-detectors` gem source is
|
43
|
+
The `opentelemetry-resource-detectors` gem source is on github, along with related gems.
|
44
44
|
|
45
|
-
The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us on our
|
45
|
+
The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us on our gitter channel or attending our weekly meeting. See the meeting calendar for dates and times. For more information on this and other language SIGs, see the OpenTelemetry community page.
|
46
46
|
|
47
47
|
## License
|
48
48
|
|
49
|
-
The `opentelemetry-resource-detectors` gem is distributed under the Apache 2.0 license. See
|
50
|
-
|
51
|
-
|
52
|
-
[opentelemetry-home]: https://opentelemetry.io
|
53
|
-
[bundler-home]: https://bundler.io
|
54
|
-
[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
|
55
|
-
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/master/LICENSE
|
56
|
-
[examples-github]: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/examples
|
57
|
-
[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
|
58
|
-
[community-meetings]: https://github.com/open-telemetry/community#community-meetings
|
59
|
-
[ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
|
49
|
+
The `opentelemetry-resource-detectors` gem is distributed under the Apache 2.0 license. See LICENSE for more information.
|
@@ -9,6 +9,12 @@ require 'opentelemetry/resource/detectors/version'
|
|
9
9
|
require 'opentelemetry/resource/detectors/google_cloud_platform'
|
10
10
|
require 'opentelemetry/resource/detectors/auto_detector'
|
11
11
|
|
12
|
+
# OpenTelemetry is an open source observability framework, providing a
|
13
|
+
# general-purpose API, SDK, and related tools required for the instrumentation
|
14
|
+
# of cloud-native software, frameworks, and libraries.
|
15
|
+
#
|
16
|
+
# The OpenTelemetry module provides global accessors for telemetry objects.
|
17
|
+
# See the documentation for the `opentelemetry-api` gem for details.
|
12
18
|
module OpenTelemetry
|
13
19
|
module Resource
|
14
20
|
# Detectors contains the resource detectors as well as the AutoDetector
|
@@ -9,42 +9,43 @@ require 'google-cloud-env'
|
|
9
9
|
module OpenTelemetry
|
10
10
|
module Resource
|
11
11
|
module Detectors
|
12
|
-
# GoogleCloudPlatform contains detect class method for determining gcp environment resource
|
12
|
+
# GoogleCloudPlatform contains detect class method for determining gcp environment resource attributes
|
13
13
|
module GoogleCloudPlatform
|
14
14
|
extend self
|
15
15
|
|
16
|
-
def detect # rubocop:disable Metrics/AbcSize
|
16
|
+
def detect # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
17
17
|
gcp_env = Google::Cloud::Env.new
|
18
|
-
|
18
|
+
resource_attributes = {}
|
19
19
|
resource_constants = OpenTelemetry::SDK::Resources::Constants
|
20
20
|
|
21
21
|
if gcp_env.compute_engine?
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
resource_attributes[resource_constants::CLOUD_RESOURCE[:provider]] = 'gcp'
|
23
|
+
resource_attributes[resource_constants::CLOUD_RESOURCE[:account_id]] = gcp_env.project_id
|
24
|
+
resource_attributes[resource_constants::CLOUD_RESOURCE[:region]] = gcp_env.instance_attribute('cluster-location')
|
25
|
+
resource_attributes[resource_constants::CLOUD_RESOURCE[:zone]] = gcp_env.instance_zone
|
26
|
+
|
27
|
+
resource_attributes[resource_constants::HOST_RESOURCE[:id]] = gcp_env.lookup_metadata('instance', 'id')
|
28
|
+
resource_attributes[resource_constants::HOST_RESOURCE[:name]] = ENV['HOSTNAME'] ||
|
29
|
+
gcp_env.lookup_metadata('instance', 'hostname') ||
|
30
|
+
safe_gethostname
|
30
31
|
end
|
31
32
|
|
32
33
|
if gcp_env.kubernetes_engine?
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
resource_attributes[resource_constants::K8S_RESOURCE[:cluster_name]] = gcp_env.instance_attribute('cluster-name')
|
35
|
+
resource_attributes[resource_constants::K8S_RESOURCE[:namespace_name]] = gcp_env.kubernetes_engine_namespace_id
|
36
|
+
resource_attributes[resource_constants::K8S_RESOURCE[:pod_name]] = ENV['HOSTNAME'] || safe_gethostname
|
36
37
|
|
37
|
-
|
38
|
+
resource_attributes[resource_constants::CONTAINER_RESOURCE[:name]] = ENV['CONTAINER_NAME']
|
38
39
|
end
|
39
40
|
|
40
|
-
|
41
|
-
OpenTelemetry::SDK::Resources::Resource.create(
|
41
|
+
resource_attributes.delete_if { |_key, value| value.nil? || value.empty? }
|
42
|
+
OpenTelemetry::SDK::Resources::Resource.create(resource_attributes)
|
42
43
|
end
|
43
44
|
|
44
45
|
private
|
45
46
|
|
46
|
-
def
|
47
|
-
|
47
|
+
def safe_gethostname
|
48
|
+
Socket.gethostname
|
48
49
|
rescue StandardError
|
49
50
|
''
|
50
51
|
end
|
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.10.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: 2020-
|
11
|
+
date: 2020-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-cloud-env
|
@@ -129,6 +129,8 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
+
- ".yardopts"
|
133
|
+
- CHANGELOG.md
|
132
134
|
- LICENSE
|
133
135
|
- README.md
|
134
136
|
- lib/opentelemetry-resource_detectors.rb
|
@@ -139,7 +141,11 @@ files:
|
|
139
141
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
140
142
|
licenses:
|
141
143
|
- Apache-2.0
|
142
|
-
metadata:
|
144
|
+
metadata:
|
145
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-resource_detectors/v0.10.0/file.CHANGELOG.html
|
146
|
+
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/resource_detectors
|
147
|
+
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
148
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-resource_detectors/v0.10.0
|
143
149
|
post_install_message:
|
144
150
|
rdoc_options: []
|
145
151
|
require_paths:
|
@@ -155,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
161
|
- !ruby/object:Gem::Version
|
156
162
|
version: '0'
|
157
163
|
requirements: []
|
158
|
-
rubygems_version: 3.
|
164
|
+
rubygems_version: 3.1.4
|
159
165
|
signing_key:
|
160
166
|
specification_version: 4
|
161
167
|
summary: Resource detection helpers for OpenTelemetry
|