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

Add possibility to specify serviceName with 'fromEnv' #510

Merged

Conversation

jpkrohling
Copy link
Collaborator

Signed-off-by: Juraci Paixão Kröhling juraci@kroehling.de

Which problem is this PR solving?

  • It's currently not possible to easily explicitly set the service name and have all the other values coming from env vars. Either the consuming application needs to set a system property and possibly clear it afterwards, or needs to call all other relevant with methods (withTracerTags being the most problematic one, IMO).

Setting/clearing a system property might be trivial for single tenant JVM instances, but it's a problem when the JVM has multiple tenants, which is usually the case for application servers like WildFly.

Short description of the changes

  • Added a Configuration.fromEnv(String) method based on the existing Configuration.fromEnv() one
  • Changed Configuration.fromEnv() to use the new method, passing JAEGER_SERVICE_NAME as the serviceName.

@ghost ghost assigned jpkrohling Aug 7, 2018
@ghost ghost added the review label Aug 7, 2018
@codecov
Copy link

codecov bot commented Aug 7, 2018

Codecov Report

Merging #510 into master will increase coverage by 0.11%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #510      +/-   ##
============================================
+ Coverage      88.2%   88.31%   +0.11%     
- Complexity      498      499       +1     
============================================
  Files            65       65              
  Lines          1848     1849       +1     
  Branches        239      239              
============================================
+ Hits           1630     1633       +3     
+ Misses          141      139       -2     
  Partials         77       77
Impacted Files Coverage Δ Complexity Δ
.../src/main/java/io/jaegertracing/Configuration.java 94.16% <100%> (+0.02%) 40 <2> (+1) ⬆️
...egertracing/internal/reporters/RemoteReporter.java 85.71% <0%> (+2.38%) 7% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f3e5049...a8c8225. Read the comment docs.

Copy link
Contributor

@objectiser objectiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - One minor thing to fix.

@@ -85,7 +85,19 @@ public void clearProperties() throws NoSuchFieldException, IllegalAccessExceptio
public void testFromEnv() {
System.setProperty(Configuration.JAEGER_SERVICE_NAME, "Test");
assertNotNull(Configuration.fromEnv().getTracer());
assertFalse(GlobalTracer.isRegistered());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If removing from here, then should remove GlobalTracer completely from this test class (i.e. clearProperies()).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I removed it because I find it confusing that the test would make a relationship between fromEnv() and the GlobalTracer. If there's indeed a need to ensure the global tracer is not registered after fromEnv() is called, I can put it back.

Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
return Configuration.fromEnv(getProperty(JAEGER_SERVICE_NAME));
}

public static Configuration fromEnv(String serviceName) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok to add this if it is the only init-time required parameter. Otherwise I think the error handling should be moved to build method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the only required parameter.

@jpkrohling jpkrohling merged commit a8c8225 into jaegertracing:master Aug 7, 2018
@ghost ghost removed the review label Aug 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants