-
Notifications
You must be signed in to change notification settings - Fork 296
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
Many spans created when .forEach
is called on mongodb results
#892
Comments
This is because of the support for cursors, which may not really be useful. It should probably not be removed completely since that would be a breaking change, but there should definitely be an option to disable that if that's not relevant in some (most?) cases. |
If that option were to exist, would that mean that all would be combined into one single span? |
Correct, you would have a single span for the entire duration of the query instead of one per individual cursor iteration. |
Thank you, that would be much appreciated. |
Any updates here, or guidance on roughly where in the library this change would need to be made? I'm happy to help with implementation. |
No update unfortunately.
The relevant code is here. In order to not have a breaking change, I think there should be an option to collapse cursor spans to a single span.
We definitely welcome constributions! If you decide to do it and have any questions, please feel free to open an unfinished PR to ask for guidance :) |
@millerick It turns out it may not be possible to handle this in a generic way on the cursor. However, if you are never explicitly calling |
@rochdev , that would work for our use case. We do not explicitly call |
@millerick After thinking about this more I think it actually makes more sense to do the opposite and instrument the actual underlying driver directly. This will provide more accurate results, which should also solve #719. The downside is that there would still be many spans for any collection method that uses cursors internally, but they would be labeled correctly with a Would that work for you as well? Merging everything into a single span while supporting all edge cases would require some pretty ugly hacks that would be nearly impossible to test and might reduce the accuracy of stats. Generally speaking, it also means hiding information since when using a cursor, there are in fact many calls made to the server to advance the cursor and consume documents, even if not apparent in the public interface. |
@rochdev , yeah, that approach works as well. In saying that, I assume that there would be the appropriate number of |
It depends on the settings of the cursor. For example, if the |
Yeah, which makes sense and is the valuable information. |
Fixed in #1159. Each span now correctly corresponds to an actual command sent to Mongo with more relevant metadata. |
Describe the bug
We have one particular data retrieval that does the following operation on top of
mongodb
:The end results is many, many spans that are created. The first span that is created for this:
The last span that is created for this:
Since there is only one operation on the database, I would expect for only a single span to be created, despite the fact that each document in the result set is iterated over.
Environment
The text was updated successfully, but these errors were encountered: