-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting an explicit service name (#39)
Fixes: #38
- Loading branch information
Showing
5 changed files
with
105 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...cing/contrib/java/spring/jaeger/starter/basic/JaegerTracerServiceNameSetExplicitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright 2018-2019 The OpenTracing Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package io.opentracing.contrib.java.spring.jaeger.starter.basic; | ||
|
||
import static org.assertj.core.api.Java6Assertions.assertThat; | ||
|
||
import io.opentracing.contrib.java.spring.jaeger.starter.AbstractTracerSpringTest; | ||
import org.junit.Test; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
@TestPropertySource( | ||
properties = { | ||
"spring.main.banner-mode=off", | ||
"opentracing.jaeger.enabled=true", | ||
"opentracing.jaeger.service-name=foo", | ||
"spring.application.name=bar" | ||
} | ||
) | ||
public class JaegerTracerServiceNameSetExplicitTest extends AbstractTracerSpringTest { | ||
|
||
@Test | ||
public void testNameIsAsExpected() { | ||
assertThat(tracer).isNotNull(); | ||
assertThat(tracer).isInstanceOf(io.jaegertracing.internal.JaegerTracer.class); | ||
|
||
// 'opentracing.jaeger.service-name' should take priority over 'spring.application.name' | ||
assertThat((getTracer()).getServiceName()).isEqualTo("foo"); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...rib/java/spring/jaeger/starter/basic/JaegerTracerServiceNameSetExplicitWithPropsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright 2018-2019 The OpenTracing Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package io.opentracing.contrib.java.spring.jaeger.starter.basic; | ||
|
||
import static org.assertj.core.api.Java6Assertions.assertThat; | ||
|
||
import io.opentracing.contrib.java.spring.jaeger.starter.AbstractTracerSpringTest; | ||
import org.junit.Test; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
@TestPropertySource( | ||
properties = { | ||
"spring.main.banner-mode=off", | ||
"opentracing.jaeger.enabled=true", | ||
"spring.application.name=foo", | ||
"app.env=stage", | ||
"opentracing.jaeger.service-name=${spring.application.name}-${app.env}" | ||
} | ||
) | ||
public class JaegerTracerServiceNameSetExplicitWithPropsTest extends AbstractTracerSpringTest { | ||
|
||
@Test | ||
public void testNameIsAsExpected() { | ||
assertThat(tracer).isNotNull(); | ||
assertThat(tracer).isInstanceOf(io.jaegertracing.internal.JaegerTracer.class); | ||
|
||
assertThat((getTracer()).getServiceName()).isEqualTo("foo-stage"); | ||
} | ||
} |