opentelemetry-common 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3fa580b58803ab61d7f60c80576fee3012197cbd3819a23430f58f03210e397
4
- data.tar.gz: 0fed67cb9dab224fa0705a4e45106d70716adf5b46f0a50cb34490eef93c4276
3
+ metadata.gz: 5770bd4c706c29a084505ab091a83da8752eb31f5cb1287bee064c522446b20d
4
+ data.tar.gz: 70fadc8a4a72c3b80154b53b227be12c3fbe5550aed9064ead579816ee08ec9e
5
5
  SHA512:
6
- metadata.gz: 9fa9cd94d3b5d766fea3e7d7bf575fab6b1169767efcaded96d045daf9ad83d2ddac642cd882854138c98b3cce16ac437f79ab575ca9841b6bb458b88077b85c
7
- data.tar.gz: f43abd95f657c1751a2f230504c43ceed199979026a48c9f3d0b4677b2da978a4392ae8fa2d96d06bbd98000556a21012db3599e6b8268306237b4df1ec39e91
6
+ metadata.gz: ef34f32f90cb1e2e48657777c8ceb91623238fc0e309fc2c47753ea0be4d372d66d9cde74faa755df2e2e16bc3a48f69359e4f397bca7837527b30978ecfd39a
7
+ data.tar.gz: eb1a5b1219c5379af28646795d26ffc8abee5fa19ba6af16de611d56e1dfae2fa958880b2c9c0b1fc662ae488a5bfc200494baabda06f036aaf1b988c9258fb5
@@ -1,5 +1,10 @@
1
1
 
2
2
 
3
+ ### v0.11.0 / 2020-12-11
4
+
5
+ * ADDED: Move utf8 encoding to common utils
6
+ * FIXED: Copyright comments to not reference year
7
+
3
8
  ### v0.10.0 / 2020-12-03
4
9
 
5
10
  * FIXED: Common gem should depend on api gem
data/LICENSE CHANGED
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2020 OpenTelemetry Authors
189
+ Copyright The OpenTelemetry Authors
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2020 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2020 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2020 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2020 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2020 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
@@ -10,15 +10,41 @@ module OpenTelemetry
10
10
  module Utilities
11
11
  extend self
12
12
 
13
- # @api private
14
- #
15
- # Returns nil if timeout is nil, 0 if timeout has expired, or the remaining (positive) time left in seconds.
13
+ STRING_PLACEHOLDER = ''.encode(::Encoding::UTF_8).freeze
14
+
15
+ # Returns nil if timeout is nil, 0 if timeout has expired,
16
+ # or the remaining (positive) time left in seconds.
16
17
  def maybe_timeout(timeout, start_time)
17
18
  return nil if timeout.nil?
18
19
 
19
20
  timeout -= (Time.now - start_time)
20
21
  timeout.positive? ? timeout : 0
21
22
  end
23
+
24
+ # Encodes a string in utf8
25
+ #
26
+ # @param [String] string The string to be utf8 encoded
27
+ # @param [optional boolean] binary This option is for displaying binary data
28
+ # @param [optional String] placeholder The fallback string to be used if encoding fails
29
+ #
30
+ # @return [String]
31
+ def utf8_encode(string, binary: false, placeholder: STRING_PLACEHOLDER)
32
+ string = string.to_s
33
+
34
+ if binary
35
+ # This option is useful for "gracefully" displaying binary data that
36
+ # often contains text such as marshalled objects
37
+ string.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
38
+ elsif string.encoding == ::Encoding::UTF_8
39
+ string
40
+ else
41
+ string.encode(::Encoding::UTF_8)
42
+ end
43
+ rescue StandardError => e
44
+ OpenTelemetry.logger.debug("Error encoding string in UTF-8: #{e}")
45
+
46
+ placeholder
47
+ end
22
48
  end
23
49
  end
24
50
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2020 OpenTelemetry Authors
3
+ # Copyright The OpenTelemetry Authors
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
7
7
  module OpenTelemetry
8
8
  module Common
9
- VERSION = '0.10.0'
9
+ VERSION = '0.11.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.10.0
4
+ version: 0.11.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-12-03 00:00:00.000000000 Z
11
+ date: 2020-12-11 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.10.0
19
+ version: 0.11.0
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.10.0
26
+ version: 0.11.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -143,10 +143,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
143
143
  licenses:
144
144
  - Apache-2.0
145
145
  metadata:
146
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-common/v0.10.0/file.CHANGELOG.html
146
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-common/v0.11.0/file.CHANGELOG.html
147
147
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/common
148
148
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
149
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-common/v0.10.0
149
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-common/v0.11.0
150
150
  post_install_message:
151
151
  rdoc_options: []
152
152
  require_paths: