Skip to content

Commit

Permalink
Merge pull request #23712 from sophokles73/fix_setting_of_sampler_man…
Browse files Browse the repository at this point in the history
…ager_host_property

Fix setting of JAEGER_SAMPLER_MANAGER_HOST_PORT system property
  • Loading branch information
radcortez authored Feb 16, 2022
2 parents 68dff2c + 17761a0 commit b6007d5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.quarkus.jaeger.test;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.jaegertracing.Configuration.SamplerConfiguration;
import io.quarkus.test.QuarkusUnitTest;

/**
* Tests verifying configuration of a remote sampler manager.
*
*/
public class SamplerManagerConfigurationTest {

@RegisterExtension
static final QuarkusUnitTest TEST = new QuarkusUnitTest().withEmptyApplication()
.overrideConfigKey("quarkus.jaeger.service-name", "my-service")
.overrideConfigKey("quarkus.jaeger.sampler-manager-host-port", "my-jaeger-host:5778");

/**
* Verifies that the {@code JAEGER_SAMPLER_MANAGER_HOST_PORT} system property is set to the
* host name and port specified in the {@code quarkus.jaeger.sampler-manager-host-port} property.
*/
@Test
void testSamplerManagerHostIsSetCorrectly() {
SamplerConfiguration config = SamplerConfiguration.fromEnv();
assertEquals("my-jaeger-host:5778", config.getManagerHostPort());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@Recorder
public class JaegerDeploymentRecorder {
private static final Logger log = Logger.getLogger(JaegerDeploymentRecorder.class);
private static final Optional UNKNOWN_SERVICE_NAME = Optional.of("quarkus/unknown");
private static final Optional<String> UNKNOWN_SERVICE_NAME = Optional.of("quarkus/unknown");
private static final QuarkusJaegerTracer quarkusTracer = new QuarkusJaegerTracer();

public static String jaegerVersion;
Expand Down Expand Up @@ -81,7 +81,8 @@ private void initTracerConfig(JaegerConfig jaeger, ZipkinConfig zipkinConfig) {
duration -> String.valueOf(duration.toMillis()));
initTracerProperty("JAEGER_SAMPLER_TYPE", jaeger.samplerType, type -> type);
initTracerProperty("JAEGER_SAMPLER_PARAM", jaeger.samplerParam, param -> NumberFormat.getInstance().format(param));
initTracerProperty("JAEGER_SAMPLER_MANAGER_HOST_PORT", jaeger.samplerManagerHostPort, hostPort -> hostPort.toString());
initTracerProperty("JAEGER_SAMPLER_MANAGER_HOST_PORT", jaeger.samplerManagerHostPort,
hostPort -> String.format("%s:%d", hostPort.getHostString(), hostPort.getPort()));
initTracerProperty("JAEGER_SERVICE_NAME", jaeger.serviceName, name -> name);
initTracerProperty("JAEGER_TAGS", jaeger.tags, tags -> tags.toString());
initTracerProperty("JAEGER_PROPAGATION", jaeger.propagation, format -> format.toString());
Expand Down

0 comments on commit b6007d5

Please sign in to comment.