restify 2.0.0 → 2.0.1

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: 85964ce70270ead0fcc3271b733611bcb97f8415e03a91b46cb402032a4c68f5
4
- data.tar.gz: 0c99e59283131de272b9a2a1ad23589395bb89e5b8753e330f305e7ec1483685
3
+ metadata.gz: 2b3748ffce3669fb7d0cf84c08ef2cb5732e18edd0a2c7f49c611c00a7d09058
4
+ data.tar.gz: 86918b318d74c3c1fa5ed03e68bd4fcc877a0697b37a324407508a1d2cb78477
5
5
  SHA512:
6
- metadata.gz: 58bf934808c55172f28ec0673f543531c935b68e8e1f8fcf62435b49dfd7ab2e13522ef6c8b675fbfaf234be7ebfac4fdbfe05d57da4e97288b3876000a2487f
7
- data.tar.gz: 4617aa58aa9ba400e1f28a0e5a854c5b56a560abb818432211958295e695feab6fe4bfeb0b5bd6418b231260db778804f4cf5309a34f8d1db9cb501d5f48fe6b
6
+ metadata.gz: 8fca1f764083979b98c66a55c2a3d49e3ad4c77bff142f2e5af8d40c4003fd2151bb8bce4076cb66b856b91054fba4cb814bb0635d2b3be3cf9d7e6b301f79f2
7
+ data.tar.gz: bdb52897e18ae8ba441128f9147a383ddde7e777f92ab59cce5353ac8e8feda23c9af072f9aaf2b4cb252085840bb7ef70927b289a42b66e6209a650d3d5a4c5
data/CHANGELOG.md CHANGED
@@ -17,6 +17,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
17
17
 
18
18
  ### Breaks
19
19
 
20
+ ## 2.0.1 - (2025-02-16)
21
+
22
+ ---
23
+
24
+ ### Fixes
25
+
26
+ - Restore compatibility with WebMocks Typhoeus instrumentation
27
+ - Catch WebMock exception and bubble them to the request promises
28
+
20
29
  ## 2.0.0 - (2025-02-14)
21
30
 
22
31
  ---
@@ -0,0 +1,192 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.37
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="file_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'><h1 id="restify">Restify</h1>
61
+
62
+ <p><a href="https://rubygems.org/gems/restify"><img src="https://img.shields.io/gem/v/restify?logo=ruby" alt="Gem Version"></a>
63
+ <a href="https://github.com/jgraichen/restify/actions"><img src="https://img.shields.io/github/actions/workflow/status/jgraichen/restify/test.yml?logo=github" alt="GitHub Actions Workflow Status"></a>
64
+ <a href="https://codebeat.co/projects/github-com-jgraichen-restify-main"><img src="https://codebeat.co/badges/368f8033-bd76-48bc-9777-85f1d4befa94" alt="Code Quality"></a></p>
65
+
66
+ <p>Restify is an hypermedia REST client that does parallel, concurrent and keep-alive requests by default.</p>
67
+
68
+ <p>Restify scans Link headers and returned resource for links and relations to other resources, represented as RFC6570 URI Templates, and exposes those to the developer.</p>
69
+
70
+ <p>Restify can be used to consume hypermedia REST APIs (like GitHubs), to build a site-specific library or to use within your own backend services.</p>
71
+
72
+ <p>Restify is build upon the following libraries:</p>
73
+
74
+ <ul>
75
+ <li><a href="https://github.com/ruby-concurrency/concurrent-ruby">concurrent-ruby</a></li>
76
+ <li><a href="https://github.com/sporkmonger/addressable">addressable</a></li>
77
+ <li><a href="https://github.com/typhoeus/typhoeus">typhoeus</a></li>
78
+ </ul>
79
+
80
+ <p>The HTTP adapters are mostly run in a background thread and may not survive mid-application forks.</p>
81
+
82
+ <p>Restify includes processors to parse responses and to extract links between resources. The following formats are can be parsed:</p>
83
+
84
+ <ul>
85
+ <li>JSON</li>
86
+ <li>MessagePack</li>
87
+ </ul>
88
+
89
+ <p>Links are extracted from</p>
90
+
91
+ <ul>
92
+ <li>HTTP Link header</li>
93
+ <li>Github-style relations in payloads</li>
94
+ </ul>
95
+
96
+ <h2 id="installation">Installation</h2>
97
+
98
+ <p>Add it to your Gemfile:</p>
99
+
100
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>restify</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>~&gt; 2.0</span><span class='tstring_end'>&#39;</span></span>
101
+ </code></pre>
102
+
103
+ <p>Or install it manually:</p>
104
+
105
+ <pre class="code console"><code class="console">gem install restify
106
+ </code></pre>
107
+
108
+ <h2 id="usage">Usage</h2>
109
+
110
+ <p>Create new Restify object. It essentially means to request some start-resource usually the &quot;root&quot; resource:</p>
111
+
112
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Restify.html" title="Restify (module)">Restify</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Restify/Global.html#new-instance_method" title="Restify::Global#new (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>https://api.github.com</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span>
113
+ <span class='comment'># =&gt; {&quot;current_user_url&quot;=&gt;&quot;https://api.github.com/user&quot;,
114
+ </span><span class='comment'># &quot;current_user_authorizations_html_url&quot;=&gt;&quot;https://github.com/settings/connections/applications{/client_id}&quot;,
115
+ </span><span class='comment'># ...
116
+ </span><span class='comment'># &quot;repository_url&quot;=&gt;&quot;https://api.github.com/repos/{owner}/{repo}&quot;,
117
+ </span><span class='comment'># ...
118
+ </span></code></pre>
119
+
120
+ <p>We are essentially requesting <code>&#39;http://api.github.com&#39;</code> via HTTP <code>get</code>. <code>get</code> is returning a <code>Promise</code>, similar to Java&#39;s <code>Future</code>. The <code>value</code> call resolves the returned <code>Promise</code> by blocking the thread until the resource is actually there. <code>value!</code> will additionally raise errors instead of returning <code>nil</code>. You can chain handlers using the <code>then</code> method. This allows you to be build a dependency chain that will be executed when the last promise is needed.</p>
121
+
122
+ <p>As we can see GitHub returns us a field <code>repository_url</code> with a URI template. Restify automatically scans for <code>*_url</code> fields in the JSON response and exposes these as relations. It additionally scans the HTTP Header field <code>Link</code> for relations like pagination.</p>
123
+
124
+ <p>We can now use the relations to navigate from resource to resource like a browser from one web page to another page.</p>
125
+
126
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_repositories'>repositories</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_rel'>rel</span><span class='lparen'>(</span><span class='symbol'>:repository</span><span class='rparen'>)</span>
127
+ <span class='comment'># =&gt; #&lt;Restify::Relation:0x00000005548968 @context=#&lt;Restify::Context:0x007f6024066ae0 @uri=#&lt;Addressable::URI:0x29d8684 URI:https://api.github.com&gt;&gt;, @template=#&lt;Addressable::Template:0x2aa44a0 PATTERN:https://api.github.com/repos/{owner}/{repo}&gt;&gt;
128
+ </span></code></pre>
129
+
130
+ <p>This gets us the relation named <code>repository</code> that we can request now. The usual HTTP methods are available on a relation:</p>
131
+
132
+ <pre class="code ruby"><code class="ruby">def get(params, params:, headers:, **)
133
+ def head(params, params:, headers:, **)
134
+ def delete(params, params:, headers:, **)
135
+
136
+ def put(data = nil, params:, headers:, **)
137
+ def post(data = nil, params:, headers:, **)
138
+ def patch(data = nil, params:, headers:, **)
139
+ </code></pre>
140
+
141
+ <p>URL templates can define some parameters such as <code>{owner}</code> or <code>{repo}</code>. They will be expanded from the <code>params</code> given to the HTTP method.</p>
142
+
143
+ <p>Now send a GET request with some parameters to request a specific repository:</p>
144
+
145
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_repo'>repo</span> <span class='op'>=</span> <span class='id identifier rubyid_repositories'>repositories</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>owner:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>jgraichen</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>repo:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>restify</span><span class='tstring_end'>&#39;</span></span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span>
146
+ </code></pre>
147
+
148
+ <p>Now fetch a list of commits for this repo and get this first one:</p>
149
+
150
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_commit'>commit</span> <span class='op'>=</span> <span class='id identifier rubyid_repo'>repo</span><span class='period'>.</span><span class='id identifier rubyid_rel'>rel</span><span class='lparen'>(</span><span class='symbol'>:commits</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
151
+ </code></pre>
152
+
153
+ <p>And print it:</p>
154
+
155
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Last commit: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_commit'>commit</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>sha</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
156
+ <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>By </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_commit'>commit</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>commit</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>author</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>name</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'> &lt;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_commit'>commit</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>commit</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>author</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>email</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>&gt;</span><span class='tstring_end'>&quot;</span></span>
157
+ <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_commit'>commit</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>commit</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>message</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
158
+ </code></pre>
159
+
160
+ <p>See commented example in main spec <a href="https://github.com/jgraichen/restify/blob/master/spec/restify_spec.rb#L100"><code>spec/restify_spec.rb</code></a> or in the <code>examples</code> directory.</p>
161
+
162
+ <h2 id="contributing">Contributing</h2>
163
+
164
+ <ol>
165
+ <li><a href="http://github.com/jgraichen/restify/fork">Fork it</a></li>
166
+ <li>Create your feature branch (<code>git checkout -b my-new-feature</code>)</li>
167
+ <li>Commit specs for your feature so that I do not break it later</li>
168
+ <li>Commit your changes (<code>git commit -am &#39;Add some feature&#39;</code>)</li>
169
+ <li>Push to the branch (<code>git push origin my-new-feature</code>)</li>
170
+ <li>Create new Pull Request</li>
171
+ </ol>
172
+
173
+ <h2 id="license">License</h2>
174
+
175
+ <p>Copyright (C) 2014-2025 Jan Graichen</p>
176
+
177
+ <p>This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</p>
178
+
179
+ <p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.</p>
180
+
181
+ <p>You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>.</p>
182
+ </div></div>
183
+
184
+ <div id="footer">
185
+ Generated on Sun Feb 16 14:11:59 2025 by
186
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
187
+ 0.9.37 (ruby-3.4.2).
188
+ </div>
189
+
190
+ </div>
191
+ </body>
192
+ </html>
@@ -23,19 +23,21 @@ module Restify
23
23
  tcp_keepintvl: 5,
24
24
  }.freeze
25
25
 
26
- # Patch to store easy handles in the queue, instead of requests.
27
- # This improves compatibility with OpenTelemetry instrumentation
28
- # for Ethon, that needs the request handle to be constructed in
29
- # the current threading context, not the background thread were
30
- # Typhoeus is running.
26
+ # Patch Hydra to restore the correct OpenTelemetry span when
27
+ # adding the request, so that the Ethon instrumentation can
28
+ # properly pick up the context where the Restify request
29
+ # originated from.
30
+ #
31
+ # Handle exception from Ethon or WebMock too, and reject the
32
+ # promise, so that the errors can be handled in user code.
33
+ # Otherwise, the user would only receive a Promise timeout.
31
34
  module EasyOverride
32
- def queue(request)
33
- request.hydra = self
34
- queued_requests << ::Typhoeus::EasyFactory.new(request, self).get
35
- end
36
-
37
- def add(handle)
38
- multi.add(handle)
35
+ def add(request)
36
+ OpenTelemetry::Trace.with_span(request._otel_span) do
37
+ super(request)
38
+ rescue Exception => e # rubocop:disable Lint/RescueException
39
+ request._restify_writer.reject(e)
40
+ end
39
41
  end
40
42
  end
41
43
 
@@ -78,7 +80,7 @@ module Restify
78
80
  private
79
81
 
80
82
  def convert(request, writer)
81
- ::Typhoeus::Request.new(
83
+ Request.new(
82
84
  request.uri,
83
85
  **@options,
84
86
  method: request.method,
@@ -87,6 +89,9 @@ module Restify
87
89
  timeout: request.timeout,
88
90
  connecttimeout: request.timeout,
89
91
  ).tap do |req|
92
+ req._otel_span = OpenTelemetry::Trace.current_span
93
+ req._restify_writer = writer
94
+
90
95
  req.on_complete do |response|
91
96
  debug 'request:complete',
92
97
  tag: request.object_id,
@@ -177,6 +182,16 @@ module Restify
177
182
  def _log_prefix
178
183
  "[#{object_id}/#{Thread.current.object_id}]"
179
184
  end
185
+
186
+ class Request < ::Typhoeus::Request
187
+ # Keep track of the OTEL span and the restify promise in the
188
+ # queued Typhoeus request.
189
+ #
190
+ # We need to access these to restore the tracing context, or
191
+ # bubble up exception that happen in the background thread after
192
+ # queuing, but when Hydra adds the requests to libcurl.
193
+ attr_accessor :_otel_span, :_restify_writer
194
+ end
180
195
  end
181
196
  end
182
197
  end
@@ -4,7 +4,7 @@ module Restify
4
4
  module VERSION
5
5
  MAJOR = 2
6
6
  MINOR = 0
7
- PATCH = 0
7
+ PATCH = 1
8
8
  STAGE = nil
9
9
  STRING = [MAJOR, MINOR, PATCH, STAGE].compact.join('.').freeze
10
10
 
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Restify do
6
+ subject(:echo) { resource.data }
7
+
8
+ let(:resource) { Restify.new('http://localhost:9292/echo').get.value! }
9
+
10
+ before do
11
+ expect(OTLE_EXPORTER.finished_spans).to be_empty
12
+ end
13
+
14
+ describe 'OpenTelemetry' do
15
+ it 'adds propagation header' do
16
+ expect(echo).to have_key('HTTP_TRACEPARENT')
17
+ end
18
+
19
+ it 'adds spans' do
20
+ resource
21
+
22
+ spans = OTLE_EXPORTER.finished_spans
23
+ expect(spans.size).to eq 2
24
+
25
+ spans[1].tap do |span|
26
+ expect(span.instrumentation_scope.name).to eq 'restify'
27
+ expect(span.instrumentation_scope.version).to eq Restify::VERSION.to_s
28
+ expect(span.attributes).to eq({
29
+ 'http.request.method' => 'GET',
30
+ 'http.response.status_code' => 200,
31
+ 'server.address' => 'localhost',
32
+ 'server.port' => 9292,
33
+ 'url.full' => 'http://localhost:9292/echo',
34
+ 'url.scheme' => 'http',
35
+ })
36
+ end
37
+
38
+ # Latest span has to be from the Ethon instrumentation and must
39
+ # have the Restify span as a parent.
40
+ spans[0].tap do |span|
41
+ expect(span.instrumentation_scope.name).to match(/Ethon/)
42
+ expect(span.parent_span_id).to eq spans[1].span_id
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Restify do
6
+ before do
7
+ WebMock.enable!
8
+ end
9
+
10
+ after do
11
+ WebMock.disable!(except: %i[net_http])
12
+ end
13
+
14
+ describe 'WebMock' do
15
+ subject(:resource) { Restify.new('http://www.example.com/base').get.value! }
16
+
17
+ it 'can stub requests' do
18
+ stub_request(:any, 'http://www.example.com/base')
19
+
20
+ expect(resource.response.status).to eq(:ok)
21
+ end
22
+
23
+ it 'raises error for not stubbed requests' do
24
+ expect { resource }.to raise_error WebMock::NetConnectNotAllowedError
25
+ end
26
+ end
27
+ end
data/spec/spec_helper.rb CHANGED
@@ -30,6 +30,7 @@ if ENV['ADAPTER']
30
30
  end
31
31
  end
32
32
 
33
+ require_relative 'support/opentelemetry'
33
34
  require_relative 'support/stub_server'
34
35
 
35
36
  RSpec.configure do |config|
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'opentelemetry/sdk'
4
+ require 'opentelemetry/instrumentation/ethon'
5
+
6
+ OTLE_EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new
7
+ span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(OTLE_EXPORTER)
8
+
9
+ OpenTelemetry::SDK.configure do |c|
10
+ c.error_handler = ->(exception:, message:) { raise(exception || message) }
11
+ c.logger = Logger.new($stderr, level: ENV.fetch('OTEL_LOG_LEVEL', 'fatal').to_sym)
12
+ c.add_span_processor span_processor
13
+
14
+ c.use 'OpenTelemetry::Instrumentation::Ethon'
15
+ end
16
+
17
+ RSpec.configure do |config|
18
+ config.around do |example|
19
+ OTLE_EXPORTER.reset
20
+
21
+ original_propagation = OpenTelemetry.propagation
22
+ propagator = OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator
23
+ OpenTelemetry.propagation = propagator
24
+
25
+ example.run
26
+ ensure
27
+ OpenTelemetry.propagation = original_propagation
28
+ end
29
+ end
@@ -18,6 +18,10 @@ module Stub
18
18
  # If no stub is found a special HTTP 599 error code will be returned.
19
19
  class Handler
20
20
  def call(env)
21
+ if env['REQUEST_URI'] == '/echo'
22
+ return [200, {'content-type': 'application/json'}, [env.to_json]]
23
+ end
24
+
21
25
  signature = WebMock::RequestSignature.new(
22
26
  env['REQUEST_METHOD'].downcase,
23
27
  "http://stubserver#{env['REQUEST_URI']}",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restify
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-14 00:00:00.000000000 Z
10
+ date: 2025-02-16 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport
@@ -160,6 +160,7 @@ files:
160
160
  - CHANGELOG.md
161
161
  - LICENSE.txt
162
162
  - README.md
163
+ - doc/file.README.html
163
164
  - lib/restify.rb
164
165
  - lib/restify/adapter/base.rb
165
166
  - lib/restify/adapter/telemetry.rb
@@ -186,10 +187,12 @@ files:
186
187
  - spec/restify/context_spec.rb
187
188
  - spec/restify/error_spec.rb
188
189
  - spec/restify/features/head_requests_spec.rb
190
+ - spec/restify/features/opentelemetry_spec.rb
189
191
  - spec/restify/features/request_bodies_spec.rb
190
192
  - spec/restify/features/request_errors_spec.rb
191
193
  - spec/restify/features/request_headers_spec.rb
192
194
  - spec/restify/features/response_errors_spec.rb
195
+ - spec/restify/features/webmock_spec.rb
193
196
  - spec/restify/global_spec.rb
194
197
  - spec/restify/link_spec.rb
195
198
  - spec/restify/processors/base_spec.rb
@@ -202,6 +205,7 @@ files:
202
205
  - spec/restify/timeout_spec.rb
203
206
  - spec/restify_spec.rb
204
207
  - spec/spec_helper.rb
208
+ - spec/support/opentelemetry.rb
205
209
  - spec/support/stub_server.rb
206
210
  homepage: https://github.com/jgraichen/restify
207
211
  licenses: