Module: RailsOpentracer
- Defined in:
- lib/rails_opentracer.rb,
lib/rails_opentracer/version.rb,
lib/rails_opentracer/middleware.rb,
lib/rails_opentracer/span_helpers.rb,
lib/rails_opentracer/zipkin_config.rb
Defined Under Namespace
Modules: SpanHelpers
Classes: Middleware, Railtie, ZipkinConfig
Constant Summary
collapse
- VERSION =
'0.1.40'.freeze
Instance Method Summary
collapse
Instance Method Details
#get(url) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/rails_opentracer.rb', line 11
def get(url)
connection =
Faraday.new do |con|
con.use Faraday::Adapter::NetHttp
end
if ZipkinConfig.opentracer_enabled_and_zipkin_url_present?
carrier = {}
OpenTracing.inject(@span.context, OpenTracing::FORMAT_RACK, carrier)
connection. = denilize(carrier)
elsif ZipkinConfig.opentracer_enabled?
Rails.logger.error 'TRACER_ERROR: `ZIPKIN_SERVICE_URL` environment variable is not defined'
end
connection.get(url)
end
|
#with_span(name) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/rails_opentracer.rb', line 26
def with_span(name)
if ZipkinConfig.opentracer_enabled_and_zipkin_url_present?
@span =
if $active_span.present?
OpenTracing.start_span(name, child_of: $active_span)
else
OpenTracing.start_span(name)
end
yield if block_given?
@span.finish
elsif block_given?
yield
end
end
|