Metadata-Version: 2.1
Name: lf-metric-emitter
Version: 0.0.3
Author-email: LINCC Frameworks <name@you.com>
License: MIT License
        
        Copyright (c) 2023 LINCC Frameworks
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: pre-commit ; extra == 'dev'
Requires-Dist: sphinx (==6.1.3) ; extra == 'dev'
Requires-Dist: sphinx-rtd-theme (==1.2.0) ; extra == 'dev'
Requires-Dist: sphinx-autoapi (==2.0.1) ; extra == 'dev'
Requires-Dist: black ; extra == 'dev'

# lf-metric-emitter
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/lincc-frameworks/metric-emitter)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/lincc-frameworks/metric-emitter/testing-and-coverage.yml)

This tool encapsulates the code needed to emit metrics to the Sasquatch InfluxDB
stack. https://sasquatch.lsst.io/index.html

To utilize this tool, two environment variables must be set:
1) `BENCHMARK_ENV` should be set to something consistent, for instance, `github-ci`, `epic`, `local-desktop-1`, etc.
2) `KAFKA_API_URL` should be set to the full url. See the Sasquatch documentation for the specific URL.

You'll also need to manually create a Kafka topic to receive the metrics that are
emitted. Again, see the Sasquatch documentation for instructions.

With the Kafka topic created, and the environmental variables, metrics can be emitted like so:

```
# result from a timing bench mark
my_result = 42.0

emitter = Emitter(namespace='lsst.lf',
                 name='ssppIncubator.bench',
                 module='PPApplyColourOffset',
                 benchmark_type:'runtime',
                 benchmark_unit:'s')


emitter.set_value(my_result)
emitter.emit()
```

[![Template](https://img.shields.io/badge/Template-LINCC%20Frameworks%20Python%20Project%20Template-brightgreen)](https://lincc-ppt.readthedocs.io/en/latest/)

This project was automatically generated using the LINCC-Frameworks [python-project-template](https://github.com/lincc-frameworks/python-project-template).

For more information about the project template see the For more information about the project template see the [documentation](https://lincc-ppt.readthedocs.io/en/latest/).
