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

Commit

Permalink
Add IP tag to tracer tags (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
black-adder authored Apr 19, 2018
1 parent 8f6a8cf commit c10a08d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion jaeger_client/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@
JAEGER_VERSION_TAG_KEY = 'jaeger.version'

# Tracer-scoped tag that contains the hostname
JAEGER_HOSTNAME_TAG_KEY = 'jaeger.hostname'
JAEGER_HOSTNAME_TAG_KEY = 'hostname'

# Tracer-scoped tag that is used to report ip of the process.
JAEGER_IP_TAG_KEY = 'ip'

# the type of sampler that always makes the same decision.
SAMPLER_TYPE_CONST = 'const'
Expand Down
1 change: 1 addition & 0 deletions jaeger_client/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def __init__(
self.codecs.update(extra_codecs)
self.tags = {
constants.JAEGER_VERSION_TAG_KEY: constants.JAEGER_CLIENT_VERSION,
constants.JAEGER_IP_TAG_KEY: self.ip_address,
}
if tags:
self.tags.update(tags)
Expand Down
6 changes: 4 additions & 2 deletions tests/test_tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,15 @@ def test_serialization_error(tracer):
)


def test_tracer_tags_hostname():
def test_tracer_tags():
reporter = mock.MagicMock()
sampler = ConstSampler(True)

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


def test_tracer_tags_passed_to_reporter():
Expand Down

0 comments on commit c10a08d

Please sign in to comment.