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 –
TelemetryProfileinstance, 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-releasefor basic OS info, and/etc/timezonefor 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 –
TelemetryProfileinstance. 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 --versionfor 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 –
TelemetryProfileinstance.- 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
SimpleAPIClientand submit all collected data to the configured API endpoint.- Parameters:
profile –
TelemetryProfileinstance.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 thekeyto 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.