Skip to content
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

Configure Sentry_SDK #35

Draft
wants to merge 4 commits into
base: ccloud
Choose a base branch
from
Draft

Configure Sentry_SDK #35

wants to merge 4 commits into from

Conversation

sven-rosenzweig
Copy link

@sven-rosenzweig sven-rosenzweig commented Nov 5, 2024

Configure Sentry_SDK

The sentry raven library is long deprecated. The python sentry SDK replaces this library.
To get the same behaviour as with raven (only enable the logging with selected loggers via the Handlers), one has to initialise the SDK but manually configure the Logging integration and set the default levels to None.

Avoiding the sentry configuration in each SAPCC upstream based project (e.g. Neutron or Nova) and furthermore
in each driver, this has is part of the loci build process. During the build a .pth and .py file will be placed in the
site_package path. Within this path, an executable line in a .pth file is run at every Python startup.
In our case, a script configuring sentry if the env variable SENTRY_USE_SDK is
set. As requirements sentry-sdk must be installed.

The sentry raven library is long deprecated. The python sentry SDK replaces this library.
To get the same behaviour as with raven
(only enable the logging with selected loggers via the Handlers), one has to initialise
the SDK but manually configure the Logging integration and set the default levels to None.

Avoiding the sentry configuration in each SAPCC upstream based project (e.g. Neutron or Nova) and furthermore
in each driver, this has is part of the loci build process.
During the build a .pth and .py file will be placed in the
site_package path. Within this path, an executable line in a .pth file is run at every Python startup.
In our case, a script configuring sentry if the env variable SENTRY_USE_SDK is
set. As requirements sentry-sdk must be installed.

Co-authored-by: Florian Streibelt  <[email protected]>
@mutax
Copy link

mutax commented Nov 6, 2024

I got some input from Seba yesterday, I think two things would make sense to add to the ccsentry.py script:

  1. check sys.argv[0] against a whitelist of commands
    • have a list of strings e.g. neutron, agent, ...
    • for each string check if its a substring of argv[0]
  2. add another environment variable to overwrite this list

This would prevent sentry getting enabled with every python process on the target which could otherwise send random logs to sentry, or interfere with debugging maybe. We however need to check if there are some "hidden" argv[0] values if a python subprocess is being created by the agents.

At the same time we could easily modify the list without building a new image, allowing us to add or remove scripts. That should come in handy when other services like nova want to test that approach.

update: added as extra commit.

Moved the ssentry.py to a file in a subdirectory, so it can be editied
in an editor using syntax highlighting, formatting and autopep
allow filtering based on argv[0] to enable only for specific commands
changing the prefix of the variables to clearly distinguish
between the namespace sentry is using and our own variables.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants