-
Notifications
You must be signed in to change notification settings - Fork 19
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
base: master
Are you sure you want to change the base?
Conversation
this will make it always make a child. I think it is better to guard for now. |
@adriancole Do you mean it is better to fix as follows: Option(contextOrFlags.context())
.map(tracer.joinSpan)
.getOrElse(tracer.nextSpan(contextOrFlags)) |
To be honest I am a bit confused about 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? |
maybe the javadoc are not rendering for you. I think it is explained
exactly including how to handle conditional here
https://github.com/openzipkin/brave/blob/master/brave/src/main/java/brave/Tracer.java#L184
…On Wed, Jul 10, 2019, 3:57 PM Simão Mata ***@***.***> wrote:
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?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#53?email_source=notifications&email_token=AAAPVV34IWG2IXIHJ7PTIULP6WB35A5CNFSM4H7HHUV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZSP3IQ#issuecomment-509935010>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAPVV3RH37CDVEV76ETHH3P6WB35ANCNFSM4H7HHUVQ>
.
|
also here is the correct code which can be copy paste until such time as
the http abstraction is implemented here..
https://github.com/openzipkin/brave/blob/master/instrumentation/http/src/main/java/brave/http/HttpServerHandler.java#L96
|
I think this looks good. |
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);
} |
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()) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
been a long time. just rebased the project so it has CI etc |
just rebased and seems ci is green. I'll try to write that test. |
To account for the case when `contextOrFlags.context() == null`
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. |
To account for the case when
contextOrFlags.context() == null