dynatrace-extensions / dt-extensions-python-sdk

Dynatrace Python Extensions SDK
https://dynatrace-extensions.github.io/dt-extensions-python-sdk/
MIT License
8 stars 2 forks source link

Fix issue with the metrics lock, add --no-print-metrics option #39

Closed dlopes7 closed 3 months ago

dlopes7 commented 3 months ago

Some time ago this line:

with self._metrics_lock:

was replaced with this line:

with self._metrics_lock and self._internal_callbacks_results_lock:

This meant that this block was the same as:

with True:

Completely negating the purpose of the lock, and allowing threads to modify the list of metrics while it was being flushed. And even worse, it allowed the list of metrics to be deleted after other threads have added metrics to it.

This fixes the lock.

It also adds the option --no-print-metrics to dt-sdk run, a useful flag to have for extensions that report a large number of metrics.

There is also a fix for the docs build as documented here