Class: Hypertrace::RubyAgent
- Inherits:
-
Object
- Object
- Hypertrace::RubyAgent
- Includes:
- Logging, Singleton
- Defined in:
- lib/hypertrace/ruby_agent.rb
Overview
We can’t name the class ‘Hypertrace::Agent’ because the built proto definitions create a module Hypertrace::Agent :( RubyAgent is repetitve, but want to remain somewhat consistent compared to python/node
Class Method Summary collapse
Instance Method Summary collapse
- #config ⇒ Object
- #initalize_tracer ⇒ Object
-
#initialize(version = Hypertrace::VERSION) ⇒ RubyAgent
constructor
A new instance of RubyAgent.
- #instrument! ⇒ Object
Methods included from Logging
Constructor Details
#initialize(version = Hypertrace::VERSION) ⇒ RubyAgent
Returns a new instance of RubyAgent.
43 44 45 46 47 48 49 50 |
# File 'lib/hypertrace/ruby_agent.rb', line 43 def initialize(version = Hypertrace::VERSION) log.info {"Initializing Hypertrace"} configure_otel_logger! @config = Hypertrace::Config::Config.new @version = version log.info {"Hypertrace version: #{Hypertrace::VERSION}"} log.info {"Ruby version: #{RUBY_VERSION}"} end |
Class Method Details
.config ⇒ Object
39 40 41 |
# File 'lib/hypertrace/ruby_agent.rb', line 39 def self.config self.instance.config end |
.instrument! ⇒ Object
35 36 37 |
# File 'lib/hypertrace/ruby_agent.rb', line 35 def self.instrument! self.instance.instrument! end |
Instance Method Details
#config ⇒ Object
52 53 54 |
# File 'lib/hypertrace/ruby_agent.rb', line 52 def config @config.config end |
#initalize_tracer ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/hypertrace/ruby_agent.rb', line 60 def initalize_tracer resource = OpenTelemetry::SDK::Resources::Resource.create(create_resource_attributes) # TODO: Extra resource Attributes From Config exporter = create_exporter OpenTelemetry::SDK.configure do |c| if ENV['HT_CI_TEST'] != nil span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) c.add_span_processor span_processor else c.add_span_processor OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(exporter) end c.resource = resource c.use 'OpenTelemetry::Instrumentation::ActionPack' c.use 'OpenTelemetry::Instrumentation::ActionView' c.use 'OpenTelemetry::Instrumentation::ActiveRecord' c.use 'OpenTelemetry::Instrumentation::ActiveSupport' c.use 'OpenTelemetry::Instrumentation::Faraday' c.use 'OpenTelemetry::Instrumentation::Mongo' c.use 'OpenTelemetry::Instrumentation::Mysql2' c.use 'OpenTelemetry::Instrumentation::PG' c.use 'OpenTelemetry::Instrumentation::Rack' c.use 'OpenTelemetry::Instrumentation::Sinatra' c.use 'OpenTelemetry::Instrumentation::Net::HTTP' c.use 'OpenTelemetry::Instrumentation::HTTP' c.use 'OpenTelemetry::Instrumentation::RestClient' end apply_custom_patch './instrumentation/rack' apply_custom_patch './instrumentation/net_http_patch' apply_custom_patch './instrumentation/http_patch' apply_custom_patch './instrumentation/faraday_patch' apply_custom_patch './instrumentation/rest_client_patch' apply_custom_patch './instrumentation/rack_env_getter' configure_propagators end |
#instrument! ⇒ Object
56 57 58 |
# File 'lib/hypertrace/ruby_agent.rb', line 56 def instrument! initalize_tracer end |