Class: Datadog::Pin
Overview
A Pin (a.k.a Patch INfo) is a small class which is used to set tracing metadata on a particular traced object. This is useful if you wanted to, say, trace two different database clusters.
Direct Known Subclasses
Contrib::Dalli::Patcher::DeprecatedPin, Contrib::Faraday::Patcher::DeprecatedPin, Contrib::GRPC::Patcher::DeprecatedPin, Contrib::Grape::Patcher::DeprecatedPin
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#app_type ⇒ Object
Returns the value of attribute app_type.
-
#config ⇒ Object
Returns the value of attribute config.
-
#name ⇒ Object
Returns the value of attribute name.
-
#service_name ⇒ Object
(also: #service)
Returns the value of attribute service_name.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#tracer ⇒ Object
readonly
Returns the value of attribute tracer.
-
#writer ⇒ Object
Returns the value of attribute writer.
Class Method Summary collapse
Instance Method Summary collapse
- #enabled? ⇒ Boolean
-
#initialize(service_name, options = {}) ⇒ Pin
constructor
A new instance of Pin.
-
#onto(obj) ⇒ Object
rubocop:disable Style/TrivialAccessors.
- #to_s ⇒ Object
Methods included from Patcher
Methods included from Datadog::Patcher::CommonMethods
#do_once, #done?, #without_warnings
Constructor Details
#initialize(service_name, options = {}) ⇒ Pin
Returns a new instance of Pin.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ddtrace/pin.rb', line 27 def initialize(service_name, = {}) deprecation_warning unless [:tracer].is_a?(Proc) || [:tracer].nil? @app = [:app] @app_type = [:app_type] @config = [:config] @name = nil # this would rarely be overriden as it's really span-specific @service_name = service_name @tags = [:tags] @tracer = [:tracer] end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
15 16 17 |
# File 'lib/ddtrace/pin.rb', line 15 def app @app end |
#app_type ⇒ Object
Returns the value of attribute app_type.
16 17 18 |
# File 'lib/ddtrace/pin.rb', line 16 def app_type @app_type end |
#config ⇒ Object
Returns the value of attribute config.
17 18 19 |
# File 'lib/ddtrace/pin.rb', line 17 def config @config end |
#name ⇒ Object
Returns the value of attribute name.
18 19 20 |
# File 'lib/ddtrace/pin.rb', line 18 def name @name end |
#service_name ⇒ Object Also known as: service
Returns the value of attribute service_name.
19 20 21 |
# File 'lib/ddtrace/pin.rb', line 19 def service_name @service_name end |
#tags ⇒ Object
Returns the value of attribute tags.
20 21 22 |
# File 'lib/ddtrace/pin.rb', line 20 def @tags end |
#tracer ⇒ Object (readonly)
Returns the value of attribute tracer.
21 22 23 |
# File 'lib/ddtrace/pin.rb', line 21 def tracer @tracer end |
#writer ⇒ Object
Returns the value of attribute writer.
22 23 24 |
# File 'lib/ddtrace/pin.rb', line 22 def writer @writer end |
Class Method Details
.get_from(obj) ⇒ Object
10 11 12 13 |
# File 'lib/ddtrace/pin.rb', line 10 def self.get_from(obj) return nil unless obj.respond_to? :datadog_pin obj.datadog_pin end |
Instance Method Details
#enabled? ⇒ Boolean
43 44 45 46 |
# File 'lib/ddtrace/pin.rb', line 43 def enabled? return tracer.enabled if tracer false end |
#onto(obj) ⇒ Object
rubocop:disable Style/TrivialAccessors
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ddtrace/pin.rb', line 49 def onto(obj) unless obj.respond_to? :datadog_pin= obj.instance_exec do def datadog_pin=(pin) @datadog_pin = pin end end end unless obj.respond_to? :datadog_pin obj.instance_exec do def datadog_pin @datadog_pin end end end obj.datadog_pin = self end |
#to_s ⇒ Object
69 70 71 |
# File 'lib/ddtrace/pin.rb', line 69 def to_s "Pin(service:#{service},app:#{app},app_type:#{app_type},name:#{name})" end |