opentelemetry-instrumentation-sinatra 0.23.5 → 0.24.1

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: 91d057f9632745f34d440f2974afc6a5972fbdddf84e78399444cf701f1ccab8
4
- data.tar.gz: 2890bdb60380ef2bc77f8464fd6c7c483491527d0d15398aa53db7184ed62d9a
3
+ metadata.gz: a78599c829d2be9627e4fc53e0b862987080ae7af515024391d22d97293dd485
4
+ data.tar.gz: 7c2da7aebc1a33187902afd199aefe4cbee83866d866021ceec4deb86c078101
5
5
  SHA512:
6
- metadata.gz: 8faf33107b76e7efc4e8b6cbfab31b2425d08847e48b8f5c773977ceb9357f7ab9b07eab53df4c9db626c07fc7335f297673bd506104ac4b7d78aa5326ca050b
7
- data.tar.gz: 60ffc9095d477828fe5f7ec76817d969a0905de37222380ee253ca12dedac7cd7a7f516bcb7af077384aafcbefa310f24dcdbe32360afaabbb0d0f663aae4c80
6
+ metadata.gz: 99d40a9dd38024c716f61d989710c71aa1d55227d506af465dee03a2e7fa52c41104e5aa5acee851eaf99e76a8af7c7eb78dd28d1921e0c2f20370de4b03ffa7
7
+ data.tar.gz: d69cbedefa3bbd4ebcf4726f406113d7e2bd1ad04b5bd8a59bf24314903e101dc7aa207f9c2738970323e6310eb2ecd37ee74da076b86e795f2082c07465486f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Release History: opentelemetry-instrumentation-sinatra
2
2
 
3
+ ### v0.24.1 / 2024-07-23
4
+
5
+ * DOCS: Add cspell to CI
6
+
7
+ ### v0.24.0 / 2024-07-02
8
+
9
+ * ADDED: Make Rack install optional for sinatra
10
+
3
11
  ### v0.23.5 / 2024-06-18
4
12
 
5
13
  * FIXED: Relax otel common gem constraints
@@ -86,7 +94,7 @@
86
94
 
87
95
  ### v0.18.0 / 2021-05-21
88
96
 
89
- * ADDED: Updated API depedency for 1.0.0.rc1
97
+ * ADDED: Updated API dependency for 1.0.0.rc1
90
98
  * BREAKING CHANGE: Remove optional parent_context from in_span
91
99
 
92
100
  * FIXED: Remove optional parent_context from in_span
@@ -146,7 +154,7 @@
146
154
  ### v0.7.0 / 2020-10-07
147
155
 
148
156
  * FIXED: Default to sinatra.route for span name
149
- * DOCS: Standardize toplevel docs structure and readme
157
+ * DOCS: Standardize top-level docs structure and readme
150
158
 
151
159
  ### v0.6.0 / 2020-09-10
152
160
 
@@ -13,23 +13,25 @@ module OpenTelemetry
13
13
  # Sinatra extension that installs TracerMiddleware and provides
14
14
  # tracing for template rendering
15
15
  module TracerExtension
16
- # Sinatra hook after extension is registered
17
- def self.registered(app)
18
- # Create tracing `render` method
19
- ::Sinatra::Base.module_eval do
20
- def render(_engine, data, *)
21
- template_name = data.is_a?(Symbol) ? data : :literal
16
+ # Contants patches for `render` method
17
+ module RenderPatches
18
+ def render(_engine, data, *)
19
+ template_name = data.is_a?(Symbol) ? data : :literal
22
20
 
23
- Sinatra::Instrumentation.instance.tracer.in_span(
24
- 'sinatra.render_template',
25
- attributes: { 'sinatra.template_name' => template_name.to_s }
26
- ) do
27
- super
28
- end
21
+ Sinatra::Instrumentation.instance.tracer.in_span(
22
+ 'sinatra.render_template',
23
+ attributes: { 'sinatra.template_name' => template_name.to_s }
24
+ ) do
25
+ super
29
26
  end
30
27
  end
31
- app.use(*OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.middleware_args)
32
- app.use(Middlewares::TracerMiddleware)
28
+ end
29
+
30
+ # Sinatra hook after extension is registered
31
+ def self.registered(app)
32
+ # Create tracing `render` method
33
+ ::Sinatra::Base.prepend(RenderPatches)
34
+ Sinatra::Instrumentation.instance.install_middleware(app)
33
35
  end
34
36
  end
35
37
  end
@@ -9,18 +9,51 @@ require_relative 'extensions/tracer_extension'
9
9
  module OpenTelemetry
10
10
  module Instrumentation
11
11
  module Sinatra
12
- # The Instrumentation class contains logic to detect and install the Sinatra
13
- # instrumentation
12
+ # The {OpenTelemetry::Instrumentation::Sinatra::Instrumentation} class contains logic to detect and install the Sinatra instrumentation
13
+ #
14
+ # Installation and configuration of this instrumentation is done within the
15
+ # {https://www.rubydoc.info/gems/opentelemetry-sdk/OpenTelemetry/SDK#configure-instance_method OpenTelemetry::SDK#configure}
16
+ # block, calling {https://www.rubydoc.info/gems/opentelemetry-sdk/OpenTelemetry%2FSDK%2FConfigurator:use use()}
17
+ # or {https://www.rubydoc.info/gems/opentelemetry-sdk/OpenTelemetry%2FSDK%2FConfigurator:use_all use_all()}.
18
+ #
19
+ # ## Configuration keys and options
20
+ #
21
+ # ### `:install_rack`
22
+ #
23
+ # Default is `true`. Specifies whether or not to install the Rack instrumentation as part of installing the Sinatra instrumentation.
24
+ # This is useful in cases where you have multiple Rack applications but want to manually specify where to insert the tracing middleware.
25
+ #
26
+ # @example Manually install Rack instrumentation.
27
+ # OpenTelemetry::SDK.configure do |c|
28
+ # c.use_all({
29
+ # 'OpenTelemetry::Instrumentation::Rack' => { },
30
+ # 'OpenTelemetry::Instrumentation::Sinatra' => {
31
+ # install_rack: false
32
+ # },
33
+ # })
34
+ # end
35
+ #
14
36
  class Instrumentation < OpenTelemetry::Instrumentation::Base
15
- install do |_|
16
- OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.install({})
37
+ install do |config|
38
+ OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.install({}) if config[:install_rack]
39
+
40
+ unless OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.installed?
41
+ OpenTelemetry.logger.warn('Rack instrumentation is required for Sinatra but not installed. Please see the docs for more details: https://opentelemetry.io/docs/languages/ruby/libraries/')
42
+ end
17
43
 
18
44
  ::Sinatra::Base.register Extensions::TracerExtension
19
45
  end
20
46
 
47
+ option :install_rack, default: true, validate: :boolean
48
+
21
49
  present do
22
50
  defined?(::Sinatra)
23
51
  end
52
+
53
+ def install_middleware(app)
54
+ app.use(*OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.middleware_args) if config[:install_rack]
55
+ app.use(Middlewares::TracerMiddleware)
56
+ end
24
57
  end
25
58
  end
26
59
  end
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Sinatra
10
- VERSION = '0.23.5'
10
+ VERSION = '0.24.1'
11
11
  end
12
12
  end
13
13
  end
@@ -9,7 +9,7 @@ require 'opentelemetry-instrumentation-base'
9
9
 
10
10
  module OpenTelemetry
11
11
  module Instrumentation
12
- # Contains the OpenTelemetry instrumentation for the Sinatra gem
12
+ # (see OpenTelemetry::Instrumentation::Sinatra::Instrumentation)
13
13
  module Sinatra
14
14
  end
15
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-instrumentation-sinatra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.5
4
+ version: 0.24.1
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-06-18 00:00:00.000000000 Z
11
+ date: 2024-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.64.0
145
+ version: 1.65.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.64.0
152
+ version: 1.65.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rubocop-performance
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -228,10 +228,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
228
228
  licenses:
229
229
  - Apache-2.0
230
230
  metadata:
231
- changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-sinatra/0.23.5/file/CHANGELOG.md
231
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-sinatra/0.24.1/file/CHANGELOG.md
232
232
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/sinatra
233
233
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
234
- documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-sinatra/0.23.5
234
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-sinatra/0.24.1
235
235
  post_install_message:
236
236
  rdoc_options: []
237
237
  require_paths: