-
Notifications
You must be signed in to change notification settings - Fork 549
Trytond integration #548
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
Trytond integration #548
Conversation
Conflicts: tox.ini
Waiting for Tryton community feedback https://discuss.tryton.org/t/sentry-sdk-integration/1925 |
Regarding the failed checks:
If the community agrees, I would settle for the easy solution: only supporting python>=3.6 |
@n1ngu it's ok to remove |
In my eyes there should be no reason to call |
That's a good point. This handler should be understood not as a framework integration but as a mean to inject code in tools that won't allow it. Obviously, if the default sdk initialization does not suffice for a particular purpose, neither will this handler. If this is a concern and such a feature was not acceptable for the core sdk I will retire it from this PR so we can focus on the actual trytond wsgi integration above! (but I'll still vendor it in my deployments 😁) Regarding complex That's why I'd settle for the "use this only if the default |
@untitaker Stated with different words: this handler could be shipped alongside the EventHandler and BreadcrumbHandler in the sentry_sdk.integrations.logging module. Not to power full Sentry customization but to ease a naive Sentry initialization in honor to your own documentation:
The alternative for this kind of not easily-hackable tools is a tedious logging config setup with the EventHandler, and still with the problem of "where to state the DSN" |
@n1ngu I would much rather separate the discussion of alternative initialization methods from getting this integration merged. The former is more controversial imo |
@n1ngu could you open a pr against https://github.com/getsentry/sentry-docs? |
Example PR: getsentry/sentry-docs#867 |
I think it would be fine to omit the request data as well if you think it
cannot be useful in the context of trytond. I do not know what Tryton does
…On Wed, Nov 27, 2019, 11:21 Ningú ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In sentry_sdk/integrations/trytond.py
<#548 (comment)>
:
> @@ -0,0 +1,35 @@
+import sentry_sdk
+import sentry_sdk.integrations
+
+from trytond.exceptions import TrytonException # type: ignore
+from trytond.wsgi import app # type: ignore
+
+
+# TODO: trytond-worker, trytond-cron and trytond-admin intergations
+
+
+class TrytondWSGIIntegration(sentry_sdk.integrations.Integration):
I'll check it out and I'll also assert that passwords do not get leaked.
But this also raises a concern about leaking bearer authorization headers,
the default auth mechanism for Tryton APIs. Can we set the integration to
skip those by default?
Also, Tryton has a pluggable auth system so you can easily tweak the
login. It can be used for 2FA with temporary secrets, but the default
password login can be completely overridden by other systems that could
request secrets in arbitrary keys (am I wrong, @cedk
<https://github.com/cedk> ?). I'd vote for completely masking
request/response bodies for the Tryton login endpoint. Is that feasible?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#548?email_source=notifications&email_token=AAGMPRPRK64XVMSLLVY3YHTQVZCZVA5CNFSM4JKV4VSKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCNETNFQ#discussion_r351203929>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGMPRP2AMIUM2DPNATAYEDQVZCZVANCNFSM4JKV4VSA>
.
|
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.
@n1ngu could you open a PR against https://github.com/getsentry/sentry-docs? A good example for adding docs for a new integration is getsentry/sentry-docs#867
I tried to push this but failed bc the PR is not editable for me: diff --git a/sentry_sdk/integrations/trytond.py b/sentry_sdk/integrations/trytond.py
index 152e879..c1a669a 100644
--- a/sentry_sdk/integrations/trytond.py
+++ b/sentry_sdk/integrations/trytond.py
@@ -4,10 +4,14 @@ import sentry_sdk.hub
import sentry_sdk.utils
import sentry_sdk.integrations
import sentry_sdk.integrations.wsgi
+from sentry_sdk._types import MYPY
from trytond.exceptions import TrytonException # type: ignore
from trytond.wsgi import app # type: ignore
+if MYPY:
+ from typing import Any
+
# TODO: trytond-worker, trytond-cron and trytond-admin intergations
@@ -25,12 +29,19 @@ class TrytondWSGIIntegration(sentry_sdk.integrations.Integration):
def error_handler(e): # type: (Exception) -> None
hub = sentry_sdk.hub.Hub.current
+
if hub.get_integration(TrytondWSGIIntegration) is None:
return
elif isinstance(e, TrytonException):
return
else:
- (event, hint) = sentry_sdk.utils.event_from_exception(sys.exc_info())
+ # If an integration is there, a client has to be there.
+ client = hub.client # type: Any
+ event, hint = sentry_sdk.utils.event_from_exception(
+ sys.exc_info(),
+ client_options=client.options,
+ mechanism={"type": "trytond", "handled": False},
+ )
hub.capture_event(event, hint=hint)
# Expected error handlers signature was changed could you apply it manually? |
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.
pending:
- changes as per prev comment need to be applied, otherwise certain
init()
options do not work with this integration - docs
rest lgtm
# If an integration is there, a client has to be there. | ||
client = hub.client # type: Any | ||
event, hint = sentry_sdk.utils.event_from_exception( | ||
e, |
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.
Switched back to build the event from the caught exception instead of sys.exc_info() because it feels more elegant to me. Does using sys.exc_info() have any advantatge I am missing?
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.
Under Python 2 this will cause you to lose the traceback, but it should be fine in this context.
fwiw this is blocked on the doc changes |
My bad. I am aware the ball is in my court. I can only spend here some spare work hours, plus I've been on vacation. But hopefully I'll have the documentation sorted in the short term! |
Gonna get this out and document later |
Sentry SDK integration for the Trytond ERP framework