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

Make the whole URL for remoteSampler / Service name configurable #565

Closed
lff0305 opened this issue Oct 24, 2018 · 11 comments
Closed

Make the whole URL for remoteSampler / Service name configurable #565

lff0305 opened this issue Oct 24, 2018 · 11 comments

Comments

@lff0305
Copy link

lff0305 commented Oct 24, 2018

Currently the service name is hard coded, as in HttpSamplingManager.java

jsonString = makeGetRequest( "http://" + hostPort + "/?service=" + URLEncoder.encode(serviceName, "UTF-8"));

In my project, I found that it would be greate helpful if the whole endpoint can be configured, instead of just hostPort.

For example,

I can config it as a RESTFUL service:
remoteURL=http://xxx.com/${serviceName}
or ,
as a query parameter
remoteURL=http://xxx.com/?q=${serviceName}
or, as HTTPS:
remoteURL=https://xxx.com/${serviceName}

Thanks.

@lff0305 lff0305 changed the title Make the whole URL for remoteSampler / Service name configurable Make the whole URL for remoteSampler / Service name configurable #newFeature Oct 24, 2018
@lff0305 lff0305 changed the title Make the whole URL for remoteSampler / Service name configurable #newFeature Make the whole URL for remoteSampler / Service name configurable Oct 24, 2018
@yurishkuro
Copy link
Member

At this time only agent exposes this configuration API, and the agent is supposed to run as a sidecar or host agent on the same host as the application.

I think there were PRs somewhere to introduce JAEGER_CONFIG_ENDPOINT config, iirc.

@lff0305
Copy link
Author

lff0305 commented Oct 26, 2018

Thanks, I checked the PR but the URL is still hard coded
serverUrl + "?service=" + URLEncoder.encode(serviceName, "UTF-8"));
Another thing missed is that this PR only deals with get config from ENV, the load for springboot / springcloud is not updated.

@pavolloffay
Copy link
Member

load for springboot / springcloud is not updated.

That is handled by a different project - https://github.com/opentracing-contrib/java-spring-jaeger

@pavolloffay
Copy link
Member

Why do you need to have the service name configured separately? Do you want to use sampling strategies for different service name than one used to report spans?

@lff0305
Copy link
Author

lff0305 commented Oct 30, 2018

Why do you need to have the service name configured separately? Do you want to use sampling strategies for different service name than one used to report spans?

That's correct. I am doing a project with springcloud (serveral microservices), and I'd like to control the tracing behavior of the microservices (config-service, api-gateway, etc) separately.

Currently the service name is passed as a parameter ( ?service=....), it is fine but I have to build another web service to provide the tracing config json.

If it can be configurable ( remoteURL=http://xxx.com/${serviceName} ) Then I can re-use the spring cloud config server, which is better to me.

@yurishkuro
Copy link
Member

Sorry, I don't follow the use case.

I have to build another web service to provide the tracing config json.

jaeger agent + collector already provide the ability to control sampling per-service via configuration. Why do you need another service?

If it can be configurable ( remoteURL=http://xxx.com/${serviceName} )

A given tracer represents a single service, so when it calls for sampling configuration it asks for sampling for that service (and you pass the name of the service to the tracer when creating it). With your suggestion you can force the tracer to ask for sampling strategy under a different service name - I don't understand that use case.

@lff0305
Copy link
Author

lff0305 commented Oct 31, 2018

Hi Thanks for you message.

Sorry, I don't follow the use case.

I have to build another web service to provide the tracing config json.

jaeger agent + collector already provide the ability to control sampling per-service via configuration. Why do you need another service?

This is mostly for enable / disable tracing for a specific micro service at runtime without restarting. And due to some firewall limit, the HTTP pulling of sampling configuration is blocked. That's why I have to build a web service internally to provide the configs.

If it can be configurable ( remoteURL=http://xxx.com/${serviceName} )

A given tracer represents a single service, so when it calls for sampling configuration it asks for sampling for that service (and you pass the name of the service to the tracer when creating it). With your suggestion you can force the tracer to ask for sampling strategy under a different service name - I don't understand that use case.

Sorry, I did not want to ask for a different service name. All I need is to set the serviceName as part of the URL (Restful style), not as a parameter.

The following is my code for test:
The url is hard coded, not as a config parameter.
The code will replace the url with serviceName, for example,

https://192.168.1.200/config/service1
https://192.168.1.200/config/service2

etc.

Of course, if the old style (as a parameter) is needed, it can be configured as
String urlConfig = "https://192.168.1.200?q=${service}";

public SamplingStrategyResponse getSamplingStrategy(String serviceName)
     throws SamplingStrategyErrorException {
    String jsonString;
    String urlConfig = "https://192.168.1.200/config/${service}";
    urlConfig = urlConfig.replaceAll("\\$\\{serviceName\\}", serviceName);
      try {
        jsonString =
                makeGetRequest(urlConfig);
      } catch (IOException e) {
        throw new SamplingStrategyErrorException(
                "http call to get sampling strategy from local agent failed.", e);
      }
    } 
    return parseJson(jsonString);
  }
}

@jpkrohling
Copy link
Collaborator

That's why I have to build a web service internally to provide the configs.

I think this is the crucial aspect and it would make easier the life of people replacing specific parts of Jaeger with their implementations.

@yurishkuro
Copy link
Member

Fair enough, I can see the value there. But I still think we must keep the existing simpler way of pointing to the agent with just the host:port, since it is the default recommended architecture, and I don't want every user to have to know about the exact URL with variable substitution syntax.

@yurishkuro
Copy link
Member

Actually, I still don't see why the independent service cannot provide the same API as provided by the agent, with the same URL structure?

@houstonheat
Copy link

houstonheat commented Mar 24, 2021

At this time only agent exposes this configuration API, and the agent is supposed to run as a sidecar or host agent on the same host as the application.

A Jaeger-collector is now exposing sampling API endpoint, so we can throw spans directly to it and get sampler configuration too (without jaeger-agent) jaegertracing/jaeger#1990

Waiting for #554, jaegertracing/documentation#124,

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

5 participants