Skip to content

Commit ad9a5c2

Browse files
plantfansamsimi
andauthored
fix: Add Ruby 3.2 to CI and do small fix (#1434)
* Add Ruby 3.2 to CI. * rescue compatibility error in addition to argument error In ruby 3.2, when you try to `strip` a string with an invalid UTF-8 byte sequence, it appears you get an `Encoding::CompatibilityError`, hence we can now rescue this. * update trace exporter * Raise argument error instead of compatibilty error * appease the cop --------- Co-authored-by: Josef Šimánek <[email protected]>
1 parent 2ed0a9c commit ad9a5c2

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ jobs:
3030
runs-on: ${{ matrix.os }}
3131
steps:
3232
- uses: actions/checkout@v2
33+
- name: "Test Ruby 3.2"
34+
uses: ./.github/actions/test_gem
35+
with:
36+
gem: "${{ matrix.gem }}"
37+
ruby: "3.2"
3338
- name: "Test Ruby 3.1"
39+
if: "${{ matrix.os == 'ubuntu-latest' }}"
3440
uses: ./.github/actions/test_gem
3541
with:
3642
gem: "${{ matrix.gem }}"
@@ -88,7 +94,13 @@ jobs:
8894
runs-on: ${{ matrix.os }}
8995
steps:
9096
- uses: actions/checkout@v2
97+
- name: "Test Ruby 3.2"
98+
uses: ./.github/actions/test_gem
99+
with:
100+
gem: "${{ matrix.gem }}"
101+
ruby: "3.2"
91102
- name: "Test Ruby 3.1"
103+
if: "${{ matrix.os == 'ubuntu-latest' }}"
92104
uses: ./.github/actions/test_gem
93105
with:
94106
gem: "${{ matrix.gem }}"
@@ -158,7 +170,13 @@ jobs:
158170
runs-on: ${{ matrix.os }}
159171
steps:
160172
- uses: actions/checkout@v2
173+
- name: "Test Ruby 3.2"
174+
uses: ./.github/actions/test_gem
175+
with:
176+
gem: "${{ matrix.gem }}"
177+
ruby: "3.2"
161178
- name: "Test Ruby 3.1"
179+
if: "${{ matrix.os == 'ubuntu-latest' }}"
162180
uses: ./.github/actions/test_gem
163181
with:
164182
gem: "${{ matrix.gem }}"

exporter/otlp-http/lib/opentelemetry/exporter/otlp/http/trace_exporter.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ def parse_headers(raw)
271271
begin
272272
k = k.to_s.strip
273273
v = v.to_s.strip
274+
rescue Encoding::CompatibilityError
275+
raise ArgumentError, ERROR_MESSAGE_INVALID_HEADERS
274276
rescue ArgumentError => e
275277
raise e, ERROR_MESSAGE_INVALID_HEADERS
276278
end

exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ def parse_headers(raw)
398398
begin
399399
k = k.to_s.strip
400400
v = v.to_s.strip
401+
rescue Encoding::CompatibilityError
402+
raise ArgumentError, ERROR_MESSAGE_INVALID_HEADERS
401403
rescue ArgumentError => e
402404
raise e, ERROR_MESSAGE_INVALID_HEADERS
403405
end

0 commit comments

Comments
 (0)