semvec/pypi-packages huggingface dataset:
opentelemetry-python-instrumentation-jobs 0.3.2
This is a library that allows you to send metrics and logs of scheduled jobs in python to otel-collector.
License: MIT
Requires Python: <4.0,>=3.9

# opentelemetry-python-instrumentation-jobs
This is a library that allows you to send metrics and logs of scheduled jobs in python to otel-collector.

Tested with python 3.12:
- schedule
- apscheduler

## Installation

```bash
pip install opentelemetry-python-instrumentation-jobs
```

## Usage

```python
from opentelemetry_python_instrumentation_jobs import send_metrics

@send_metrics(job_name="job 1")
def job_1(job_name: str, update_progress: Callable):
    total = 10
    for i in range(total):
        update_progress(1, total)
```

### `send_metrics` decorator

#### parameters:

- `job_name` (string): The name of the job
- `show_progress` (boolean): Whether to show the progress of the job in console(tqdm)

decorator injects `job_name` and `update_progress` parameters to the job function

`update_progress` is a function that takes two parameters:
- processed items count in the iteration (1 or batch size);
- total items count (10 in this example)

You can ignore `job_name` and `update_progress` parameters if you don't need them:

```python
from opentelemetry_python_instrumentation_jobs import send_metrics

@send_metrics(job_name="job 1")
def job_1(*args, **kwargs):
    for i in range(10):
        pass
```

## Environment Variables

- `OTEL_SERVICE_NAME` (string): The name of the service
- `OTEL_EXPORTER_OTLP_ENDPOINT` (string): The endpoint of the otel-collector
- `OTEL_EXPORTER_OTLP_INSECURE` (boolean): Whether to use insecure connection
- `SENDING_LOGS_AND_METRICS_ENABLED` (boolean): Whether to send logs and metrics
- `OTEL_EXPORT_INTERVAL` (int): The interval in milliseconds at which to export metrics

## Full example

```python
import time
import schedule
from opentelemetry_python_instrumentation_jobs import send_metrics

@send_metrics(job_name="job 1")
def job_1(*args, update_progress: Callable, **kwargs):
    total = 20
    update_progress(0, total)
    
    for i in range(total):
        time.sleep(1)
        update_progress(1, total)

@send_metrics(job_name="job 2", show_progress=False)
def job_2(*args, **kwargs): 
    for i in range(10):
        time.sleep(1)

schedule.every(1).minutes.do(job_1)
schedule.every(20).seconds.do(job_2)

while True:
    schedule.run_pending()
    time.sleep(1)
```


## Metrics that are sent

- `${METRIC_PREFIX}_job_run_count` (counter): How many times the job has been run
- `${METRIC_PREFIX}_job_status` (counter): Job counter by status (success, error)
- `${METRIC_PREFIX}_job_duration` (gauge): Job execution duration in seconds
- `${METRIC_PREFIX}_job_records` (gauge): Number of records in job (processed, total)
- `${METRIC_PREFIX}_job_last_status` (gauge): Last job status (1, 0)
- `${METRIC_PREFIX}_job_time` (gauge): Job start and finish time in unix timestamp (started, finished)


### License

MIT License

Copyright (c) 2024 Vano Atabegashvili
Neatlogger 0.1.2
Neat adaptions to the loguru package which wraps logging in python.
License: MIT
Requires Python: >3.9
Keywords: logging

# Neatlogger
[![PyPi Version](https://img.shields.io/pypi/v/neatlogger.svg)](https://pypi.python.org/pypi/neatlogger/)
[![MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/mschroen/neatlogger/blob/main/LICENSE)
[![Issues](https://img.shields.io/github/issues-raw/mschroen/neatlogger.svg?maxAge=25000)](https://github.com/mschroen/neatlogger/issues)  
Neat adaptions to the loguru package which wraps logging in python.

## Idea

This wrapper around loguru shortcuts your way to more simple usage of loggers, especially useful in small, production-ready scripts:
- Provides the shorthand `log` instead of `logger` 
- Provides new levels: `NEW`, `PROGRESS`, `READ`, `WRITE`, `DONE`.
- Formats logger outputs more cleanly, skips unnecessary information.

## Example usage:

```python
from neatlogger import log

log.new("Welcome to my script")
log.trace("Some minor tracing message")
x = 42
log.debug("Let's debug value x={}", x)
log.info("By the way, it's going well so far.")
log.progress("Heavy calculation ahead...")
log.read("Reading in some data...")
log.write("Writing some output file...")
log.warning("Note that writing files could take some time!")
try:
    x / 0
except Exception as e:
    log.error("An error occured: {}", e)
log.success("Yey, found a solution to the problem eventually.")
log.done("")
```

![Example output](https://github.com/mschroen/neatlogger/blob/main/docs/example_output.png)

## Install

```bash
pip install neatlogger
```

Requires:
- loguru
package-scgps-speak 0.1.0
My short description for my project.
License: MIT
Requires Python: >=3.6.0


📦 setup.py (for humans)
=======================

This repo exists to provide [an example setup.py] file, that can be used
to bootstrap your next Python project. It includes some advanced
patterns and best practices for `setup.py`, as well as some
commented–out nice–to–haves.

For example, this `setup.py` provides a `$ python setup.py upload`
command, which creates a *universal wheel* (and *sdist*) and uploads
your package to [PyPi] using [Twine], without the need for an annoying
`setup.cfg` file. It also creates/uploads a new git tag, automatically.

In short, `setup.py` files can be daunting to approach, when first
starting out — even Guido has been heard saying, "everyone cargo cults
thems". It's true — so, I want this repo to be the best place to
copy–paste from :)

[Check out the example!][an example setup.py]

Installation
-----

```bash
cd your_project

# Download the setup.py file:
#  download with wget
wget https://raw.githubusercontent.com/navdeep-G/setup.py/master/setup.py -O setup.py

#  download with curl
curl -O https://raw.githubusercontent.com/navdeep-G/setup.py/master/setup.py
```

To Do
-----

-   Tests via `$ setup.py test` (if it's concise).

Pull requests are encouraged!

More Resources
--------------

-   [What is setup.py?] on Stack Overflow
-   [Official Python Packaging User Guide](https://packaging.python.org)
-   [The Hitchhiker's Guide to Packaging]
-   [Cookiecutter template for a Python package]

License
-------

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any means.

  [an example setup.py]: https://github.com/navdeep-G/setup.py/blob/master/setup.py
  [PyPi]: https://docs.python.org/3/distutils/packageindex.html
  [Twine]: https://pypi.python.org/pypi/twine
  [image]: https://farm1.staticflickr.com/628/33173824932_58add34581_k_d.jpg
  [What is setup.py?]: https://stackoverflow.com/questions/1471994/what-is-setup-py
  [The Hitchhiker's Guide to Packaging]: https://the-hitchhikers-guide-to-packaging.readthedocs.io/en/latest/creation.html
  [Cookiecutter template for a Python package]: https://github.com/audreyr/cookiecutter-pypackage