Configuration { public static Configuration fromEnv() { return Configuration.fromEnv(getProperty(JAEGER_SERVICE_NAME)); } Configuration(String serviceName); static Configuration fromEnv(); static Configuration fromEnv(String serviceName); JaegerTracer.Builder getTracerBuilder(); synchronized JaegerTracer getTracer(); synchronized void closeTracer(); Configuration withMetricsFactory(MetricsFactory metricsFactory); Configuration withServiceName(String serviceName); Configuration withReporter(ReporterConfiguration reporterConfig); Configuration withSampler(SamplerConfiguration samplerConfig); Configuration withCodec(CodecConfiguration codecConfig); Configuration withTraceId128Bit(boolean useTraceId128Bit); Configuration withTracerTags(Map<String, String> tracerTags); String getServiceName(); ReporterConfiguration getReporter(); SamplerConfiguration getSampler(); CodecConfiguration getCodec(); MetricsFactory getMetricsFactory(); Map<String, String> getTracerTags(); static final String JAEGER_PREFIX; static final String JAEGER_ENDPOINT; static final String JAEGER_AUTH_TOKEN; static final String JAEGER_USER; static final String JAEGER_PASSWORD; static final String JAEGER_AGENT_HOST; static final String JAEGER_AGENT_PORT; static final String JAEGER_REPORTER_LOG_SPANS; static final String JAEGER_REPORTER_MAX_QUEUE_SIZE; static final String JAEGER_REPORTER_FLUSH_INTERVAL; static final String JAEGER_SAMPLER_TYPE; static final String JAEGER_SAMPLER_PARAM; static final String JAEGER_SAMPLER_MANAGER_HOST_PORT; static final String JAEGER_SERVICE_NAME; static final String JAEGER_TAGS; static final String JAEGER_PROPAGATION; static final String JAEGER_SENDER_FACTORY; static final String JAEGER_TRACEID_128BIT; }
@Test public void testFromEnv() { System.setProperty(Configuration.JAEGER_SERVICE_NAME, "Test"); assertNotNull(Configuration.fromEnv().getTracer()); }
@Test public void testSamplerConst() { System.setProperty(Configuration.JAEGER_SAMPLER_TYPE, ConstSampler.TYPE); System.setProperty(Configuration.JAEGER_SAMPLER_PARAM, "1"); SamplerConfiguration samplerConfig = SamplerConfiguration.fromEnv(); assertEquals(ConstSampler.TYPE, samplerConfig.getType()); assertEquals(1, samplerConfig.getParam().intValue()); }
@Test public void testSamplerConstInvalidParam() { System.setProperty(Configuration.JAEGER_SAMPLER_TYPE, ConstSampler.TYPE); System.setProperty(Configuration.JAEGER_SAMPLER_PARAM, "X"); SamplerConfiguration samplerConfig = SamplerConfiguration.fromEnv(); assertEquals(ConstSampler.TYPE, samplerConfig.getType()); assertNull(samplerConfig.getParam()); }
@Test public void testReporterConfiguration() { System.setProperty(Configuration.JAEGER_REPORTER_LOG_SPANS, "true"); System.setProperty(Configuration.JAEGER_AGENT_HOST, "MyHost"); System.setProperty(Configuration.JAEGER_AGENT_PORT, "1234"); System.setProperty(Configuration.JAEGER_REPORTER_FLUSH_INTERVAL, "500"); System.setProperty(Configuration.JAEGER_REPORTER_MAX_QUEUE_SIZE, "1000"); ReporterConfiguration reporterConfig = ReporterConfiguration.fromEnv(); assertTrue(reporterConfig.getLogSpans()); assertEquals("MyHost", reporterConfig.getSenderConfiguration().getAgentHost()); assertEquals(1234, reporterConfig.getSenderConfiguration().getAgentPort().intValue()); assertEquals(500, reporterConfig.getFlushIntervalMs().intValue()); assertEquals(1000, reporterConfig.getMaxQueueSize().intValue()); }
@Test public void testReporterConfigurationInvalidFlushInterval() { System.setProperty(Configuration.JAEGER_REPORTER_FLUSH_INTERVAL, "X"); ReporterConfiguration reporterConfig = ReporterConfiguration.fromEnv(); assertNull(reporterConfig.getFlushIntervalMs()); }
@Test public void testReporterConfigurationInvalidLogSpans() { System.setProperty(Configuration.JAEGER_REPORTER_LOG_SPANS, "X"); ReporterConfiguration reporterConfig = ReporterConfiguration.fromEnv(); assertFalse(reporterConfig.getLogSpans()); }
@Test public void testSenderBackwardsCompatibilityGettingAgentHostAndPort() { System.setProperty(Configuration.JAEGER_AGENT_HOST, "jaeger-agent"); System.setProperty(Configuration.JAEGER_AGENT_PORT, "6832"); assertEquals("jaeger-agent", Configuration.ReporterConfiguration.fromEnv() .getSenderConfiguration().getAgentHost()); assertEquals(Integer.valueOf(6832), Configuration.ReporterConfiguration.fromEnv() .getSenderConfiguration().getAgentPort()); }
@Test public void testSenderInstanceIsCached() { SenderConfiguration senderConfiguration = SenderConfiguration.fromEnv(); assertEquals(senderConfiguration.getSender(), senderConfiguration.getSender()); }