Skip to content

Commit

Permalink
Adds user-facing telemetry submission.
Browse files Browse the repository at this point in the history
By default Pulp systems will now submit anonymous telemetry information
to https://analytics.pulpproject.org/. It documents exactly what is
submitted, and introduces the `TELEMETRY` setting which can be used to
disable anonymous telemetry submission entirely.

closes pulp#3115
  • Loading branch information
bmbouter committed Aug 24, 2022
1 parent f85381e commit 62521d2
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGES/3115.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Introduces anonymous telemetry data posting to `<https://analytics.pulpproject.org/>`_. This is
enabled by default, and can be disabled by setting the ``TELEMETRY`` setting to ``False``. See the
:ref:`telemetry docs <telemetry>` for more info on exactly what is posted along with an example.
41 changes: 41 additions & 0 deletions docs/components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ started and stopped without notifying Pulp.
All necessary information about tasks is stored in Pulp's Postgres database as a single source of
truth. In case your tasking system get's jammed, there is a guide to help :ref:debugging_tasks.


Static Content
--------------

Expand All @@ -100,3 +101,43 @@ Collect all of the static content into place using the ``collectstatic`` command
``DJANGO_SETTINGS_MODULE="pulpcore.app.settings"``. Run ``collectstatic`` as follows::

$ pulpcore-manager collectstatic



.. _telemetry:

Telemetry Collection
--------------------

By default, Pulp installations post anonymous telemetry data every 24 hours which is summarized on
`<https://analytics.pulpproject.org/>`_ and aids in project decision making. This is enabled by
default but can be disabled by setting ``TELEMETRY=False`` in your settings.

Here is the list of exactly what is collected along with an example below:

* The version of Pulp components installed
* The number of worker processes and number of hosts (not hostnames) those workers run on
* The number of content app processes and number of hosts (not hostnames) those content apps run on

An example payload:

.. code-block:: json
{
"systemId": "a6d91458-32e8-4528-b608-b2222ede994e",
"onlineContentApps": {
"processes": 2,
"hosts": 1
},
"onlineWorkers": {
"processes": 2,
"hosts": 1
},
"components": [{
"name": "core",
"version": "3.21.0"
}, {
"name": "file",
"version": "1.12.0"
}]
}
12 changes: 12 additions & 0 deletions docs/configuration/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,15 @@ TASK_DIAGNOSTICS
``/var/tmp/pulp/<task_UUID>/``. This is ``False`` by default.

* memory - the task's max resident set size in MB.


.. _telemetry-setting:

TELEMETRY
^^^^^^^^^

If ``True``, Pulp will anonymously post telemetry information to
`<https://analytics.pulpproject.org/>`_ and aids in project decision making. See the
:ref:`telemetry docs <telemetry>` for more info on exactly what is posted along with an example.

Defaults to ``True``.
2 changes: 2 additions & 0 deletions pulpcore/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@

TASK_DIAGNOSTICS = False

TELEMETRY = True

# HERE STARTS DYNACONF EXTENSION LOAD (Keep at the very bottom of settings.py)
# Read more at https://dynaconf.readthedocs.io/en/latest/guides/django.html
from dynaconf import DjangoDynaconf, Validator # noqa
Expand Down
13 changes: 12 additions & 1 deletion pulpcore/app/tasks/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from google.protobuf.json_format import MessageToJson

from pulpcore.app.apps import pulp_plugin_configs
from pulpcore.app.util import get_telemetry_posting_url
from pulpcore.app.models import SystemID
from pulpcore.app.models.status import ContentAppStatus
from pulpcore.app.models.task import Worker
Expand All @@ -19,6 +18,18 @@
logger = logging.getLogger(__name__)


PRODUCTION_URL = "https://analytics.pulpproject.org/"
DEV_URL = "https://dev.analytics.pulpproject.org/"


def get_telemetry_posting_url():
for app in pulp_plugin_configs():
if ".dev" in app.version:
return DEV_URL

return PRODUCTION_URL


async def _num_hosts(qs):
hosts = set()
items = await sync_to_async(list)(qs.all())
Expand Down
21 changes: 4 additions & 17 deletions pulpcore/app/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@
from pulpcore.app import models
from pulpcore.exceptions.validation import InvalidSignatureError

# a little cache so viewset_for_model doesn't have iterate over every app every time
# a little cache so viewset_for_model doesn't have to iterate over every app every time
_model_viewset_cache = {}

PRODUCTION_URL = "https://analytics.pulpproject.org/"
DEV_URL = "https://dev.analytics.pulpproject.org/"


def get_url(model):
"""
Expand Down Expand Up @@ -249,23 +246,13 @@ def gpg_verify(public_keys, signature, detached_data=None):
return verified


def get_telemetry_posting_url():
for app in pulp_plugin_configs():
if ".dev" in app.version:
return DEV_URL

return PRODUCTION_URL


def configure_telemetry():
url = get_telemetry_posting_url()
task_name = "pulpcore.app.tasks.telemetry.post_telemetry"
dispatch_interval = timedelta(days=1)
name = "Post Anonymous Telemetry Periodically"
# Initially only dev systems send data.
if url == PRODUCTION_URL:
models.TaskSchedule.objects.filter(task_name=task_name).delete()
else:
if settings.TELEMETRY:
models.TaskSchedule.objects.update_or_create(
name=name, defaults={"task_name": task_name, "dispatch_interval": dispatch_interval}
)
else:
models.TaskSchedule.objects.filter(task_name=task_name).delete()

0 comments on commit 62521d2

Please sign in to comment.