locust-cloud 1.5.0__py3-none-any.whl → 1.5.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
locust_cloud/cloud.py CHANGED
@@ -173,6 +173,13 @@ parser.add_argument(
173
173
  action="store_true",
174
174
  help="Delete a running cluster. Useful if locust-cloud was killed/disconnected or if there was an error.",
175
175
  )
176
+ parser.add_argument(
177
+ "--image-tag",
178
+ type=str,
179
+ env_var="LOCUST_CLOUD_IMAGE_TAG",
180
+ default="latest",
181
+ help=configargparse.SUPPRESS, # overrides the locust-cloud docker image tag. for internal use
182
+ )
176
183
 
177
184
  options, locust_options = parser.parse_known_args()
178
185
  options: Namespace
@@ -289,6 +296,7 @@ def main() -> None:
289
296
  *locust_env_variables,
290
297
  ],
291
298
  "worker_count": worker_count,
299
+ "image_tag": options.image_tag,
292
300
  }
293
301
  headers = {
294
302
  "Authorization": f"Bearer {cognito_client_id_token}",
@@ -99,13 +99,15 @@ class Exporter:
99
99
  def write_samples_to_db(self, samples):
100
100
  try:
101
101
  with self.pool.connection() as conn:
102
- conn.cursor().executemany(
103
- """
104
- INSERT INTO requests (time,run_id,greenlet_id,loadgen,name,request_type,response_time,success,response_length,exception,pid,url,context)
105
- VALUES (%(time)s, %(run_id)s, %(greenlet_id)s, %(loadgen)s, %(name)s, %(request_type)s, %(response_time)s, %(success)s, %(response_length)s, %(exception)s, %(pid)s, %(url)s, %(context)s)
106
- """,
107
- samples,
108
- )
102
+ conn: psycopg.connection.Connection
103
+ with conn.cursor() as cur:
104
+ cur.executemany(
105
+ """
106
+ INSERT INTO requests (time,run_id,greenlet_id,loadgen,name,request_type,response_time,success,response_length,exception,pid,url,context)
107
+ VALUES (%(time)s, %(run_id)s, %(greenlet_id)s, %(loadgen)s, %(name)s, %(request_type)s, %(response_time)s, %(success)s, %(response_length)s, %(exception)s, %(pid)s, %(url)s, %(context)s)
108
+ """,
109
+ samples,
110
+ )
109
111
  except psycopg.Error as error:
110
112
  logging.error("Failed to write samples to Postgresql timescale database: " + repr(error))
111
113
 
@@ -1,6 +1,4 @@
1
- import json
2
1
  import logging
3
- import time
4
2
 
5
3
  from flask import make_response, request
6
4
  from locust_cloud.timescale.queries import queries
@@ -15,20 +13,18 @@ def adapt_timestamp(result):
15
13
  def register_query(environment, pool):
16
14
  @environment.web_ui.app.route("/cloud-stats/<query>", methods=["POST"])
17
15
  def query(query):
18
- print(query)
19
16
  results = []
20
-
21
17
  try:
22
18
  if query and queries[query]:
23
- start_time = time.perf_counter()
19
+ # start_time = time.perf_counter()
24
20
  with pool.connection() as conn:
25
- get_conn_time = (time.perf_counter() - start_time) * 1000
21
+ # get_conn_time = (time.perf_counter() - start_time) * 1000
26
22
  sql_params = request.get_json()
27
- start_time = time.perf_counter()
23
+ # start_time = time.perf_counter()
28
24
  cursor = conn.execute(queries[query], sql_params)
29
- exec_time = (time.perf_counter() - start_time) * 1000
25
+ # exec_time = (time.perf_counter() - start_time) * 1000
30
26
  assert cursor
31
- start_time = time.perf_counter()
27
+ # start_time = time.perf_counter()
32
28
  results = [
33
29
  adapt_timestamp(
34
30
  dict(
@@ -40,16 +36,10 @@ def register_query(environment, pool):
40
36
  )
41
37
  for row in cursor.fetchall()
42
38
  ]
43
- fetch_time = (time.perf_counter() - start_time) * 1000
44
-
45
- logger.info(
46
- f"Executed query '{query}' with params {sql_params}. It took {round(get_conn_time)}+{round(exec_time)}+{round(fetch_time)}ms"
47
- )
48
- try:
49
- json.dumps(results)
50
- except TypeError:
51
- logger.error(f"Could not serialize result: {str(results)[:500]}")
52
- return make_response(f"Could not serialize result: {str(results)[:500]}", 400)
39
+ # fetch_time = (time.perf_counter() - start_time) * 1000
40
+ # logger.info(
41
+ # f"Executed query '{query}' with params {sql_params}. It took {round(get_conn_time)}+{round(exec_time)}+{round(fetch_time)}ms"
42
+ # )
53
43
  return results
54
44
  else:
55
45
  logger.warning(f"Received invalid query key: '{query}'")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: locust-cloud
3
- Version: 1.5.0
3
+ Version: 1.5.2
4
4
  Summary: Locust Cloud
5
5
  Project-URL: Homepage, https://locust.cloud
6
6
  Requires-Python: >=3.11
@@ -1,11 +1,11 @@
1
1
  locust_cloud/__init__.py,sha256=HbH2uFv-zdVS3PeX1D1RmplyXDGe0rWPmVhbQcmJrdY,2613
2
2
  locust_cloud/auth.py,sha256=K57DQ25tfzr97lRbqEH1lz6GITSTXRtXO4JzK4vbVVk,3203
3
- locust_cloud/cloud.py,sha256=mZJxWClcRod596En1vo_rwJAVZ_nWsSY4vmZFR3AAUY,15732
3
+ locust_cloud/cloud.py,sha256=VSXv5EzIIcmkdbMB-YfMIW0fk9EVZooB1vDxvFQURiM,15991
4
4
  locust_cloud/constants.py,sha256=YGgIEnaOT9cAA8F8a8Z8lOmlI78D2fXiVpP0RF213MA,167
5
5
  locust_cloud/credential_manager.py,sha256=JbuS22RTGAmngVB9DFLxHIgaonCSImemMGvtWnxBZRE,5515
6
- locust_cloud/timescale/exporter.py,sha256=iojCxuV9H9yg5O9y3lDdXUq0gOgklUD6JOfV2Pe8hXU,10808
6
+ locust_cloud/timescale/exporter.py,sha256=tx4TPp2gfl0ggA-2CrRTfRlg9ZG1Y31NOXcqiXzqkEw,10921
7
7
  locust_cloud/timescale/queries.py,sha256=TjcmWDB9PZSslnKLbUs3o6R9NZ61zV3BSu36XKNensk,5863
8
- locust_cloud/timescale/query.py,sha256=Aqh-J9v2m2PugRInLT33qrTTf5YChb8Np4BYXOW2xtg,2387
8
+ locust_cloud/timescale/query.py,sha256=Ab3tAZSAeAH2SPBhreVxCNOiVbpq_eKb5xMiCrlsRwk,2078
9
9
  locust_cloud/webui/.eslintrc,sha256=huuuTZNwbBGkhfelEOMhLQ-tgC9OYnnX0DRYgBn83Ig,1146
10
10
  locust_cloud/webui/.gitignore,sha256=i8EHIqDlVm1-Dkvf_GTZmP_Wu99GE7ABfbYzHXOU734,54
11
11
  locust_cloud/webui/.prettierrc,sha256=qZpzAJPlHUQ3--NHYK8WXgc_TlIqq-eoz4pbkTKK3nk,167
@@ -17,7 +17,7 @@ locust_cloud/webui/vite.config.ts,sha256=cqxPMkbwEA3H9mGGbuPulQUhIHCosUqm_1usxzs
17
17
  locust_cloud/webui/yarn.lock,sha256=6BC6sHV1ufQeg1s3HoLHC2SwYs6zEVE-NHVg_1kSuVI,227118
18
18
  locust_cloud/webui/dist/index.html,sha256=ceT6hvFOq5tHWJGjwPVhlfOgvDzj8kJ1SudRmXQBggc,664
19
19
  locust_cloud/webui/dist/assets/index-B-CH83Zq.js,sha256=CbLgdiLRCwxAqGNKyHOQjmll_al3lrXaPPsisboc0S4,2806387
20
- locust_cloud-1.5.0.dist-info/METADATA,sha256=CU3XaOMBy7yHj5BmShOnA87bTEaW6C3za5d3EjDX9vY,1663
21
- locust_cloud-1.5.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
22
- locust_cloud-1.5.0.dist-info/entry_points.txt,sha256=PGyAb4e3aTsGS3N3VGShDl6VzJaXy7QwsEgsLOC7V00,57
23
- locust_cloud-1.5.0.dist-info/RECORD,,
20
+ locust_cloud-1.5.2.dist-info/METADATA,sha256=u1T_pJTb1vBru95DDkZWtOTySjK7WkMgyW7K97ozGKA,1663
21
+ locust_cloud-1.5.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
22
+ locust_cloud-1.5.2.dist-info/entry_points.txt,sha256=PGyAb4e3aTsGS3N3VGShDl6VzJaXy7QwsEgsLOC7V00,57
23
+ locust_cloud-1.5.2.dist-info/RECORD,,