Module: SignalFx::Tracing::Instrumenter
- Defined in:
- lib/signalfx/tracing.rb,
lib/signalfx/tracing/register.rb,
lib/signalfx/tracing/instrumentation/pg.rb,
lib/signalfx/tracing/instrumentation/rack.rb,
lib/signalfx/tracing/instrumentation/grape.rb,
lib/signalfx/tracing/instrumentation/rails.rb,
lib/signalfx/tracing/instrumentation/redis.rb,
lib/signalfx/tracing/instrumentation/mysql2.rb,
lib/signalfx/tracing/instrumentation/sequel.rb,
lib/signalfx/tracing/instrumentation/faraday.rb,
lib/signalfx/tracing/instrumentation/mongodb.rb,
lib/signalfx/tracing/instrumentation/sidekiq.rb,
lib/signalfx/tracing/instrumentation/sinatra.rb,
lib/signalfx/tracing/instrumentation/net_http.rb,
lib/signalfx/tracing/instrumentation/restclient.rb,
lib/signalfx/tracing/instrumentation/active_record.rb,
lib/signalfx/tracing/instrumentation/elasticsearch.rb,
lib/signalfx/tracing/instrumentation/patching-test.rb
Defined Under Namespace
Modules: ActiveRecord, Elasticsearch, Faraday, Grape, MongoDB, Mysql2, NetHttp, PG, PatchingTest, Rack, Rails, Redis, RestClient, Sequel, Sidekiq, Sinatra Classes: Register
Class Attribute Summary collapse
-
.access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
.ingest_url ⇒ Object
readonly
Returns the value of attribute ingest_url.
-
.reporter ⇒ Object
Returns the value of attribute reporter.
-
.service_name ⇒ Object
readonly
Returns the value of attribute service_name.
-
.tracer ⇒ Object
Returns the value of attribute tracer.
Class Method Summary collapse
- .configure(tracer: nil, ingest_url: ENV['SIGNALFX_ENDPOINT_URL'] || ENV['SIGNALFX_INGEST_URL'] || 'http://localhost:9080/v1/trace', service_name: ENV['SIGNALFX_SERVICE_NAME'] || "signalfx-ruby-tracing", access_token: ENV['SIGNALFX_ACCESS_TOKEN'], auto_instrument: false) ⇒ Object
- .instrument(to_patch, **args) ⇒ Object
- .revive ⇒ Object
- .set_tracer(tracer: nil, service_name: nil, access_token: nil) ⇒ Object
Class Attribute Details
.access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
13 14 15 |
# File 'lib/signalfx/tracing.rb', line 13 def access_token @access_token end |
.ingest_url ⇒ Object (readonly)
Returns the value of attribute ingest_url.
13 14 15 |
# File 'lib/signalfx/tracing.rb', line 13 def ingest_url @ingest_url end |
.reporter ⇒ Object
Returns the value of attribute reporter.
14 15 16 |
# File 'lib/signalfx/tracing.rb', line 14 def reporter @reporter end |
.service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
13 14 15 |
# File 'lib/signalfx/tracing.rb', line 13 def service_name @service_name end |
.tracer ⇒ Object
Returns the value of attribute tracer.
14 15 16 |
# File 'lib/signalfx/tracing.rb', line 14 def tracer @tracer end |
Class Method Details
.configure(tracer: nil, ingest_url: ENV['SIGNALFX_ENDPOINT_URL'] || ENV['SIGNALFX_INGEST_URL'] || 'http://localhost:9080/v1/trace', service_name: ENV['SIGNALFX_SERVICE_NAME'] || "signalfx-ruby-tracing", access_token: ENV['SIGNALFX_ACCESS_TOKEN'], auto_instrument: false) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/signalfx/tracing.rb', line 16 def configure(tracer: nil, ingest_url: ENV['SIGNALFX_ENDPOINT_URL'] || ENV['SIGNALFX_INGEST_URL'] || 'http://localhost:9080/v1/trace', service_name: ENV['SIGNALFX_SERVICE_NAME'] || "signalfx-ruby-tracing", access_token: ENV['SIGNALFX_ACCESS_TOKEN'], auto_instrument: false) @ingest_url = ingest_url @service_name = service_name @access_token = access_token set_tracer(tracer: tracer, service_name: service_name, access_token: access_token) if @tracer.nil? if auto_instrument Register.available_libs.each_pair do |key, value| value.instrument end else yield self end Compat.apply end |
.instrument(to_patch, **args) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/signalfx/tracing.rb', line 37 def instrument(to_patch, **args) if Register.available_libs[to_patch].nil? puts "instrumentation not found" else Register.available_libs[to_patch].instrument(**args) end end |
.revive ⇒ Object
78 79 80 |
# File 'lib/signalfx/tracing.rb', line 78 def revive set_tracer(service_name: @service_name, access_token: @access_token) end |
.set_tracer(tracer: nil, service_name: nil, access_token: nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/signalfx/tracing.rb', line 45 def set_tracer(tracer: nil, service_name: nil, access_token: nil) # build a new tracer if one wasn't provided if tracer.nil? headers = {} # don't set the header if no token was provided headers["X-SF-Token"] = access_token if access_token && !access_token.empty? encoder = Jaeger::Client::Encoders::ThriftEncoder.new(service_name: service_name) @http_sender = SignalFx::Tracing::HttpSenderWithFlag.new(url: @ingest_url, headers: headers, encoder: encoder) @reporter = Jaeger::Client::Reporters::RemoteReporter.new(sender: @http_sender, flush_interval: 1) injectors = { OpenTracing::FORMAT_RACK => [Jaeger::Client::Injectors::B3RackCodec], OpenTracing::FORMAT_TEXT_MAP => [Jaeger::Client::Injectors::B3RackCodec] } extractors = { OpenTracing::FORMAT_RACK => [Jaeger::Client::Extractors::B3RackCodec], OpenTracing::FORMAT_TEXT_MAP => [Jaeger::Client::Extractors::B3TextMapCodec] } @tracer = Jaeger::Client.build( service_name: service_name, reporter: @reporter, injectors: injectors, extractors: extractors ) OpenTracing.global_tracer = @tracer else @tracer = tracer end end |