-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
lib: add span API to diagnostics_channel #35534
Conversation
Review requested:
|
254bf26
to
07305ce
Compare
07305ce
to
d3bea0b
Compare
cc @nodejs/diagnostics Now that diagnostics_channel has landed, I'd like to get a fresh look at this to figure out how we can evolve the spans concept to make it less controversial. The general intent is to somehow provide a channel-unique correlation identifier to indicate that a set of events are related, along with some method of marking the start and end of a sequence of correlated events. I'm not tied to the current API design, it is just one possibility. |
d3bea0b
to
de91871
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
de91871
to
f2d16bb
Compare
In general I agree that something to correlate spans/transactions is helpful for diagnostics data. There are some drawbacks in optinion:
|
The included docs already suggest when a span would make sense. Do you think there's something more needed than what I've already included?
Reuse of a correlation id is achieved by reusing the span object. If you want to use the id for something like linking one span to another, you can just get the id from
The overhead is extremely minimal. All it does it create an object with a numeric id, a name to identify the event type, and the message data itself. Do you have any suggestions for a simpler way to achieve the id and sequencing needs here?
That's assuming a channel would be used for multiple types of message data, which is not intended. Each channel should have a single purpose. I would strongly discourage sending spans on the same channel as non-span events. If it's something that doesn't fit a
Yep, I need to figure out a better way to handle that. That specific API is intended more just as a helper and I'm fine omitting that until we can figure out a good solution. |
Regarding docs: I meant publishers have to document what data they publish. So they could also include some correlationId in their data without dedicated support in core. I have overlooked If you recommend to not mix spans and single messages on a channel I would recommend that API should reflect this. Maybe we should add a |
I'm not really sure there's a good way to add a new channel type parallel to the existing one though, due to how the publisher and subscriber sides basically form a race to construct the named channel instance. The subscriber-side API would all need to change to make sure it's constructing the appropriate type when not already found, which would probably also require duplicating most if not all of the other module internals... |
Another limitation of |
The timings are what the map function was intended for, though I'm not convinced that's a great solution. 😕 |
It's not just storing the timing. consider e.g. OpenTelemetry as consumer - they will call |
You can do the correlation in the map function too. Also, |
Haven't read the code yet, only the docs and discussion on the PR. So far I agree with @Flarna though, this can easily be achieved with the current API today by producers. Furthermore, general consensus in the diagnostics meeting today was that we need to start seeing adoption (especially by producers) of the existing API before adding new things (unless adding those new things is essential for adoption). @Qard do you know any frameworks using the current API, or with plans to use it in the near future? |
I'm working on adding it to express, and I believe @RafaelGSS was working on making a fastify pugin. I would say that the spans API is somewhat essential to adoption though. There's definitely some value to what's already there, but there are certain common patterns such as expressing a span which would greatly benefit from a unified/standard way to express it, otherwise the ecosystem will gradually get fragmented. It would not be ideal if an APM wanted to instrument ten different database libraries and needed ten different span representation systems to handle all of them. 😬 |
Yes, here fastify/fastify#2697 is the tracking issue. I haven't read the code though but seems reasonable to have a unique way to deal with Spans. |
cc @nodejs/diagnostics I'm still seeking further feedback on this. I want to figure out some way to move this forward. |
Sorry, this got out of my focus... What about publishing a
We could add a basic implementation of the span |
Seems like all your arguments are against the |
Yes, it's the consumer side I don't like that much. But I have to admit that I haven't tried yet to use your proposal in a bigger sample. By proposing a Span object on consumer side I have a symmetry with publisher in mind. A published span arrives as span at consumer side, piece by piece. I don't propose a completly different API. The publisher side is most likely uneffected. The consumer gets a Most likely it would be best that I just write down in code what I mean. Will try but I can't promise a date. |
I'd be happy to get on a call sometime too, if you think that would help. We're getting into the holidays now though, so I don't expect to see a lot of movement on this until after the holidays are over. 😅 |
To me, it looks like Otherwise I think this Span API is a good idea, to at least try to give a general direction for the de facto (non-)standardization process that will happen in |
I've split the span api out of #34895 as the exact design seems to still be a bit controversial, so I'd like to iterate on it here to allow the core of diagnostics_channel to land separately.
Depends on #34895
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes