-
Notifications
You must be signed in to change notification settings - Fork 10
Conversation
Pass in a tracer as an option when creating a Remit instance and watch it fly!
Because the lib currently uses jeff-lewis/cls-hooked for passing tracing context in-process, other pieces (Express, GraphQL, etc) will find it hard to communicate fully with Remit, as the parent context is decided via usage of this hook. For that reason, it may also be pertinent to allow the passing of a This might look something like: // public libs
const { getNamespace } = require('cls-hooked')
const Remit = require('remit')
// setup
const session = getNamespace('tracing')
const remit = Remit({ namespace: session })
// Remit will use this same namespace to fetch the parent
// context of traces internally.
session.set('context', myParentContext) Madness or something that'd be required for more complex traces (i.e. combining the tracing functionalities of multiple libraries)? |
@jpwilliams This looks solid by the way had a glance earlier need time to dig in a bit more though. As for your last comment. That's a super interesting question - a similar one is asked here opentracing/specification#23 - consensus seems to be that it's quite hard to do. |
More detailed examples here: https://github.com/opentracing/opentracing.io/blob/master/_docs/pages/instrumentation/common-use-cases.md#in-process-request-context-propagation . It seems you have to be more intentional about what metrics are sent which seems fine to me at least. |
Cheeky question: If we wanted
Could we get a span for |
@jacktuck Great find on that OpenTracing spec ticket! Interesting to see that it's an ongoing concern. Will definitely stick with jeff-lewis/cls-hooked for now as it's nice for the user to not have to think about it at all. (In fact, we need this, otherwise users would have to explicitly pass in parent contexts to make tracing work, which just seems mad.) With there being no set way to proceed, I'm tempted to allow the injection of a namespace as above and see how that goes; we can happily switch to a "standard" method if one comes along from OpenTracing. Not sure I follow your labels example. Whatchya wanting to measure there? |
@jpwilliams Yeah ignore the labelled block thingy haha. I guess if remit exposes opentracing users can always insert their own spans to measure different parts within the same process. |
@jacktuck Yeah exactly that. Interesting. I'll add it in here when I have time and then test it out with some Express/GraphQL bits to see how easy it integrates. |
Can't wait for this to be merged ❤️ |
This also allows users to pass in the namespace used for this, letting them sync up the usage across multiple libraries.
This is looking pretty sorted to me. Can I get a review @jacktuck / @jackjacek? The OpenTracing client provides a |
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.
Just some observations which could be non-issues.
Adds OpenTracing support to Remit! 🎉
You can pass in any tracer under the
tracer
key when creating a Remit instance and it'll push spans to that tracer! Awesome!So far only tested with Jaeger and needs a lot more looking at to prove that it works as intended, as well as tests (OpenTracing's no-op default Tracer provides a
report
function that can help with this, perhaps?) and docs.Tracers that are currently "officially" supported are: