[ 
https://issues.apache.org/jira/browse/HTRACE-214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14653077#comment-14653077
 ] 

Masatake Iwasaki commented on HTRACE-214:
-----------------------------------------

Thanks for the update, [~cmccabe].

bq. The span receivers are closed either when the process is about to exit, or 
when all Tracers have been closed.

I think the design is reasonable. We should make certain to close Tracer by 
try-with-resources or finally block and document it. Some tests expecting there 
is no receivers yet failed due to existing receivers other tests created. 

{noformat}
TestCreateStandardSpanReceivers(org.apache.htrace.TestSpanReceiverBuilder)  
Time elapsed: 0.005 sec  <<< FAILURE!
java.lang.AssertionError
        at org.junit.Assert.fail(Assert.java:86)
        at org.junit.Assert.assertTrue(Assert.java:41)
        at org.junit.Assert.assertTrue(Assert.java:52)
        at 
org.apache.htrace.TestSpanReceiverBuilder.TestCreateStandardSpanReceivers(TestSpanReceiverBuilder.java:53)

testGetSpanReceiverWithConstructorError(org.apache.htrace.TestSpanReceiverBuilder)
  Time elapsed: 0.007 sec  <<< FAILURE!
java.lang.AssertionError: expected:<1> but was:<6>
        at org.junit.Assert.fail(Assert.java:88)
        at org.junit.Assert.failNotEquals(Assert.java:743)
        at org.junit.Assert.assertEquals(Assert.java:118)
        at org.junit.Assert.assertEquals(Assert.java:555)
        at org.junit.Assert.assertEquals(Assert.java:542)
        at 
org.apache.htrace.TestSpanReceiverBuilder.testGetSpanReceiverWithConstructorError(TestSpanReceiverBuilder.java:119)
{noformat}

We can close tracers before or after of unit tests otherwise.
{code}
  @After
  public void closeTracers() {
    for (Tracer tracer : TracerPool.GLOBAL.getTracers()) {
      TracerPool.GLOBAL.removeTracer(tracer);
    }
  }
{code}


> De-globalize Tracer.java
> ------------------------
>
>                 Key: HTRACE-214
>                 URL: https://issues.apache.org/jira/browse/HTRACE-214
>             Project: HTrace
>          Issue Type: Sub-task
>    Affects Versions: 4.0
>            Reporter: Colin Patrick McCabe
>            Assignee: Colin Patrick McCabe
>         Attachments: HTRACE-214.001.patch, HTRACE-214.002.patch, 
> HTRACE-214.003.patch
>
>
> De-globalize Tracer.java.
> Currently, Tracer is a Singleton managed by TracerHolder.  Instead, Tracer 
> objects should be created by each process or library that needs to use 
> HTrace.  This enables a few things:
> * When the Tracer object is created, we can give it a name.  Then we can use 
> this name in the "process id" of all spans created by that tracer, rather 
> than trying to scrape the JVM name using "questionable" methods.
> * SpanReceivers can be shared between multiple Tracer objects in the same 
> process.  The span receivers are reference counted.  This should eliminate 
> the "double tracing" issues we have had when tracing client libraries inside 
> processes which also want tracing.
> * Tracers can be closed by calling Tracer#close.  If the Tracer being closed 
> is the last tracer in the process, it will close all the span receivers.
> * We will have a TracerFactory that takes care of the details of creating the 
> right span receivers based on the configuration.  This removes some 
> boilerplate that is currently needed to enable HTrace in an application or 
> library.  We can also make SpanReceiverFactory package-private since it will 
> no longer need to be publicly visible.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to