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

Ability to specify custom jaeger.hostname useful for running in kubernetes or containers #166

Closed
SEJeff opened this issue Apr 27, 2018 · 1 comment

Comments

@SEJeff
Copy link
Contributor

SEJeff commented Apr 27, 2018

This code:

hostname = socket.gethostname()
self.tags[constants.JAEGER_HOSTNAME_TAG_KEY] = hostname

Is not ideal when running jaeger_client in containerized applications. It seems most useful to allow setting a custom hostname in the config or via an environment variable. We're currently using an init_tracer() like this for flask applications:

def initialize_tracer():
    config = Config(
        config={
            'sampler': {
                'type': 'const',
                'param': 1,
            },
            'local_agent': {
                'reporting_host': os.environ.get('NODE_NAME', '127.0.0.1'),
            },
            'logging': True,
        },
        service_name=os.environ.get('APP_DEPLOYMENT_NAME', __name__),
    )
    return config.initialize_tracer()

The NODE_NAME env var is set via the kubernetes downward api to the actual kubelet running the pod (since it runs a jaeger-agent pod on every node).

Changing the code for this seems pretty trivial, but what do you suggest we name the config and env variable for this?

@yurishkuro
Copy link
Member

I'd suggest we do the same thing as here jaegertracing/jaeger-client-java#371

SEJeff added a commit to SEJeff/jaeger-client-python that referenced this issue Apr 29, 2018
This matches the functionality of jaeger-client-java after
jaegertracing/jaeger-client-java#371 was merged.

Refs: jaegertracing#166
SEJeff added a commit to SEJeff/jaeger-client-python that referenced this issue Apr 29, 2018
This matches the functionality of jaeger-client-java after
jaegertracing/jaeger-client-java#371 was merged.

Refs: jaegertracing#166

Signed-off-by: Jeff Schroeder <jeffschroeder@computer.org>
yurishkuro pushed a commit that referenced this issue Apr 29, 2018
* Allow specifying the hostname via a tag

This is useful for applications running inside containers where the
hostname is autogenerated and generally useless. In kubernetes, the
downward api can be used to pass in the node name actually running
the container.

Fixes #66

Signed-off-by: Jeff Schroeder <jeffschroeder@computer.org>

* Catch the `socket.error` exception when trying to get the hostname

This is the base exception for all errors in the socket library. Explicit
is better than implicit!

Signed-off-by: Jeff Schroeder <jeffschroeder@computer.org>

* Don't attempt to lookup the ip address if specified via a tag

This matches the functionality of jaeger-client-java after
jaegertracing/jaeger-client-java#371 was merged.

Refs: #166

Signed-off-by: Jeff Schroeder <jeffschroeder@computer.org>

* Remove ipv4_to_int since jaeger converts tags to strings

Signed-off-by: Jeff Schroeder <jeffschroeder@computer.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants