wuttatell.telemetry

Telemetry submission handler

class wuttatell.telemetry.TelemetryHandler(config)[source]

Handler for submission of telemetry data

The primary caller interface involves just two methods:

collect_all_data(profile=None)[source]

Collect and return all data pertaining to the given profile.

The profile will determine which types of data to collect, e.g. ('os', 'python'). Corresponding handler methods are then called to collect each type; for instance:

Once all data has been collected, errors are grouped to the top level of the structure.

Parameters:

profileTelemetryProfile instance, or key thereof. If not specified, 'default' is assumed.

Returns:

A dict of data, keyed by collection type. If any errors were encountered during collection, the dict will also have an 'errors' key.

collect_data_black(profile)[source]

Collect basic data about the black command, if present.

The black executable is assumed to be found in PATH; if so then black --version is called to get the result:

{
    "executable": "/usr/local/bin/black",
    "release_full": ("black, 25.1.0 (compiled: yes)\n"
                     "Python (CPython) 3.13.5"),
    "release_version": "25.1.0",
}
Parameters:

profileTelemetryProfile instance.

Returns:

Data dict similar to the above. May have an 'errors' key if anything goes wrong.

collect_data_borg(profile)[source]

Collect basic data about the Borg backup command, if present.

The borg executable is assumed to be found in PATH; if so then borg --version is called to get the result:

{
    "executable": "/usr/local/bin/borg",
    "release_version": "1.4.5",
}
Parameters:

profileTelemetryProfile instance.

Returns:

Data dict similar to the above. May have an 'errors' key if anything goes wrong.

collect_data_os(profile, **kwargs)[source]

Collect basic data about the operating system.

This parses /etc/os-release for basic OS info, and /etc/timezone for the timezone.

If all goes well the result looks like:

{
    "release_id": "debian",
    "release_version": "12",
    "release_full": "Debian GNU/Linux 12 (bookworm)",
    "timezone": "America/Chicago",
}
Parameters:

profileTelemetryProfile instance. Note that the default logic here ignores the profile.

Returns:

Data dict similar to the above. May have an 'errors' key if anything goes wrong.

collect_data_python(profile)[source]

Collect basic data about the Python environment.

This primarily runs python --version for the desired environment. Note that the profile will determine which environment to inspect, e.g. system-wide or a specific virtual environment.

If all goes well the system-wide result looks like:

{
    "executable": "/usr/bin/python3",
    "release_full": "Python 3.11.2",
    "release_version": "3.11.2",
}

If a virtual environment is involved the result will include its root path:

{
    "envroot": "/srv/envs/poser",
    "executable": "/srv/envs/poser/bin/python",
    "release_full": "Python 3.11.2",
    "release_version": "3.11.2",
}
Parameters:

profileTelemetryProfile instance.

Returns:

Data dict similar to the above. May have an 'errors' key if anything goes wrong.

get_all_profile_keys()[source]

Retrieve list of all configured profile keys.

This will iterate over defined config values from file(s) only (will not read DB settings), and parse each option name to determine the set of unique profile names.

Returns:

Sorted list of profile keys. If default is included, it will always be first in the list.

submit_all_data(profile=None, data=None)[source]

Submit telemetry data to the configured collection service.

Default logic will use SimpleAPIClient and submit all collected data to the configured API endpoint.

Parameters:
class wuttatell.telemetry.TelemetryProfile(config, key)[source]

Represents a configured profile for telemetry submission.

This is a subclass of WuttaConfigProfile, and similarly works off the key to identify each configured profile.

Upon construction each profile instance will have the following attributes, determined by config:

collect_keys

List of keys identifying the types of data to collect, e.g. ["os", "python", "borg"].

submit_url

URL to which collected telemetry data should be submitted.