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:
profile –
TelemetryProfile
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_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:
profile –
TelemetryProfile
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:
profile –
TelemetryProfile
instance.- Returns:
Data dict similar to the above. May have an
'errors'
key if anything goes wrong.
- 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:
profile –
TelemetryProfile
instance.data – Data dict as obtained by
collect_all_data()
.
- class wuttatell.telemetry.TelemetryProfile(config, key)[source]¶
Represents a configured profile for telemetry submission.
This is a subclass of
WuttaConfigProfile
, and similarly works off thekey
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']
.
- submit_url¶
URL to which collected telemetry data should be submitted.