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 committed Jan 12, 2024
1 parent 7d9faa5 commit 70d7f91
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/opl/cluster_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
import jinja2.exceptions
import boto3
import urllib3
import tenacity

from . import data
from . import date
from tenacity import retry


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

@retry
def measure(self, ri, name, grafana_target):
assert (
ri.start is not None and ri.end is not None
Expand Down
3 changes: 3 additions & 0 deletions opl/cluster_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
import jinja2.exceptions
import boto3
import urllib3
import tenacity

from . import data
from . import date
from tenacity import retry


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

@retry
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 70d7f91

Please sign in to comment.