Using sentry logging

Has anyone experience in using Sentry logging with Zato.
The current raven version that is included in Zato 3 is quite old. Can it be upgraded without problems?

Another problem is that the default logging on uncaught exceptions from Zato cannot be interpreted properly by Sentry, so there is no error context available in the sentry logs.

Any tips/tricks about Zato - Sentry integration are welcome.

Regards, Jan

Hello @jjmurre,

yes, feel free to update it using pip and post feedback about which version you are using - I will be happy to upgrade it to a newer version for Zato 3.1.

Regards.

Hi @chadical,

Could it be related with this issue?

Zato is gevent based, so maybe using that type of Sentry ‘transport’ could help.

Regards, Jan

Hello @chadical and @jjmurre ,

I will update Raven to the latest version.

As for obtaining a Sentry client in your own code, I would use self.server.user_ctx and self.server.user_ctx_lock.

The former is a process-wide dictionary-like object that can be used for sharing information across services. It is up to users to decide what it should contain, Zato will never use it for anything internally.

Note that there is one user_ctx per one process; thus, if you have one server with four sub-processes, each one will have its own user_ctx.

self.server.user_ctx_lock is a lock object - you can use it, for instance, to serialize write access to the function that creates a Sentry client.

Here is how it can look like

class MyService(Service):

    def _create_sentry_client(self):
        client = create_client()
        self.server.user_ctx['my.sentry.client'] = client

    def before_handle(self):

        # Obtain a Python process-wide lock
        with self.server.user_ctx_lock:

            # Does the client exist already?
            if not self.server.user_ctx.get('my.sentry.client'):
                self._create_sentry_client()

    def handle(self):

        # Here it is guaranteed that the client exists,
        # either because we have just created it in before_handle
        # or because it was already available.
        client = self.server.user_ctx['my.sentry.client']