Class: Datadog::Pin
- Inherits:
-
Object
- Object
- Datadog::Pin
- Defined in:
- lib/ddtrace/pin.rb
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.
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 ⇒ Object
Returns the value of attribute service.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#tracer ⇒ Object
Returns the value of attribute tracer.
Class Method Summary collapse
Instance Method Summary collapse
- #enabled? ⇒ Boolean
-
#initialize(service, options = { app: nil, tags: nil, app_type: nil, tracer: nil, config: nil }) ⇒ Pin
constructor
- ruby19
-
named parameters would be more idiomatic here, but would break backward compatibility.
- #onto(obj) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(service, options = { app: nil, tags: nil, app_type: nil, tracer: nil, config: nil }) ⇒ Pin
- ruby19
-
named parameters would be more idiomatic here, but would break backward compatibility
22 23 24 25 26 27 28 29 30 |
# File 'lib/ddtrace/pin.rb', line 22 def initialize(service, = { app: nil, tags: nil, app_type: nil, tracer: nil, config: nil }) @service = service @app = .fetch(:app, nil) @tags = .fetch(:tags, nil) @app_type = .fetch(:app_type, nil) @name = nil # this would rarely be overriden as it's really span-specific @tracer = [:tracer] || Datadog.tracer @config = .fetch(:config, nil) end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
14 15 16 |
# File 'lib/ddtrace/pin.rb', line 14 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.
19 20 21 |
# File 'lib/ddtrace/pin.rb', line 19 def config @config end |
#name ⇒ Object
Returns the value of attribute name.
17 18 19 |
# File 'lib/ddtrace/pin.rb', line 17 def name @name end |
#service ⇒ Object
Returns the value of attribute service.
13 14 15 |
# File 'lib/ddtrace/pin.rb', line 13 def service @service end |
#tags ⇒ Object
Returns the value of attribute tags.
15 16 17 |
# File 'lib/ddtrace/pin.rb', line 15 def @tags end |
#tracer ⇒ Object
Returns the value of attribute tracer.
18 19 20 |
# File 'lib/ddtrace/pin.rb', line 18 def tracer @tracer end |
Class Method Details
.get_from(obj) ⇒ Object
8 9 10 11 |
# File 'lib/ddtrace/pin.rb', line 8 def self.get_from(obj) return nil unless obj.respond_to? :datadog_pin obj.datadog_pin end |
Instance Method Details
#enabled? ⇒ Boolean
32 33 34 35 |
# File 'lib/ddtrace/pin.rb', line 32 def enabled? return @tracer.enabled if @tracer false end |
#onto(obj) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ddtrace/pin.rb', line 37 def onto(obj) unless obj.respond_to? :datadog_pin= obj.instance_exec do def datadog_pin=(pin) Datadog::Tracer.log.debug("Set pin #{pin.service} on #{self.class}.") @datadog_pin = pin end end end unless obj.respond_to? :datadog_pin obj.instance_exec do def datadog_pin Datadog::Tracer.log.debug("Get pin from #{self.class}.") @datadog_pin end end end obj.datadog_pin = self end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/ddtrace/pin.rb', line 59 def to_s "Pin(service:#{@service},app:#{@app},app_type:#{@app_type},name:#{@name})" end |