Skip to content

docs: pypi-installation on Ubuntu 24.04 and statsd package for event-logging #32891

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/docs/configuration/event-logging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ if desired. Most endpoints hit are logged as
well as key events like query start and end in SQL Lab.

To setup StatsD logging, it’s a matter of configuring the logger in your `superset_config.py`.
If not already present, you need to ensure that the `statsd`-package is installed in Superset's python environment.

```python
from superset.stats_logger import StatsdStatsLogger
Expand Down
18 changes: 10 additions & 8 deletions docs/docs/installation/pypi.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ level dependencies.

**Debian and Ubuntu**

Ubuntu **24.04** uses python 3.12 per default, which currently is not supported by Superset. You need to add a second python installation of 3.11 and install the required additional dependencies.
```bash
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.11 python3.11-dev python3.11-venv build-essential libssl-dev libffi-dev libsasl2-dev libldap2-dev default-libmysqlclient-dev
```

In Ubuntu **20.04 and 22.04** the following command will ensure that the required dependencies are installed:

```bash
Expand Down Expand Up @@ -94,14 +101,9 @@ These will now be available when pip installing requirements.

## Python Virtual Environment

We highly recommend installing Superset inside of a virtual environment. Python ships with
`virtualenv` out of the box. If you're using [pyenv](https://github.com/pyenv/pyenv), you can install [pyenv-virtualenv](https://github.com/pyenv/pyenv-virtualenv). Or you can install it with `pip`:

```bash
pip install virtualenv
```
We highly recommend installing Superset inside of a virtual environment.

You can create and activate a virtual environment using:
You can create and activate a virtual environment using the following commands. Ensure you are using a compatible version of python. You might have to explicitly use for example `python3.11` instead of `python3`.

```bash
# virtualenv is shipped in Python 3.6+ as venv instead of pyvenv.
Expand Down Expand Up @@ -132,7 +134,7 @@ pip install apache-superset

Then, define mandatory configurations, SECRET_KEY and FLASK_APP:
```bash
export SUPERSET_SECRET_KEY=YOUR-SECRET-KEY
export SUPERSET_SECRET_KEY=YOUR-SECRET-KEY # For production use, make sure this is a strong key, for example generated using `openssl rand -base64 42`. See https://superset.apache.org/docs/configuration/configuring-superset#specifying-a-secret_key
export FLASK_APP=superset
```

Expand Down
28 changes: 25 additions & 3 deletions superset/stats_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
import logging
from typing import Optional
from typing import Any, Optional

from colorama import Fore, Style

Expand Down Expand Up @@ -105,5 +105,27 @@
def gauge(self, key: str, value: float) -> None:
self.client.gauge(key, value)

except Exception: # pylint: disable=broad-except # noqa: S110
pass
except Exception as e: # pylint: disable=broad-except # noqa: S110

Check warning on line 108 in superset/stats_logger.py

View check run for this annotation

Codecov / codecov/patch

superset/stats_logger.py#L108

Added line #L108 was not covered by tests
# e can only be accessed in the catch and not later during class instantiation.
# We have to save it to a separate variable.
_saved_exception = e

Check warning on line 111 in superset/stats_logger.py

View check run for this annotation

Codecov / codecov/patch

superset/stats_logger.py#L111

Added line #L111 was not covered by tests

class StatsdStatsLogger(BaseStatsLogger):
def __init__( # pylint: disable=super-init-not-called

Check warning on line 114 in superset/stats_logger.py

View check run for this annotation

Codecov / codecov/patch

superset/stats_logger.py#L113-L114

Added lines #L113 - L114 were not covered by tests
self,
host: str = "localhost",
port: int = 8125,
prefix: str = "superset",
statsd_client: Any = None,
) -> None:
"""
Initializes from either params or a supplied, pre-constructed statsd client.

If statsd_client argument is given, all other arguments are ignored and the
supplied client will be used to emit metrics.

If an exception is raised while creating the StatsdStatsLogger class, for
example because the statsd package is not installed, it will be re-raised
on instantiation of the StatsdStatsLogger.
"""
raise _saved_exception

Check warning on line 131 in superset/stats_logger.py

View check run for this annotation

Codecov / codecov/patch

superset/stats_logger.py#L131

Added line #L131 was not covered by tests
Loading