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

Add a Tracer.close() method #78

Merged
merged 1 commit into from
Oct 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions jaeger-core/src/main/java/com/uber/jaeger/Tracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ public <T> io.opentracing.SpanContext extract(Format<T> format, T carrier) {
return extractor.extract(carrier);
}

/**
* Shuts down the {@link Reporter} and {@link Sampler}
*/
public void close(){
reporter.close();
sampler.close();
}

private class SpanBuilder implements io.opentracing.Tracer.SpanBuilder {

private String operationName = null;
Expand Down
22 changes: 17 additions & 5 deletions jaeger-core/src/test/java/com/uber/jaeger/TracerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@
*/
package com.uber.jaeger;

import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import com.uber.jaeger.metrics.InMemoryStatsReporter;
import com.uber.jaeger.propagation.Injector;
import com.uber.jaeger.reporters.InMemoryReporter;
import com.uber.jaeger.reporters.Reporter;
import com.uber.jaeger.samplers.ConstSampler;
import com.uber.jaeger.samplers.Sampler;
import io.opentracing.propagation.Format;
import io.opentracing.propagation.TextMap;
import io.opentracing.propagation.TextMapExtractAdapter;
Expand All @@ -36,11 +43,6 @@
import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

public class TracerTest {

Tracer tracer;
Expand Down Expand Up @@ -132,4 +134,14 @@ public void testServiceNameNotNull() {
public void testServiceNameNotEmptyNull() {
new Tracer.Builder(" ", new InMemoryReporter(), new ConstSampler(true));
}

@Test
public void testClose(){
Reporter reporter = mock(Reporter.class);
Sampler sampler = mock(Sampler.class);
tracer = new Tracer.Builder("bonda", reporter, sampler).build();
tracer.close();
verify(reporter).close();
verify(sampler).close();
}
}