opentelemetry-exporter-otlp-metrics 0.1.0 → 0.2.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4900aee75f04656632debac8b989868fb24fc1097ab8dd30d50216143496cbba
|
4
|
+
data.tar.gz: bc29bb3e4bb368ee6eb3b8aed510d5af2361da1103e7c2d524ddbe2a24e4c601
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7d1227d845b3cc78f8528e712e99cbeb5ca42a610df51bd9a8de00f4e25dc4d5b4289dffd1edfe8da956c34ac46bf152f65999acdffa03343b2f95ef7c6c69e
|
7
|
+
data.tar.gz: 1de7c79780328fd7fd48ba000f60e9dd8a2e0eca7ba02fe73bc1fc7b6a56ffff82aa08fa8ad5b2dfd498d86d41a89c55b299c572463827b7528614e7cbd24f41
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Release History: opentelemetry-exporter-otlp-metrics
|
2
2
|
|
3
|
+
### v0.2.0 / 2024-11-19
|
4
|
+
|
5
|
+
* ADDED: Add basic metrics view
|
6
|
+
* FIXED: Remove Metrics OTLP exporter `Util#measure_request_duration` and duplicate files
|
7
|
+
* FIXED: Add mTLS for metrics exporter
|
8
|
+
|
3
9
|
### v0.1.0 / 2024-08-27
|
4
10
|
|
5
11
|
Initial release.
|
data/README.md
CHANGED
@@ -18,6 +18,41 @@ Generally, *libraries* that produce telemetry data should avoid depending direct
|
|
18
18
|
|
19
19
|
This gem supports the [v0.20.0 release][otel-proto-release] of OTLP.
|
20
20
|
|
21
|
+
## Prerequisite
|
22
|
+
|
23
|
+
The exporter-oltp-metrics depends on two gems that have not been officially released: opentelemetry-metrics-sdk and opentelemetry-metrics-api.
|
24
|
+
|
25
|
+
Within the .gemspec file, these gems are not listed as dependencies. However, for users who need utilize this metrics exporter, they must first install and load these two gems before they can use the exporter.
|
26
|
+
|
27
|
+
To facilitate this, there are couple recommended approaches:
|
28
|
+
|
29
|
+
### 1. Download the source code
|
30
|
+
|
31
|
+
1. Download the [opentelemetry-ruby](https://github.com/open-telemetry/opentelemetry-ruby).
|
32
|
+
2. Navigate to subfolder, then build the [metrics_sdk](https://github.com/open-telemetry/opentelemetry-ruby/tree/main/metrics_sdk) and [metrics_api](https://github.com/open-telemetry/opentelemetry-ruby/tree/main/metrics_api).
|
33
|
+
3. Execute `gem build *.gemspec`.
|
34
|
+
4. Lastly, install the built gem into the system.
|
35
|
+
|
36
|
+
### 2. Using `path:` option in Gemfile with downloaded source code
|
37
|
+
|
38
|
+
git clone [opentelemetry-ruby](https://github.com/open-telemetry/opentelemetry-ruby) first, then use Gemfile
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
# Gemfile
|
42
|
+
source 'https://rubygems.org'
|
43
|
+
gem 'opentelemetry-metrics-api', path: "opentelemetry-ruby/metrics_api"
|
44
|
+
gem 'opentelemetry-metrics-sdk', path: "opentelemetry-ruby/metrics_sdk"
|
45
|
+
```
|
46
|
+
|
47
|
+
### 3. Using `git:` option in Gemfile
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
# Gemfile
|
51
|
+
source 'https://rubygems.org'
|
52
|
+
gem 'opentelemetry-metrics-api', git: "https://github.com/open-telemetry/opentelemetry-ruby", glob: 'metrics_api/*.gemspec'
|
53
|
+
gem 'opentelemetry-metrics-sdk', git: "https://github.com/open-telemetry/opentelemetry-ruby", glob: 'metrics_sdk/*.gemspec'
|
54
|
+
```
|
55
|
+
|
21
56
|
## How do I get started?
|
22
57
|
|
23
58
|
Install the gem using:
|
@@ -67,15 +102,15 @@ The collector exporter can be configured explicitly in code, or via environment
|
|
67
102
|
| ------------------- | -------------------------------------------- | ----------------------------------- |
|
68
103
|
| `endpoint:` | `OTEL_EXPORTER_OTLP_ENDPOINT` | `"http://localhost:4318/v1/metrics"` |
|
69
104
|
| `certificate_file: `| `OTEL_EXPORTER_OTLP_CERTIFICATE` | |
|
105
|
+
| `client_certificate_file: `| `OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE` | |
|
106
|
+
| `client_key_file:` | `OTEL_EXPORTER_OTLP_CLIENT_KEY` | |
|
70
107
|
| `headers:` | `OTEL_EXPORTER_OTLP_HEADERS` | |
|
71
108
|
| `compression:` | `OTEL_EXPORTER_OTLP_COMPRESSION` | `"gzip"` |
|
72
109
|
| `timeout:` | `OTEL_EXPORTER_OTLP_TIMEOUT` | `10` |
|
73
|
-
| `ssl_verify_mode:` | `OTEL_RUBY_EXPORTER_OTLP_SSL_VERIFY_PEER` or | `OpenSSL::SSL:VERIFY_PEER` |
|
74
|
-
| | `OTEL_RUBY_EXPORTER_OTLP_SSL_VERIFY_NONE` | |
|
110
|
+
| `ssl_verify_mode:` | `OTEL_RUBY_EXPORTER_OTLP_SSL_VERIFY_PEER` or `OTEL_RUBY_EXPORTER_OTLP_SSL_VERIFY_NONE` | `OpenSSL::SSL:VERIFY_PEER` |
|
75
111
|
|
76
112
|
`ssl_verify_mode:` parameter values should be flags for server certificate verification: `OpenSSL::SSL:VERIFY_PEER` and `OpenSSL::SSL:VERIFY_NONE` are acceptable. These values can also be set using the appropriately named environment variables as shown where `VERIFY_PEER` will take precedence over `VERIFY_NONE`. Please see [the Net::HTTP docs](https://ruby-doc.org/stdlib-2.7.6/libdoc/net/http/rdoc/Net/HTTP.html#verify_mode) for more information about these flags.
|
77
113
|
|
78
|
-
|
79
114
|
## How can I get involved?
|
80
115
|
|
81
116
|
The `opentelemetry-exporter-otlp-metrics` gem source is [on github][repo-github], along with related gems including `opentelemetry-metrics-sdk`.
|
@@ -26,7 +26,7 @@ module OpenTelemetry
|
|
26
26
|
module OTLP
|
27
27
|
module Metrics
|
28
28
|
# An OpenTelemetry metrics exporter that sends metrics over HTTP as Protobuf encoded OTLP ExportMetricsServiceRequest.
|
29
|
-
class MetricsExporter < ::OpenTelemetry::SDK::Metrics::Export::MetricReader
|
29
|
+
class MetricsExporter < ::OpenTelemetry::SDK::Metrics::Export::MetricReader
|
30
30
|
include Util
|
31
31
|
|
32
32
|
attr_reader :metric_snapshots
|
@@ -47,6 +47,8 @@ module OpenTelemetry
|
|
47
47
|
|
48
48
|
def initialize(endpoint: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_METRICS_ENDPOINT', 'OTEL_EXPORTER_OTLP_ENDPOINT', default: 'http://localhost:4318/v1/metrics'),
|
49
49
|
certificate_file: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE', 'OTEL_EXPORTER_OTLP_CERTIFICATE'),
|
50
|
+
client_certificate_file: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE', 'OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE'),
|
51
|
+
client_key_file: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY', 'OTEL_EXPORTER_OTLP_CLIENT_KEY'),
|
50
52
|
ssl_verify_mode: MetricsExporter.ssl_verify_mode,
|
51
53
|
headers: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_METRICS_HEADERS', 'OTEL_EXPORTER_OTLP_HEADERS', default: {}),
|
52
54
|
compression: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_METRICS_COMPRESSION', 'OTEL_EXPORTER_OTLP_COMPRESSION', default: 'gzip'),
|
@@ -63,7 +65,7 @@ module OpenTelemetry
|
|
63
65
|
URI(endpoint)
|
64
66
|
end
|
65
67
|
|
66
|
-
@http = http_connection(@uri, ssl_verify_mode, certificate_file)
|
68
|
+
@http = http_connection(@uri, ssl_verify_mode, certificate_file, client_certificate_file, client_key_file)
|
67
69
|
|
68
70
|
@path = @uri.path
|
69
71
|
@headers = prepare_headers(headers)
|
@@ -87,7 +89,7 @@ module OpenTelemetry
|
|
87
89
|
end
|
88
90
|
end
|
89
91
|
|
90
|
-
def send_bytes(bytes, timeout:)
|
92
|
+
def send_bytes(bytes, timeout:)
|
91
93
|
return FAILURE if bytes.nil?
|
92
94
|
|
93
95
|
request = Net::HTTP::Post.new(@path)
|
@@ -115,7 +117,7 @@ module OpenTelemetry
|
|
115
117
|
@http.read_timeout = remaining_timeout
|
116
118
|
@http.write_timeout = remaining_timeout
|
117
119
|
@http.start unless @http.started?
|
118
|
-
response =
|
120
|
+
response = @http.request(request)
|
119
121
|
case response
|
120
122
|
when Net::HTTPOK
|
121
123
|
response.body # Read and discard body
|
@@ -181,7 +183,7 @@ module OpenTelemetry
|
|
181
183
|
@http.write_timeout = @timeout
|
182
184
|
end
|
183
185
|
|
184
|
-
def encode(metrics_data)
|
186
|
+
def encode(metrics_data)
|
185
187
|
Opentelemetry::Proto::Collector::Metrics::V1::ExportMetricsServiceRequest.encode(
|
186
188
|
Opentelemetry::Proto::Collector::Metrics::V1::ExportMetricsServiceRequest.new(
|
187
189
|
resource_metrics: metrics_data
|
@@ -215,7 +217,7 @@ module OpenTelemetry
|
|
215
217
|
# current metric sdk only implements instrument: :counter -> :sum, :histogram -> :histogram
|
216
218
|
#
|
217
219
|
# metrics [MetricData]
|
218
|
-
def as_otlp_metrics(metrics)
|
220
|
+
def as_otlp_metrics(metrics)
|
219
221
|
case metrics.instrument_kind
|
220
222
|
when :observable_gauge
|
221
223
|
Opentelemetry::Proto::Metrics::V1::Metric.new(
|
@@ -15,11 +15,13 @@ module OpenTelemetry
|
|
15
15
|
ERROR_MESSAGE_INVALID_HEADERS = 'headers must be a String with comma-separated URL Encoded UTF-8 k=v pairs or a Hash'
|
16
16
|
DEFAULT_USER_AGENT = "OTel-OTLP-MetricsExporter-Ruby/#{OpenTelemetry::Exporter::OTLP::Metrics::VERSION} Ruby/#{RUBY_VERSION} (#{RUBY_PLATFORM}; #{RUBY_ENGINE}/#{RUBY_ENGINE_VERSION})".freeze
|
17
17
|
|
18
|
-
def http_connection(uri, ssl_verify_mode, certificate_file)
|
18
|
+
def http_connection(uri, ssl_verify_mode, certificate_file, client_certificate_file, client_key_file)
|
19
19
|
http = Net::HTTP.new(uri.host, uri.port)
|
20
20
|
http.use_ssl = uri.scheme == 'https'
|
21
21
|
http.verify_mode = ssl_verify_mode
|
22
22
|
http.ca_file = certificate_file unless certificate_file.nil?
|
23
|
+
http.cert = OpenSSL::X509::Certificate.new(File.read(client_certificate_file)) unless client_certificate_file.nil?
|
24
|
+
http.key = OpenSSL::PKey::RSA.new(File.read(client_key_file)) unless client_key_file.nil?
|
23
25
|
http.keep_alive_timeout = KEEP_ALIVE_TIMEOUT
|
24
26
|
http
|
25
27
|
end
|
@@ -67,16 +69,6 @@ module OpenTelemetry
|
|
67
69
|
headers
|
68
70
|
end
|
69
71
|
|
70
|
-
def measure_request_duration
|
71
|
-
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
72
|
-
begin
|
73
|
-
yield
|
74
|
-
ensure
|
75
|
-
stop = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
76
|
-
1000.0 * (stop - start)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
72
|
def parse_headers(raw)
|
81
73
|
entries = raw.split(',')
|
82
74
|
raise ArgumentError, ERROR_MESSAGE_INVALID_HEADERS if entries.empty?
|
@@ -97,7 +89,7 @@ module OpenTelemetry
|
|
97
89
|
end
|
98
90
|
end
|
99
91
|
|
100
|
-
def backoff?(retry_count:, reason:, retry_after: nil)
|
92
|
+
def backoff?(retry_count:, reason:, retry_after: nil)
|
101
93
|
return false if retry_count > RETRY_COUNT
|
102
94
|
|
103
95
|
sleep_interval = nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-exporter-otlp-metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.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: 2024-
|
11
|
+
date: 2024-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: googleapis-common-protos-types
|
@@ -324,10 +324,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
|
324
324
|
licenses:
|
325
325
|
- Apache-2.0
|
326
326
|
metadata:
|
327
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-exporter-otlp-metrics/v0.
|
327
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-exporter-otlp-metrics/v0.2.0/file.CHANGELOG.html
|
328
328
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/exporter/otlp-metrics
|
329
329
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
330
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-exporter-otlp-metrics/v0.
|
330
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-exporter-otlp-metrics/v0.2.0
|
331
331
|
post_install_message:
|
332
332
|
rdoc_options: []
|
333
333
|
require_paths:
|