Jomol Michael
Jomol Michael

Reputation: 29

How to connect Opentracing application to a remote Jaeger collector

I am using Jaeger UI to display traces from my application. It's work fine for me if both application an Jaeger are running on same server. But I need to run my Jaeger collector on a different server. I tried out with JAEGER_ENDPOINT, JAEGER_AGENT_HOST and JAEGER_AGENT_PORT, but it failed.

I don't know, whether my values setting for these variables is wrong or not. Whether it required any configuration settings inside application code?

Can you provide me any documentation for this problem?

Upvotes: 1

Views: 1835

Answers (2)

mdamircoder
mdamircoder

Reputation: 41

Specify "JAEGER_AGENT_HOST" and ensure "local_agent" is not specified in tracer config file.

Below is the working solution for Python
import os 

os.environ['JAEGER_AGENT_HOST'] = "123.XXX.YYY.ZZZ"  # Specify remote Jaeger-Agent here 
# os.environ['JAEGER_AGENT_HOST'] = "16686" # optional, default: "16686"


from jaeger_client import Config

config = Config(
    config={
        'sampler': {
            'type': 'const',
            'param': 1,
        },
        # ENSURE 'local_agent' is not specified 
        # 'local_agent': {
        #     # 'reporting_host': "127.0.0.1",
        #     # 'reporting_port': 16686,
        # },
        'logging': True,
    },
    service_name="your-service-name-here",
)
# create tracer object here and voila!

Guidance of Jaeger: https://www.jaegertracing.io/docs/1.33/getting-started/

Jaeger-Client features: https://www.jaegertracing.io/docs/1.33/client-features/

Flask-OpenTracing: https://github.com/opentracing-contrib/python-flask

OpenTelemetry-Python: https://opentelemetry.io/docs/instrumentation/python/getting-started/

Upvotes: 0

Ashen Jayasinghe
Ashen Jayasinghe

Reputation: 522

In server 2 , Install jaeger

$ docker run -d --name jaeger \
  -p 5775:5775/udp \
  -p 6831:6831/udp \
  -p 6832:6832/udp \
  -p 5778:5778 \
  -p 16686:16686 \
  -p 14268:14268 \
  -p 9411:9411 \
  jaegertracing/all-in-one:latest

In server 1, set these environment variables.

JAEGER_SAMPLER_TYPE=probabilistic 
JAEGER_SAMPLER_PARAM=1 
JAEGER_SAMPLER_MANAGER_HOST_PORT=(EnterServer2HostName):5778 
JAEGER_REPORTER_LOG_SPANS=false 
JAEGER_AGENT_HOST=(EnterServer2HostName)
JAEGER_AGENT_PORT=6831 
JAEGER_REPORTER_FLUSH_INTERVAL=1000 
JAEGER_REPORTER_MAX_QUEUE_SIZE=100 
application-server-id=server-x

Change the tracer registration application code as below in server 1, so that it will get the configurations from the environment variables.

@Produces
@Singleton
public static io.opentracing.Tracer jaegerTracer() {
String serverInstanceId = System.getProperty("application-server-id");
if(serverInstanceId == null) {
serverInstanceId = System.getenv("application-server-id");
}
return new Configuration("ApplicationName" + (serverInstanceId!=null && !serverInstanceId.isEmpty() ? "-"+serverInstanceId : ""), 
                Configuration.SamplerConfiguration.fromEnv(),
                Configuration.ReporterConfiguration.fromEnv())
                .getTracer();
}

Hope this works!

Check this link for integrating elasticsearch as the persistence storage backend so that the traces will not remove once the Jaeger instance is stopped. How to configure Jaeger with elasticsearch?

Upvotes: 3

Related Questions