Module: Vault::Tracing
- Defined in:
- lib/vault-tools/tracing.rb,
lib/vault-tools/tracing/sidekiq_client.rb,
lib/vault-tools/tracing/sidekiq_server.rb
Defined Under Namespace
Classes: SidekiqClient, SidekiqServer
Constant Summary collapse
- ZIPKIN_API_HOST_STAGING =
'https://zipkin-staging.heroku.tools'.freeze
Class Method Summary collapse
-
.config ⇒ Hash
Configuration options for the Zipkin RackHandler.
-
.configure ⇒ Object
Injects the zipkin middleware into the Web class, add Zipkin middleware to Excon, and adds Zipkin middleware to Sidekiq.
-
.enabled? ⇒ true
A helper to guard against injecting Zipkin when not desired.
-
.setup_sidekiq(sidekiq = Sidekiq) ⇒ Object
Adds our SidekiqClient and SidekiqServer middlware to Sidekiq.
-
.trace_local(name, tracer = ZipkinTracer::TraceClient, **options) {|the_block_passed_in| ... } ⇒ Object
Traces a local component.
Class Method Details
.config ⇒ Hash
Configuration options for the Zipkin RackHandler.
49 50 51 52 53 54 55 56 57 |
# File 'lib/vault-tools/tracing.rb', line 49 def self.config { service_name: "#{Config.app_name}.herokuapp.com", service_port: 443, json_api_host: Config[:zipkin_api_host], sample_rate: (Config[:zipkin_sample_rate] || 0.1).to_f, sampled_as_boolean: false } end |
.configure ⇒ Object
Injects the zipkin middleware into the Web class, add Zipkin middleware to Excon, and adds Zipkin middleware to Sidekiq.
14 15 16 17 18 19 20 21 |
# File 'lib/vault-tools/tracing.rb', line 14 def self.configure return unless Vault::Tracing.enabled? Vault::Web.instance_eval { require 'zipkin-tracer' } Vault::Web.use ZipkinTracer::RackHandler, config setup_excon setup_sidekiq end |
.enabled? ⇒ true
A helper to guard against injecting Zipkin when not desired.
62 63 64 65 66 |
# File 'lib/vault-tools/tracing.rb', line 62 def self.enabled? Config.app_name && Config[:zipkin_enabled] == 'true' && Config[:zipkin_api_host] end |
.setup_sidekiq(sidekiq = Sidekiq) ⇒ Object
Adds our SidekiqClient and SidekiqServer middlware to Sidekiq
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/vault-tools/tracing.rb', line 86 def self.setup_sidekiq(sidekiq = Sidekiq) return unless defined?(sidekiq) sidekiq.configure_client do |config| config.client_middleware do |chain| chain.add Vault::Tracing::SidekiqClient end end sidekiq.configure_server do |config| config.client_middleware do |chain| chain.add Vault::Tracing::SidekiqClient end config.server_middleware do |chain| chain.add Vault::Tracing::SidekiqServer, Vault::Tracing.config end end end |
.trace_local(name, tracer = ZipkinTracer::TraceClient, **options) {|the_block_passed_in| ... } ⇒ Object
Traces a local component. Useful to track down long running implementation methods within an app, instead of only tracing external calls.
36 37 38 39 40 41 42 43 44 |
# File 'lib/vault-tools/tracing.rb', line 36 def self.trace_local(name, tracer = ZipkinTracer::TraceClient, **) return yield unless Vault::Tracing.enabled? tracer.local_component_span(name) do |span| span.name = name span.record_tag('options', .to_s) unless .empty? yield end end |