nameko / nameko-sentry

Apache License 2.0
28 stars 9 forks source link

Proper way to disable sentry log aggregation on different environments? #8

Closed MrLokans closed 7 years ago

MrLokans commented 7 years ago

Hello there. I have a case when I have a set of configs to be used in different environments (e.g. dev/prod) and I don't want any sentry error handling in the development environment, but if I simply do not fill the required settings in the config - my service will fail to be loaded failing with the following error:

   File "/usr/local/lib/python3.5/site-packages/eventlet/greenthread.py", line 214, in main
     result = function(*args, **kwargs)
   File "/usr/local/lib/python3.5/site-packages/nameko/utils.py", line 176, in call
     return getattr(item, name)(*args, **kwargs)
   File "/usr/local/lib/python3.5/site-packages/nameko_sentry.py", line 13, in setup
     dsn = sentry_config['DSN']
TypeError: 'NoneType' object is not subscriptable

So what is the correct way to enable the Sentry logging only on the specific environemnt? Thank you

MrLokans commented 7 years ago

Perhaps we could have checked the presence of the DSN setting in the configuration file and if it is missing warn the user about the misconfiguration once and do not call raven client methods

mattbennett commented 7 years ago

You can set the value of the DSN to None, i.e.

# config.yaml
SENTRY:
    DSN: null

See the test here -- https://github.com/mattbennett/nameko-sentry/blob/v0.0.3/test_nameko_sentry.py#L109-L118

I see your PR though and agree that we should also cope with a config file that was missing the SENTRY section completely. Thank for the contribution :)

sivabudh commented 4 years ago

I think this has been handled already.