opentelemetry-common 0.14.0 → 0.19.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: 1dcc91a5cff7866e5f3a083305bf12db4853c15c907e7e46644045cd1fc8578c
4
- data.tar.gz: 35261314130175ed09723633373238b1c9718e6e603e9c98aeec728416075b57
3
+ metadata.gz: 60edcde9894cb1557d7520894daeb80885ca09f88d1f7afa4b42fc42ca215e09
4
+ data.tar.gz: e7133c891b98460419438509074931b647e987a099704f0da47f98d1a90182ec
5
5
  SHA512:
6
- metadata.gz: 40e5f48d5576429a3f8dd3d777de7039bcc94ca20298d6be7d8daac766fa7b992ff05db367ff9cfb8b53de95f8078e72673fa63411bd86cab869bd7fde851c05
7
- data.tar.gz: c09f7152fda0d8c260e426356f5ee3200a075736b2091b408341eddbec42443f8dc23f1f9696d59c690ea767c6313572594c822b5d914af1cc07321b59f986ef
6
+ metadata.gz: 41de8ff040c84ef6ec156c168426e72f46e215aaeacacf089b9bbcaad7efd69903fe15e62593d7726dd0bc0def2abd6be05b4cfedb849b99008fc69d2bf8bc3a
7
+ data.tar.gz: fa0ba69125bc824dd794154d207e1c8d95b6b00dcff9f60a3fbf07eda6933bb52ded8b3c7370cab9412a6011b3d5fa43e6dcb9e2c6404863674580ccb252c68b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
 
2
2
 
3
+ ### v0.19.0 / 2021-06-23
4
+
5
+ * ADDED: Add Tracer.non_recording_span to API
6
+
7
+ ### v0.18.0 / 2021-05-21
8
+
9
+ * BREAKING CHANGE: Replace Time.now with Process.clock_gettime
10
+
11
+ * FIXED: Replace Time.now with Process.clock_gettime
12
+
13
+ ### v0.17.0 / 2021-04-22
14
+
15
+ * ADDED: Add zipkin exporter
16
+ * ADDED: Processors validate exporters on init.
17
+
18
+ ### v0.16.0 / 2021-03-17
19
+
20
+ * ADDED: Instrument lmdb gem
21
+ * FIXED: Remove passwords from http.url
22
+ * DOCS: Replace Gitter with GitHub Discussions
23
+
24
+ ### v0.15.0 / 2021-02-18
25
+
26
+ * (No significant changes)
27
+
3
28
  ### v0.14.0 / 2021-02-03
4
29
 
5
30
  * (No significant changes)
data/README.md CHANGED
@@ -53,8 +53,10 @@ end
53
53
 
54
54
  The `opentelemetry-common` gem source is on github, along with related gems.
55
55
 
56
- 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.
56
+ The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] 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.
57
57
 
58
58
  ## License
59
59
 
60
60
  The `opentelemetry-common` gem is distributed under the Apache 2.0 license. See LICENSE for more information.
61
+
62
+ [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright The OpenTelemetry Authors
4
+ #
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ def with_env(new_env)
8
+ env_to_reset = ENV.select { |k, _| new_env.key?(k) }
9
+ keys_to_delete = new_env.keys - ENV.keys
10
+ new_env.each_pair { |k, v| ENV[k] = v }
11
+ yield
12
+ ensure
13
+ env_to_reset.each_pair { |k, v| ENV[k] = v }
14
+ keys_to_delete.each { |k| ENV.delete(k) }
15
+ end
16
+
17
+ def exportable_timestamp(time = Time.now)
18
+ (time.to_r * 1_000_000_000).to_i
19
+ end
@@ -14,13 +14,29 @@ module OpenTelemetry
14
14
 
15
15
  # Returns nil if timeout is nil, 0 if timeout has expired,
16
16
  # or the remaining (positive) time left in seconds.
17
+ #
18
+ # @param [Numeric] timeout The timeout in seconds. May be nil.
19
+ # @param [Numeric] start_time Start time for timeout returned
20
+ # by {timeout_timestamp}.
21
+ #
22
+ # @return [Numeric] remaining (positive) time left in seconds.
23
+ # May be nil.
17
24
  def maybe_timeout(timeout, start_time)
18
25
  return nil if timeout.nil?
19
26
 
20
- timeout -= (Time.now - start_time)
27
+ timeout -= (timeout_timestamp - start_time)
21
28
  timeout.positive? ? timeout : 0
22
29
  end
23
30
 
31
+ # Returns a timestamp suitable to pass as the start_time
32
+ # argument to {maybe_timeout}. This has no meaning outside
33
+ # of the current process.
34
+ #
35
+ # @return [Numeric]
36
+ def timeout_timestamp
37
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
38
+ end
39
+
24
40
  # Encodes a string in utf8
25
41
  #
26
42
  # @param [String] string The string to be utf8 encoded
@@ -46,8 +62,37 @@ module OpenTelemetry
46
62
  placeholder
47
63
  end
48
64
 
65
+ # Truncates a string if it exceeds the size provided.
66
+ #
67
+ # @param [String] string The string to be truncated
68
+ # @param [Integer] size The max size of the string
69
+ #
70
+ # @return [String]
71
+ def truncate(string, size)
72
+ string.size > size ? "#{string[0...size - 3]}..." : string
73
+ end
74
+
49
75
  def untraced
50
- OpenTelemetry::Trace.with_span(OpenTelemetry::Trace::Span.new) { yield }
76
+ OpenTelemetry::Trace.with_span(OpenTelemetry::Trace.non_recording_span(OpenTelemetry::Trace::SpanContext.new)) { yield }
77
+ end
78
+
79
+ # Returns a URL string with userinfo removed.
80
+ #
81
+ # @param [String] url The URL string to cleanse.
82
+ #
83
+ # @return [String] the cleansed URL.
84
+ def cleanse_url(url)
85
+ cleansed_url = URI.parse(url)
86
+ cleansed_url.password = nil
87
+ cleansed_url.user = nil
88
+ cleansed_url.to_s
89
+ rescue URI::Error
90
+ url
91
+ end
92
+
93
+ # Returns true if exporter is a valid exporter.
94
+ def valid_exporter?(exporter)
95
+ exporter && %i[export shutdown force_flush].all? { |m| exporter.respond_to?(m) }
51
96
  end
52
97
  end
53
98
  end
@@ -6,6 +6,6 @@
6
6
 
7
7
  module OpenTelemetry
8
8
  module Common
9
- VERSION = '0.14.0'
9
+ VERSION = '0.19.0'
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.19.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: 2021-02-03 00:00:00.000000000 Z
11
+ date: 2021-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.14.0
19
+ version: 1.0.0.rc2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.14.0
26
+ version: 1.0.0.rc2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -137,16 +137,17 @@ files:
137
137
  - lib/opentelemetry/common.rb
138
138
  - lib/opentelemetry/common/http.rb
139
139
  - lib/opentelemetry/common/http/client_context.rb
140
+ - lib/opentelemetry/common/test_helpers.rb
140
141
  - lib/opentelemetry/common/utilities.rb
141
142
  - lib/opentelemetry/common/version.rb
142
143
  homepage: https://github.com/open-telemetry/opentelemetry-ruby
143
144
  licenses:
144
145
  - Apache-2.0
145
146
  metadata:
146
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-common/v0.14.0/file.CHANGELOG.html
147
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-common/v0.19.0/file.CHANGELOG.html
147
148
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/common
148
149
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
149
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-common/v0.14.0
150
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-common/v0.19.0
150
151
  post_install_message:
151
152
  rdoc_options: []
152
153
  require_paths:
@@ -162,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
163
  - !ruby/object:Gem::Version
163
164
  version: '0'
164
165
  requirements: []
165
- rubygems_version: 3.1.4
166
+ rubygems_version: 3.1.6
166
167
  signing_key:
167
168
  specification_version: 4
168
169
  summary: Common helpers for OpenTelemetry