Skip to content
This repository was archived by the owner on Jul 11, 2022. It is now read-only.

Commit c10a08d

Browse files
authored
Add IP tag to tracer tags (#160)
1 parent 8f6a8cf commit c10a08d

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

jaeger_client/constants.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
JAEGER_VERSION_TAG_KEY = 'jaeger.version'
4646

4747
# Tracer-scoped tag that contains the hostname
48-
JAEGER_HOSTNAME_TAG_KEY = 'jaeger.hostname'
48+
JAEGER_HOSTNAME_TAG_KEY = 'hostname'
49+
50+
# Tracer-scoped tag that is used to report ip of the process.
51+
JAEGER_IP_TAG_KEY = 'ip'
4952

5053
# the type of sampler that always makes the same decision.
5154
SAMPLER_TYPE_CONST = 'const'

jaeger_client/tracer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def __init__(
8080
self.codecs.update(extra_codecs)
8181
self.tags = {
8282
constants.JAEGER_VERSION_TAG_KEY: constants.JAEGER_CLIENT_VERSION,
83+
constants.JAEGER_IP_TAG_KEY: self.ip_address,
8384
}
8485
if tags:
8586
self.tags.update(tags)

tests/test_tracer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,15 @@ def test_serialization_error(tracer):
169169
)
170170

171171

172-
def test_tracer_tags_hostname():
172+
def test_tracer_tags():
173173
reporter = mock.MagicMock()
174174
sampler = ConstSampler(True)
175175

176176
with mock.patch('socket.gethostname', return_value='dream-host.com'):
177177
t = Tracer(service_name='x', reporter=reporter, sampler=sampler)
178-
assert t.tags.get(c.JAEGER_HOSTNAME_TAG_KEY) == 'dream-host.com'
178+
assert t.tags.get('hostname') == 'dream-host.com'
179+
assert 'ip' in t.tags
180+
assert 'jaeger.version' in t.tags
179181

180182

181183
def test_tracer_tags_passed_to_reporter():

0 commit comments

Comments
 (0)