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

Scope of the Span not working as expected with Ratpack Promises #21

Closed
kirenjolly opened this issue Feb 25, 2019 · 10 comments
Closed

Scope of the Span not working as expected with Ratpack Promises #21

kirenjolly opened this issue Feb 25, 2019 · 10 comments

Comments

@kirenjolly
Copy link
Contributor

Scope of the Span not working as expected with Ratpack Promises

newScope function in RatpackCurrentTraceContext has the return() which gets executed when scope of span closes when a promise is expected. But is scope is still not over.

@kirenjolly
Copy link
Contributor Author

@llinder @adriancole @beckje01 Can you guys take a look at the modified sample app
https://github.com/kirenjolly/ratpack-kotlin-demo
And check whether i am doing wrong or missing something.
Or this is an issue with Ratpack Promises

@codefromthecrypt
Copy link

taking a look

@codefromthecrypt
Copy link

not exactly sure what this example app is trying to do. It took some time to figure out how to run it, which is kindof time lost.

curl -X POST http://localhost:5050 -H'Content-Type: application/json' -d '{}'

if possible, please instead add a test case to this as what you are mentioning doesn't seem to require a standalone app to vet https://github.com/openzipkin-contrib/brave-ratpack/blob/master/src/test/java/brave/http/ITServerTracingModule.java#L44

@codefromthecrypt
Copy link

possibly related if coroutines are somehow at play here. openzipkin/brave#820 (comment)

@kirenjolly
Copy link
Contributor Author

@adriancole This is a simple ratpack-kotlin app which has a chain that has a all handler. so i am able to get the httpTracing.tracing().currentTraceContext() till the parsejson function.
As parseJson is expecting a promise and then evaluates the promise value.
So when promise is encountered the scope of the server span is somehow closed and hence removes all the TraceContextHolder value in registries.
Thus when i form a new span child it forms as a seperate trace.
This is the exact scenario where i was facing issues from the begining.
So help me out with this same case.

@kirenjolly
Copy link
Contributor Author

@adriancole So At what scenarios does the scope of a span closes unless we specify it explicitly.
Does the scope automatically closes on encountering a promise?

@kirenjolly
Copy link
Contributor Author

This app is just trying to prove that the scope of span fails on promises.
you can hit localhost:5050/main in postman to see that after running the application.
i couldn't figure out why does it took time for you to run it

@codefromthecrypt
Copy link

codefromthecrypt commented Feb 28, 2019 via email

@drmaas
Copy link
Contributor

drmaas commented Mar 4, 2019

Making a request:

curl -XPOST -H "Accept: application/json" -H "Content-Type: application/json" localhost:5050/main -d '{"trace_id":"1","trace_name":"name"}'

Output:

[ratpack-compute-1-9] INFO InitialHandler - InitialSpan: RealSpan(f8dcd4ea5ff36a8b/f8dcd4ea5ff36a8b)
[ratpack-compute-1-9] INFO InitialHandler - initialSpanInChain: RealSpan(f8dcd4ea5ff36a8b/f8dcd4ea5ff36a8b)
[ratpack-compute-1-9] INFO InitialHandler - idFromRequestBody: 1
[ratpack-compute-1-9] INFO InitialHandler - is Span Context present in tracer: false

Ultimately it looks like context is null when calling this line: https://github.com/openzipkin-contrib/brave-ratpack/blob/master/src/main/java/ratpack/zipkin/internal/RatpackCurrentTraceContext.java#L43

Also, a new trace context holder ends up in the execution registry in the .then block with an empty context, where the the trace context holder pre-then does contain a context. When debugging the above line I can see different objects. Not yet sure why this is.

@drmaas
Copy link
Contributor

drmaas commented Mar 5, 2019

I think this issue is also unique to parsing request bodies.

llinder added a commit to llinder/brave-ratpack that referenced this issue Mar 10, 2019
llinder added a commit to llinder/brave-ratpack that referenced this issue Mar 10, 2019
llinder added a commit to llinder/brave-ratpack that referenced this issue Mar 10, 2019
llinder added a commit to llinder/brave-ratpack that referenced this issue Mar 10, 2019
llinder added a commit that referenced this issue Mar 11, 2019
 ensure the same span is available after parsing requests, closes #21
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

No branches or pull requests

3 participants