Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use nextSpan instead of joinSpan #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

simao
Copy link

@simao simao commented Jul 9, 2019

To account for the case when contextOrFlags.context() == null

@codefromthecrypt
Copy link

this will make it always make a child. I think it is better to guard for now.

@shimamoto
Copy link
Member

@adriancole Do you mean it is better to fix as follows:

Option(contextOrFlags.context())
      .map(tracer.joinSpan)
      .getOrElse(tracer.nextSpan(contextOrFlags))

@simao
Copy link
Author

simao commented Jul 10, 2019

To be honest I am a bit confused about nextSpan, joinSpan and similar... This method is called when calling a remote api for example, in that case shouldn't a new newChild always be called?

If there is a parent span already, that would be the span of something that called this service and there should be a child span of that span?

@codefromthecrypt
Copy link

codefromthecrypt commented Jul 11, 2019 via email

@codefromthecrypt
Copy link

codefromthecrypt commented Jul 11, 2019 via email

@shimamoto
Copy link
Member

I think this looks good.

@codefromthecrypt
Copy link

sorry to be more literal, both old and new are broken code. scala variant of this can fix it.

  Span nextSpan(TraceContextOrSamplingFlags extracted, Req request) {
    Boolean sampled = extracted.sampled();
    // only recreate the context if the http sampler made a decision
    if (sampled == null && (sampled = sampler.trySample(adapter, request)) != null) {
      extracted = extracted.sampled(sampled.booleanValue());
    }
    return extracted.context() != null
        ? tracer.joinSpan(extracted.context())
        : tracer.nextSpan(extracted);
  }

@codefromthecrypt
Copy link

sorry actually this code looks ok because you don't have http sampler anyway yet. it does need test case though

@@ -170,7 +170,8 @@ trait ZipkinTraceServiceLike {
(carrier: A, key: String) => getHeader(carrier, key).orNull
).extract(headers)

tracer.joinSpan(contextOrFlags.context())
Option(contextOrFlags.context())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is good, just need test case. you can use something like only sampled header to test.

ex. test that X-B3-Sampled: 0 results in a new unsampled trace

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like I would need #32 to write a test for this?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit test could be done now I suspect.

@codefromthecrypt
Copy link

been a long time. just rebased the project so it has CI etc

@simao
Copy link
Author

simao commented Nov 24, 2020

just rebased and seems ci is green. I'll try to write that test.

To account for the case when `contextOrFlags.context() == null`
@simao
Copy link
Author

simao commented Feb 26, 2021

Hi,

I added a unit test, but I think I didn't get the idea, as this test passes even without my changes. Could you explain a bit more what do you mean I should be testing here?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants