opentelemetry-resource_detectors 0.5.1 → 0.6.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 +8 -0
- data/README.md +6 -16
- data/lib/opentelemetry/resource/detectors/google_cloud_platform.rb +16 -16
- data/lib/opentelemetry/resource/detectors/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d535862f90f1e764bcbaeeccdba57293e0bd98a58d0824d7913c76a0edae8cae
|
4
|
+
data.tar.gz: ca2c83de07de71c50d74b69beeafab678d8749873a26c8907d1b220269222702
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0afd04139ca2ce20d38aa96bcc05e1e79f7eaea4902827bbd802f612e72d869f3a7e84aee34437ce78f3aa246668f0c0afcf18368b3f55ca7bc1070106552876
|
7
|
+
data.tar.gz: e7b5ccfb80b17e7c88e6b78521b50702f1613f27af4a969187c4063dd606f8e40afaaa79072ecec985d77a126edbef4f68745692f168e848a19611cab37e4a60
|
data/CHANGELOG.md
ADDED
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,36 +9,36 @@ 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
16
|
def detect # rubocop:disable Metrics/AbcSize
|
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[:hostname]] = hostname
|
28
|
+
resource_attributes[resource_constants::HOST_RESOURCE[:id]] = gcp_env.lookup_metadata('instance', 'id')
|
29
|
+
resource_attributes[resource_constants::HOST_RESOURCE[:name]] = gcp_env.lookup_metadata('instance', 'hostname')
|
30
30
|
end
|
31
31
|
|
32
32
|
if gcp_env.kubernetes_engine?
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
resource_attributes[resource_constants::K8S_RESOURCE[:cluster_name]] = gcp_env.instance_attribute('cluster-name')
|
34
|
+
resource_attributes[resource_constants::K8S_RESOURCE[:namespace_name]] = gcp_env.kubernetes_engine_namespace_id
|
35
|
+
resource_attributes[resource_constants::K8S_RESOURCE[:pod_name]] = hostname
|
36
36
|
|
37
|
-
|
37
|
+
resource_attributes[resource_constants::CONTAINER_RESOURCE[:name]] = ENV['CONTAINER_NAME']
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
OpenTelemetry::SDK::Resources::Resource.create(
|
40
|
+
resource_attributes.delete_if { |_key, value| value.nil? || value.empty? }
|
41
|
+
OpenTelemetry::SDK::Resources::Resource.create(resource_attributes)
|
42
42
|
end
|
43
43
|
|
44
44
|
private
|
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.6.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-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-cloud-env
|
@@ -129,6 +129,7 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
+
- CHANGELOG.md
|
132
133
|
- LICENSE
|
133
134
|
- README.md
|
134
135
|
- lib/opentelemetry-resource_detectors.rb
|
@@ -155,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
156
|
- !ruby/object:Gem::Version
|
156
157
|
version: '0'
|
157
158
|
requirements: []
|
158
|
-
rubygems_version: 3.
|
159
|
+
rubygems_version: 3.1.2
|
159
160
|
signing_key:
|
160
161
|
specification_version: 4
|
161
162
|
summary: Resource detection helpers for OpenTelemetry
|