Skip to content

Commit 37d6926

Browse files
committed
Use Pin#service_name as the official attribute name
1 parent e2f2a54 commit 37d6926

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/ddtrace/pin.rb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ def self.get_from(obj)
1010
obj.datadog_pin
1111
end
1212

13-
attr_accessor :service
13+
attr_accessor :service_name
1414
attr_accessor :app
1515
attr_accessor :tags
1616
attr_accessor :app_type
1717
attr_accessor :name
1818
attr_accessor :tracer
1919
attr_accessor :config
2020

21-
def initialize(service, options = {})
21+
def initialize(service_name, options = {})
2222
@app = options[:app]
2323
@tags = options[:tags]
2424
@app_type = options[:app_type]
2525
@name = nil # this would rarely be overriden as it's really span-specific
2626
@tracer = options[:tracer] || Datadog.tracer
2727
@config = options[:config]
28-
self.service = service
28+
self.service_name = service_name
2929
end
3030

3131
def enabled?
@@ -54,18 +54,17 @@ def datadog_pin
5454
obj.datadog_pin = self
5555
end
5656

57-
def service=(name)
58-
if name && app && app_type
59-
tracer.set_service_info(name, app, app_type)
60-
end
57+
def service_name=(name)
58+
tracer.set_service_info(name, app, app_type) if name && app && app_type
6159

62-
@service = name
60+
@service_name = name
6361
end
6462

65-
alias service_name= service=
63+
alias service= service_name=
64+
alias service service_name
6665

6766
def to_s
68-
"Pin(service:#{@service},app:#{@app},app_type:#{@app_type},name:#{@name})"
67+
"Pin(service:#{service},app:#{app},app_type:#{app_type},name:#{name})"
6968
end
7069
end
7170
end

test/pin_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def test_service_info_update
8181

8282
def test_service_info_update_with_missing_params
8383
tracer = get_test_tracer
84+
8485
# instantiating `Pin` without an `app` param (which is necessary for service info)
8586
Datadog::Pin.new('test-service', app_type: 'test-type', tracer: tracer)
8687

0 commit comments

Comments
 (0)