Skip to content

Commit

Permalink
feat: Import tenacity library and use it in cluster_read.py
Browse files Browse the repository at this point in the history
Use it to retry POST requests to Grafana which seems to close/reset
connections under load.

[Tenacity](https://tenacity.readthedocs.io/en/latest/)
  • Loading branch information
pablomh authored and jhutar committed Jan 14, 2024
1 parent 7d9faa5 commit d2c844d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/opl/cluster_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from . import data
from . import date
from tenacity import *


def execute(command):
Expand Down Expand Up @@ -178,6 +179,7 @@ def _sanitize_target(self, target):
target = target.replace("$Cloud", self.args.grafana_prefix)
return target

@retry(stop=(stop_after_delay(10) | stop_after_attempt(10)))
def measure(self, ri, name, grafana_target):
assert (
ri.start is not None and ri.end is not None
Expand Down
1 change: 1 addition & 0 deletions core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"requests",
"tabulate",
"deepdiff",
"tenacity",
],
package_data={
"opl": [
Expand Down
2 changes: 2 additions & 0 deletions opl/cluster_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from . import data
from . import date
from tenacity import *


def execute(command):
Expand Down Expand Up @@ -178,6 +179,7 @@ def _sanitize_target(self, target):
target = target.replace("$Cloud", self.args.grafana_prefix)
return target

@retry(stop=(stop_after_delay(10) | stop_after_attempt(10)))
def measure(self, ri, name, grafana_target):
assert (
ri.start is not None and ri.end is not None
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"requests",
"tabulate",
"deepdiff",
"tenacity",
],
package_data={
"opl": [
Expand Down

0 comments on commit d2c844d

Please sign in to comment.