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

How to set Jaeger endpoint #47

Closed
nlamirault opened this issue May 19, 2017 · 9 comments
Closed

How to set Jaeger endpoint #47

nlamirault opened this issue May 19, 2017 · 9 comments

Comments

@nlamirault
Copy link

Hi, i try to use the python version of the jaeger client.
In go i do that to create the tracer :

cfg := jaegercfg.Configuration{
		Sampler: &jaegercfg.SamplerConfig{
			Type:  jaeger.SamplerTypeConst,
			Param: 1,
		},
		Reporter: &jaegercfg.ReporterConfig{
		LogSpans:           true,
		LocalAgentHostPort: "192.168.1.10:5775",
	},
}

jLogger := jaegerlog.StdLogger
jMetricsFactory := metrics.NullFactory
tracer, _, err := cfg.New(
		"myservice",
		jaegercfg.Logger(jLogger),
		jaegercfg.Metrics(jMetricsFactory),
)

How do that in Python ?
Thanks

@yurishkuro
Copy link
Member

The address of the agent is configured automatically (in Go as well), you do not need to provide it in the configuration. If you still really want to, you can override the port via:

config = {
    'local_agent': {
        'reporting_port': number,
        'sampling_port': number,
    },
}

@nlamirault
Copy link
Author

OK.
But i would like to use the jaeger all-in-one image. :

docker run -d -p5775:5775/udp -p16686:16686 jaegertracing/all-in-one:latest

It's not on the same host.

@yurishkuro
Copy link
Member

I think Python client doesn't support talking to an agent on another host (it's also not recommended because clients use UDP to send the packets, which won't be lossless, unlike when talking over the loopback interface).

A quick fix would be to extend Python client to support reporting_host_port config param as an alternative to just the port.

Longer term, we are having ongoing discussions about supporting reporting over HTTP.

@longXboy
Copy link

longXboy commented May 24, 2017

When an application running in docker container, i can't communicate with the jaeger agent by using localhost. So providing an reporting_host will be a good choice?

@yurishkuro yurishkuro changed the title How set Jaeger endpoint How to set Jaeger endpoint May 25, 2017
@MrSaints
Copy link
Contributor

MrSaints commented Jul 10, 2017

I believe this, and #49 are addressed in #51

@nlamirault
Copy link
Author

I launch the all-in-one image :

$ docker run -d -p5775:5775/udp -p6831:6831/udp -p6832:6832/udp -p5778:5778 -p16686:16686 -p14268:14268 jaegertracing/all-in-one:latest

Try this code :

import opentracing
import logging
import time
from jaeger_client import Config

if __name__ == "__main__":
    log_level = logging.DEBUG
    logging.getLogger('').handlers = []
    logging.basicConfig(format='%(asctime)s %(message)s', level=log_level)

    config = Config(
        config={ # usually read from some yaml config
            'sampler': {
                'type': 'const',
                'param': 1,
            },
            'local_agent': {
                'reporting_host': "127.0.0.1",
                'reporting_port': 5775,
            },
            'logging': True,
        },
        service_name='my-app',
    )
    tracer = config.initialize_tracer()

    with opentracing.tracer.start_span('TestSpan') as span:
        span.log_event('test message', payload={'life': 42})

        with opentracing.tracer.start_span('ChildSpan', child_of=span) as child_span:
            span.log_event('down below')

    time.sleep(2)   # yield to IOLoop to flush the spans - https://github.com/uber/jaeger-client-python/issues/50
    tracer.close()  # flush any buffered spans

And the output logs :

$ python foo.py
2017-09-11 16:34:08,509 Initializing Jaeger Tracer with UDP reporter
2017-09-11 16:34:08,512 Using sampler ConstSampler(True)
2017-09-11 16:34:08,513 opentracing.tracer initialized to <jaeger_client.tracer.Tracer object at 0x7fe7e3d68c50>[app_name=my-app]
2017-09-11 16:34:08,514 Reporting span d8f5c5f29cb6c02d:de0863b7a8ed4610:d8f5c5f29cb6c02d:1 my-app.ChildSpan
2017-09-11 16:34:08,514 Reporting span d8f5c5f29cb6c02d:d8f5c5f29cb6c02d:0:1 my-app.TestSpan
Exception in thread Thread-1 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
  File "/usr/lib/python2.7/threading.py", line 754, in run
  File "/home/vagrant/Projets/sirocco/venv/local/lib/python2.7/site-packages/threadloop/threadloop.py", line 78, in _start_io_loop
  File "/home/vagrant/Projets/sirocco/venv/local/lib/python2.7/site-packages/tornado/ioloop.py", line 904, in start
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute '_current'

@ror6ax
Copy link
Contributor

ror6ax commented Mar 12, 2018

reporting_host and reporting_port seem to work fine now. I think this issue can be closed? @yurishkuro

@yurishkuro
Copy link
Member

Yes, closing.

@nlamirault the exception you showed is something inside tornado, could you please open a new issue with it and include the versions of the dependencies you're using? I have run https://github.com/yurishkuro/opentracing-tutorial/tree/master/python with the latest jaeger client and it had no issues (using Python 2.7)

carlosonunez added a commit to carlosonunez/jaeger-client-python that referenced this issue Mar 27, 2019
carlosonunez added a commit to carlosonunez/jaeger-client-python that referenced this issue Mar 27, 2019
This is in response to [this issue](jaegertracing#47).

Signed-off-by: Carlos Nunez <carlosonunez@noreply.github.com>
yurishkuro pushed a commit that referenced this issue Apr 24, 2019
This is in response to [this issue](#47).

Signed-off-by: Carlos Nunez <carlosonunez@noreply.github.com>
@pzheng64
Copy link

pzheng64 commented May 17, 2019

@yurishkuro What is the meaning of local_agent config? If I'm running jager-all-in-one using jaeger-operator on k8s, what should be the config array here?

def tracer():
    install_all_patches()
    config = Config(
        config={
            'sampler': {
                'type': 'const',
                'param': 1,
            },
            'local_agent': {
                'reporting_host': 'jaeger',
                'reporting_port': '6831',
            },
            'logging': True,
        },  
        service_name='devhubserver',
        validate=True,
        metrics_factory=PrometheusMetricsFactory(namespace='devhubserver')
    )
    return config.initialize_tracer()

// default is False
OPENTRACING_TRACE_ALL = True

// default is []
OPENTRACING_TRACED_ATTRIBUTES = ['path', 'method', 'META', 'body', 'path_info', 'content_type', 'content_params', 'GET', 'POST', 'COOKIES', 'FILES', 'headers']```

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

6 participants