ext/pymongo: Add instrumentor#612
Merged
toumorokoshi merged 11 commits intoopen-telemetry:masterfrom Apr 27, 2020
mauriciovasquezbernal:mauricio/instrumentation-pymongo
Merged
ext/pymongo: Add instrumentor#612toumorokoshi merged 11 commits intoopen-telemetry:masterfrom mauriciovasquezbernal:mauricio/instrumentation-pymongo
toumorokoshi merged 11 commits intoopen-telemetry:masterfrom
mauriciovasquezbernal:mauricio/instrumentation-pymongo
Conversation
The current Pymongo integration uses the monitoring.register() [1] to hook the different internal calls of Pymongo. This integration doesn't allow to unregister a monitor. This commit workaround that limitation by adding an enable flag to the CommandTracer class and adds a logic to disable the integration. This solution is not perfect becasue there will be some overhead even when the instrumentation is disabled, but that's what we can do with the current approach. [1] https://api.mongodb.com/python/current/api/pymongo/monitoring.html#pymongo.monitoring.register
Pop span instead of getting and then removing it.
hectorhdzg
reviewed
Apr 24, 2020
ext/opentelemetry-ext-pymongo/src/opentelemetry/ext/pymongo/__init__.py
Outdated
Show resolved
Hide resolved
hectorhdzg
reviewed
Apr 24, 2020
ext/opentelemetry-ext-pymongo/src/opentelemetry/ext/pymongo/__init__.py
Outdated
Show resolved
Hide resolved
hectorhdzg
reviewed
Apr 24, 2020
ext/opentelemetry-ext-pymongo/src/opentelemetry/ext/pymongo/__init__.py
Outdated
Show resolved
Hide resolved
hectorhdzg
approved these changes
Apr 24, 2020
Member
hectorhdzg
left a comment
There was a problem hiding this comment.
LGTM only added some small suggestions
toumorokoshi
approved these changes
Apr 25, 2020
ext/opentelemetry-ext-pymongo/src/opentelemetry/ext/pymongo/__init__.py
Outdated
Show resolved
Hide resolved
|
|
||
| def _remove_span(self, event): | ||
| self._span_dict.pop(_get_span_dict_key(event)) | ||
| if not self.enable: |
Member
There was a problem hiding this comment.
I notice this snippet is almost identical to the above code. Don't know if it's worth refactoring into a utility method though.
Member
Author
There was a problem hiding this comment.
Do you mean the following snippet?
if not self.is_enabled:
return
?
Member
There was a problem hiding this comment.
nvm. I maybe be going crazy, but I thought a diff verifying significantly more standard attributes like db type.
srikanthccv
pushed a commit
to srikanthccv/opentelemetry-python
that referenced
this pull request
Nov 1, 2020
closes open-telemetry#612 Signed-off-by: Olivier Albertini <olivier.albertini@montreal.ca>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements the Instrumentor interface for the Pymongo integration. It also implements a way to disable instrumentation.
I compared with the DataDog donated implementation available at https://github.com/open-telemetry/opentelemetry-python-contrib/tree/master/reference/ddtrace/contrib/pymongo, the already existing implementation is good enough and we do not need to take any from that in this case.
I'm opening a new PR to supersedes #598 to avoid reviewing and approving my own changes there.
How to try:
pymongo_example.py:
If everything went fine you see some spans on the terminal.