opentelemetry-instrumentation-sinatra 0.23.5 → 0.24.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/opentelemetry/instrumentation/sinatra/extensions/tracer_extension.rb +16 -14
- data/lib/opentelemetry/instrumentation/sinatra/instrumentation.rb +37 -4
- data/lib/opentelemetry/instrumentation/sinatra/version.rb +1 -1
- data/lib/opentelemetry/instrumentation/sinatra.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c2ff5d9ea266d15b8fa21453c2178c4c3161893c3c2778c603b1dc7ba2788b5
|
4
|
+
data.tar.gz: fd2953b0a5e1bad80eb0a9d40f2df066d4b14e1da77099ff88993299aa3f9dd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a08cea93e13127d14a3b222e908b1724e3a6271a5de3c4330b8b6bd77809aff506ba37d63e4a4e9850ebc88c12e56b2778f9f1e4c3d13e389b71cb60942166b1
|
7
|
+
data.tar.gz: b9c209655a2a32a6e53b2230f05228312dcdc481331cbf91389d18b45e2e98eb40265c6db51a24e05112eb4b9a171614b1898ba19833c953e75b8e74f94cf056
|
data/CHANGELOG.md
CHANGED
@@ -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
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
32
|
-
|
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
|
-
#
|
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
|
@@ -9,7 +9,7 @@ require 'opentelemetry-instrumentation-base'
|
|
9
9
|
|
10
10
|
module OpenTelemetry
|
11
11
|
module Instrumentation
|
12
|
-
#
|
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.
|
4
|
+
version: 0.24.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: 2024-
|
11
|
+
date: 2024-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -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.
|
231
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-sinatra/0.24.0/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.
|
234
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-sinatra/0.24.0
|
235
235
|
post_install_message:
|
236
236
|
rdoc_options: []
|
237
237
|
require_paths:
|