https://github.com/plughacker/pytelemety
https://github.com/plughacker/pytelemety
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/plughacker/pytelemety
- Owner: plughacker
- Created: 2023-11-01T12:52:34.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-18T18:00:09.000Z (about 2 years ago)
- Last Synced: 2025-04-10T00:38:14.576Z (about 1 year ago)
- Language: Python
- Size: 24.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# pytelemetry
A simple and default open telemetry log formatter
## Quick Start
* Install
```bash
pip install git+https://github.com/plughacker/pytelemety.git@v0.0.1
```
* Create an env var
```
NEW_RELIC_APP_NAME=your_project_name
NEW_RELIC_ENVIRONMENT=development | production | None
SERVICE_VERSION=0.0.1
LOGGER_SAVE_TO_FILE=True | False # When True salve logs in app.
LOGGER_LEVEL=DEBUG
```
or
```
SERVICE_NAME=your_project_name
SERVICE_ENVIRONMENT=development | production | None
SERVICE_VERSION=0.0.1
LOGGER_SAVE_TO_FILE=True | False # When True salve logs in app.log file
```
* Import in your project
```python
from pytelemetry import create_logger
logger = create_logger('My Controller') # returns default python logger
logger.error('division by zero')
```
Output
```json
{"Timestamp": 1698414960, "TraceId": "a0909332-03a7-4ff5-84b1-7373793042ce", "SeverityText": "ERROR", "SeverityNumber": 17, "Body": "division by zero", "Resource": {"service_name": "service_not_named", "service_version": "0.0.1", "service_environment": null}, "InstrumentationScope": "Class or mehtod name", "Attributes": []}
```
[Baseado em](https://github.com/diego-malga/pytelemetry)