Metadata-Version: 2.1
Name: lb-telemetry
Version: 0.3.0
Summary: A utility for logging telemetry data from LHCb packages to MONIT
Author-email: Cameron McClymont <cameron.duncan.mcclymont@cern.ch>, Daniel Cervenkov <daniel.cervenkov@cern.ch>, Chris Burr <christopher.burr@cern.ch>
Project-URL: Homepage, https://gitlab.cern.ch/lhcb/lb-telemetry
Project-URL: Bug Tracker, https://gitlab.cern.ch/lhcb/lb-telemetry/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: LbPlatformUtils
Requires-Dist: logzero
Requires-Dist: requests
Provides-Extra: dev
Requires-Dist: mypy ; extra == 'dev'
Requires-Dist: mypy-extensions ; extra == 'dev'
Requires-Dist: pre-commit ; extra == 'dev'
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: ruff ; extra == 'dev'
Requires-Dist: types-requests ; extra == 'dev'

# lb-telemetry

A utility for logging telemetry data about LHCb packages to [MONIT](https://monit.web.cern.ch/).
Usage data graphs specific to each package can be viewed on the [MONIT Grafana](https://monit-grafana.cern.ch/d/Q78h6E-nz/home?orgId=46).

The package is not user-callable. It is intended to be imported and called by other LHCb packages such as [PIDCalib2](https://gitlab.cern.ch/lhcb-rta/pidcalib2).

## Setup

### Installing from PyPI

The package is available on [PyPI](https://pypi.org/project/lb-telemetry/).
It can be installed on any computer via `pip` by running (preferably in a [virtual environment](https://docs.python.org/3/library/venv.html)):
```sh
pip install lb-telemetry
```

## Usage

### Adding to a package

```py
# Time execution (optional)
start_time = time.perf_counter()
do_some_task()
exec_time = time.perf_counter() - start_time

telemetry = {
    "exec_time": exec_time,
    "version": VERSION,
    "some_field": "field_value",
    "some_tag": "tag_value",
}

logger = Logger()
Logger().log_to_monit(
    "NameOfThisPackage",  # Or other readable identifier
    telemetry,
    tags=["version", "some_tag"],
)
```

### Viewing the telemetry

Logged telemetry is usually visible in under a minute and can be accessed via this [Grafana dashboard](https://monit-grafana.cern.ch/d/vQC-V7C4k/lb-telemetry?orgId=46&from=now-30d&to=now). Request permission to edit the dashboard from an LHCb Grafana org admin if necessary. Then create a new row on the dashboard for your package and add the desired graphs.
