Top Level Namespace
Defined Under Namespace
Modules: FaradayPatch, Helios, MongoPatch, NetHttpPatch, RackPatch Classes: HeliosProcessor
Constant Summary collapse
- HELIOS_TEST_TRIGGERED_TRACE =
'hs-triggered-test'.freeze
- ATTRIBUTES_TO_DROP =
[ Helios::OpenTelemetry::SemanticAttributes::DB_QUERY_RESULT, Helios::OpenTelemetry::SemanticAttributes::HTTP_RESPONSE_BODY, Helios::OpenTelemetry::SemanticAttributes::HTTP_RESPONSE_HEADERS, Helios::OpenTelemetry::SemanticAttributes::HTTP_REQUEST_BODY, Helios::OpenTelemetry::SemanticAttributes::HTTP_REQUEST_HEADERS ]
- SUPPORTED_INSTRUMENTATIONS =
{ 'OpenTelemetry::Instrumentation::ActiveRecord' => {}, 'OpenTelemetry::Instrumentation::ActionPack' => {}, 'OpenTelemetry::Instrumentation::Rails' => {}, 'OpenTelemetry::Instrumentation::ActionView' => {}, 'OpenTelemetry::Instrumentation::ActiveJob' => { propagation_style: :child }, 'OpenTelemetry::Instrumentation::ActiveModelSerializers' => {}, 'OpenTelemetry::Instrumentation::ActiveSupport' => {}, 'OpenTelemetry::Instrumentation::AwsSdk' => { inject_messaging_context: true, suppress_internal_instrumentation: true }, 'OpenTelemetry::Instrumentation::Bunny' => {}, 'OpenTelemetry::Instrumentation::ConcurrentRuby' => {}, 'OpenTelemetry::Instrumentation::Dalli' => {}, 'OpenTelemetry::Instrumentation::DelayedJob' => {}, 'OpenTelemetry::Instrumentation::Ethon' => {}, 'OpenTelemetry::Instrumentation::Excon' => {}, 'OpenTelemetry::Instrumentation::Faraday' => {}, 'OpenTelemetry::Instrumentation::GraphQL' => {}, 'OpenTelemetry::Instrumentation::HTTP' => {}, 'OpenTelemetry::Instrumentation::HttpClient' => {}, 'OpenTelemetry::Instrumentation::Net::HTTP' => {}, 'OpenTelemetry::Instrumentation::Koala' => {}, 'OpenTelemetry::Instrumentation::LMDB' => {}, 'OpenTelemetry::Instrumentation::Mongo' => { db_statement: :include }, 'OpenTelemetry::Instrumentation::Mysql2' => {}, 'OpenTelemetry::Instrumentation::PG' => {}, 'OpenTelemetry::Instrumentation::Que' => { propagation_style: :child }, 'OpenTelemetry::Instrumentation::Rack' => {}, 'OpenTelemetry::Instrumentation::Rdkafka' => {}, 'OpenTelemetry::Instrumentation::Redis' => { db_statement: :include }, 'OpenTelemetry::Instrumentation::Resque' => { propagation_style: :child }, 'OpenTelemetry::Instrumentation::RestClient' => {}, 'OpenTelemetry::Instrumentation::RSpec' => nil, # Disabled for now 'OpenTelemetry::Instrumentation::Sidekiq' => { propagation_style: :child }, 'OpenTelemetry::Instrumentation::Sinatra' => {}, 'OpenTelemetry::Instrumentation::RubyKafka' => {}, 'OpenTelemetry::Instrumentation::Trilogy' => { db_statement: :include } }
Instance Method Summary collapse
- #additional_patches ⇒ Object
- #apply_instrumentations(otel_config) ⇒ Object
- #auto_tracing_mode? ⇒ Boolean
- #patch_faraday ⇒ Object
- #patch_mongo ⇒ Object
- #patch_net_http ⇒ Object
- #patch_rack ⇒ Object
Instance Method Details
#additional_patches ⇒ Object
101 102 103 104 105 106 |
# File 'lib/helios/opentelemetry/sdk/instrumentations.rb', line 101 def additional_patches patch_net_http patch_faraday patch_rack patch_mongo end |
#apply_instrumentations(otel_config) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/helios/opentelemetry/sdk/instrumentations.rb', line 45 def apply_instrumentations(otel_config) SUPPORTED_INSTRUMENTATIONS.each do |instrumentation, config| next if config.nil? otel_config.use(instrumentation, config) end additional_patches end |
#auto_tracing_mode? ⇒ Boolean
83 84 85 86 |
# File 'lib/helios/opentelemetry/sdk.rb', line 83 def auto_tracing_mode? ruby_opt = ENV['RUBYOPT'] !!ruby_opt and !!ruby_opt.match(%r{-r\s+helios/opentelemetry/sdk}) end |
#patch_faraday ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/helios/opentelemetry/sdk/instrumentations.rb', line 62 def patch_faraday return unless defined?(::Faraday) require 'opentelemetry/instrumentation/faraday/middlewares/tracer_middleware' require_relative 'patches/faraday_patch' ::OpenTelemetry::Instrumentation::Faraday::Middlewares::TracerMiddleware.prepend( FaradayPatch::HeliosFaradayMiddleware ) rescue StandardError => e ::OpenTelemetry.logger.debug("Error patching faraday: #{e}") end |
#patch_mongo ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/helios/opentelemetry/sdk/instrumentations.rb', line 86 def patch_mongo return unless defined?(::Mongo::Monitoring::Global) require 'opentelemetry/instrumentation/mongo/subscriber' min_version = ::OpenTelemetry::Instrumentation::Mongo::Instrumentation::MINIMUM_VERSION mongo_version = Gem::Version.new(::Mongo::VERSION) return unless mongo_version >= min_version require_relative 'patches/mongo_patch' ::OpenTelemetry::Instrumentation::Mongo::Subscriber.prepend(MongoPatch::Subscriber) ::OpenTelemetry::Instrumentation::Mongo::CommandSerializer.prepend(MongoPatch::CommandSerializer) rescue StandardError => e ::OpenTelemetry.logger.debug("Error patching mongo: #{e}") end |
#patch_net_http ⇒ Object
55 56 57 58 59 60 |
# File 'lib/helios/opentelemetry/sdk/instrumentations.rb', line 55 def patch_net_http require_relative 'patches/net_http_patch' ::Net::HTTP.prepend(NetHttpPatch::Instrumentation) rescue StandardError => e ::OpenTelemetry.logger.debug("Error patching net http: #{e}") end |
#patch_rack ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/helios/opentelemetry/sdk/instrumentations.rb', line 74 def patch_rack return unless defined?(::Rack) require 'opentelemetry/instrumentation/rack/middlewares/tracer_middleware' require_relative 'patches/rack_patch' ::OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware.prepend( RackPatch::HeliosRackMiddleware ) rescue StandardError => e ::OpenTelemetry.logger.debug("Error patching rack: #{e}") end |