-
Notifications
You must be signed in to change notification settings - Fork 2
What's the story with threads? #3
Comments
I haven't entirely thought it through yet, but we should check out how the Go library deals with this. From memory, I believe it's roughly about |
opentracing/specification#23 may discuss this. In general, it seems that this is not part of the OpenTracing spec, so i'd be inclined to just hold off. https://github.com/opentracing/opentracing-java/blob/master/opentracing-api/src/main/java/io/opentracing/ActiveSpan.java#L64 is |
A way forward, I think, could be to split 'current span' tracking etc (move it into Remains the shared use of Maybe a
|
Well it wouldn't be much work to copy the Java API and have data Continuation
captureActiveSpan :: Tracer -> IO (Maybe Continuation)
restore :: Tracer -> Continuation -> IO () But I need to give it a bit of thought, and might also need to think about these I'm a little cautious about committing to a particular monad or transformer though. I'm not sure about the connection to |
What I tried to say about the writeBuf :: WriteBuffer -> LBS.ByteString -> IO ()
writeBuf w s = modifyIORef w ( <> lazyByteString s) (https://git1-us-west.apache.org/repos/asf?p=thrift.git;a=blob;f=lib/hs/src/Thrift/Transport/IOBuffer.hs;hb=39310dad793ca69b4b7217a3b54430e682e5e2a4) Thinking of it, doing a worker-thread(s?) + queue approach would
|
Given the I believe there are 3 possible states:
Not sure how to encode this ergonomically (wrt how a span is stored in the state) though. Will do some exploration-while-coding. |
I was thinking of using some |
pitfalls?
Certainly, and this comes from having the jaeger tracer fork a thread that periodically flushes.
|
I was trying to figure out how to handle concurrency (
forkIO
,async
).A potential API I came up with would be something like
I implemented something along these lines (although my
fork
isReference -> Text -> TracingT IO () -> TracingT IO ThreadId
since I didn't generalize it), also introducingactiveSpanContext :: Tracer -> IO (Maybe SpanContext)
to theOpenTracing
sig and implenting it inJaeger
accordingly.Sadly enough, this does not work, because of the
IORef (Maybe Span)
being used in theJaeger.Tracer
type. What should be added instead, I guess, is some kind ofdupTracer
which creates a newIORef
to be used within the thread, or something along those lines.It may also require creating new sockets etc, or coordination between threads, because otherwise multiple threads could
write
to the same socket concurrently (may not be a problem with UDP transports, but would be with TCP-based tracing systems).This seems to become messy quite quickly.
An alternative could be to have a single thread interacting with the tracing agent, and use some kind of queue to submit spans to it.
Related to this: need to figure out how to play nice with libraries like
async
. Getting things to 'Just Work' seems difficult, some new APIs will be required I believe. But ending up with something likewhere the sub-threads would
ChildOf
reference the main one could be sensible, staying close to theasync
APIs, and not requiring changes togetPage
(which may be a library function, not tracing-enabled).The text was updated successfully, but these errors were encountered: