Package: thoth-common
A library used in projectThoth. It’s aim is
to provide core utilities for logger setup, manipulation with datetimes and
similar handy helpers. Namely, you can find:operations used for cluster object management (e.g. obtaining logs of pods)operations used for scheduling workload using Argo WorkflowsThoth’s configuration abstraction used for serialization/deserialization of
Thoth’s config file across all the componentsapplication logging setupmanipulation with date and timeInstallationThis project is released onPyPI, so
the latest release can be installed via pip orPipenvas shown below:pipenv install thoth-commonThis library will automatically discover installed packages and enableSentry
integrationsif you use Flask,
SQLAlchemy or AIOHTTP. An exception is for Flask applications, that need to
explicitly installsentry-sdk[flask]due to integrations dependencies.Logging setupTo setup a logger in any of Thoth’s component (component that are namespaced
withthoth), you can simply set an environment variable. The name of
environment variable is constructed from module name. Let’s say you want to
debugthoth.adviser.pipelinemodule, in that case you can set environment
variableTHOTH_LOG_ADVISER_PIPELINE=DEBUGwhich will cause loggersthoth.adviser.pipelineto be set toDEBUGmode. Seelog-levels
documentationfor more info. If a module has underscore in its name, replace it with double
underscore in the environment variable name.To setup a logger that is not introduced by a Thoth’s component, you can setTHOTH_ADJUST_LOGGINGenvironment variable. The format of this environment
variableTHOTH_ADJUST_LOGGINGis a comma separated list where each entry is
made out of a logger name and a corresponding log-level (”DEBUG”,
“INFO”, “WARNING”, “ERROR” as for standard Python’s logging). These
two are delimited by a colon, an example:THOTH_ADJUST_LOGGING="flask:WARNING,alembic.migrations:ERROR"Structured loggingThe library will automatically detect when it is running inside an OpenShift
cluster (based onSTI_SCRIPTS_PATHenvironment variable that is inserted
into the container if build the container was built in an OpenShift cluster),
In such case, the library will setup structured logging suitable for automated
logs aggregation (e.g. automated logs aggregation using the ELK stack). This
behavior can be suppressed by setting environment variableTHOTH_LOGGING_NO_JSON=1.Ignoring reports from a loggerIn some cases it’s expected to turn off reporting of some logger to Sentry. You
can provideTHOTH_SENTRY_IGNORE_LOGGERenvironment variable which holds a
comma separated list of loggers that should be ignored when reporting errors to
Sentry:THOTH_SENTRY_IGNORE_LOGGER="thoth.adviser.resolver,thoth.adviser.run"This is helpful if you want to report errors to users but not to Thoth
application itself.If you want some certain classes of error not to be reported to Sentry, you can
can provideTHOTH_SENTRY_IGNORE_EXCEPTIONenvironment variable which holds
a comma-separated list of exception classes to be ignored when reporting to
Sentry:THOTH_SENTRY_IGNORE_EXCEPTION="connexion.decorators.validation,builtins.ValueError"Remember all builtin exception classes need to be specified as in the same
manner asValueErroris specified above.