Skip to content

Commit

Permalink
Add execution time monitoring example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
olzhasar-reef committed Oct 7, 2024
1 parent e5c44ba commit 28fd179
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions {{cookiecutter.repostory_name}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,29 @@ To flush add tasks in specific queue, use

Running the app requires proper certificates to be put into `nginx/monitoring_certs`,
see [nginx/monitoring_certs/README.md](nginx/monitoring_certs/README.md) for more details.

## Monitoring execution time of code blocks

Somewhere, probably in `metrics.py`:

```python
some_calculation_time = prometheus_client.Histogram(
'some_calculation_time',
'How Long it took to calculate something',
namespace='django',
unit='seconds',
labelnames=['task_type_for_example'],
buckets=[0.5, 1, *range(2, 30, 2), *range(30, 75, 5), *range(75, 135, 15)]
)
```

Somewhere else:

```python
with some_calculation_time.labels('blabla').time():
do_some_work()
```

{% endif %}

# Cloud deployment
Expand Down

0 comments on commit 28fd179

Please sign in to comment.