From cd3e0d872db6c2f5a190f0d92471683aafce1ea4 Mon Sep 17 00:00:00 2001 From: John Seekins Date: Wed, 6 Sep 2023 13:22:33 -0600 Subject: [PATCH 1/3] support proper influx writes better (victoriametrics doesn't require 'bucket' to be defined) Signed-off-by: John Seekins --- openstates/utils/instrument.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openstates/utils/instrument.py b/openstates/utils/instrument.py index ff9e4ba9b..00bc4de02 100644 --- a/openstates/utils/instrument.py +++ b/openstates/utils/instrument.py @@ -42,12 +42,14 @@ def __init__(self) -> None: self._batch: List[Dict] = list() self.prefix: str = os.environ.get("STATS_PREFIX", "openstates_") self.endpoint: str = os.environ.get("STATS_ENDPOINT", "") + bucket: str = os.environ.get("STATS_BUCKET", "openstates") if self.endpoint.endswith("/"): self.endpoint = self.endpoint.strip("/") client = InfluxDBClient( url=self.endpoint, token=token, org="openstates", + bucket=bucket, enable_gzip=True, ) self.write_api = client.write_api(write_options=SYNCHRONOUS) From 324772df326967b7ce4c87cbaf57d4ae7b0003b7 Mon Sep 17 00:00:00 2001 From: John Seekins Date: Wed, 6 Sep 2023 13:25:00 -0600 Subject: [PATCH 2/3] use bucket correctly Signed-off-by: John Seekins --- openstates/utils/instrument.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openstates/utils/instrument.py b/openstates/utils/instrument.py index 00bc4de02..a9b5b53b1 100644 --- a/openstates/utils/instrument.py +++ b/openstates/utils/instrument.py @@ -42,14 +42,13 @@ def __init__(self) -> None: self._batch: List[Dict] = list() self.prefix: str = os.environ.get("STATS_PREFIX", "openstates_") self.endpoint: str = os.environ.get("STATS_ENDPOINT", "") - bucket: str = os.environ.get("STATS_BUCKET", "openstates") + self.bucket: str = os.environ.get("STATS_BUCKET", "openstates") if self.endpoint.endswith("/"): self.endpoint = self.endpoint.strip("/") client = InfluxDBClient( url=self.endpoint, token=token, org="openstates", - bucket=bucket, enable_gzip=True, ) self.write_api = client.write_api(write_options=SYNCHRONOUS) @@ -90,7 +89,7 @@ def _send_stats(self, force: bool = False) -> None: points.append(p) self.logger.debug(f"Sending stats batch: {self._batch}") try: - self.write_api.write("", record=points) + self.write_api.write(self.bucket, record=points) self._batch = list() except Exception as e: self.logger.warning( From a6d4535951efa07a12ef741ef61b58cde8cd5c49 Mon Sep 17 00:00:00 2001 From: John Seekins Date: Wed, 6 Sep 2023 13:27:33 -0600 Subject: [PATCH 3/3] bump version Signed-off-by: John Seekins --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5dd04e383..5527f9a9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "openstates" -version = "6.17.6" +version = "6.17.7" description = "core infrastructure for the openstates project" authors = ["James Turk "] license = "MIT"