Sha256: 5220773157ec0c07b058c58c3dc0f3b14be23877ae6dadaf7175ec849012e61d

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

module Vault
  module Tracing
    ZIPKIN_API_HOST_STAGING = 'https://zipkin-staging.heroku.tools'.freeze

    # Injects the zipkin middleware into the Web class.
    #
    # @example
    #   Vault::Tracing.configure
    #
    # @return nil
    def self.configure
      return unless Vault::Tracing.enabled?

      Vault::Web.instance_eval { require 'zipkin-tracer' }
      Vault::Web.use ZipkinTracer::RackHandler, config
    end

    # Configuration options for the Zipkin RackHandler.
    #
    # @return [Hash] config options for Zipkin tracer
    def self.config
      {
        service_name: Config.app_name,
        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

    # A helper to guard against injecting Zipkin when not desired.
    #
    # @return [true] if so
    def self.enabled?
      Config.app_name &&
        Config[:zipkin_enabled] == 'true' &&
        Config[:zipkin_api_host]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vault-tools-0.6.2 lib/vault-tools/tracing.rb
vault-tools-0.6.1 lib/vault-tools/tracing.rb
vault-tools-0.6.0 lib/vault-tools/tracing.rb