nucliadb 6.4.0.post4279__py3-none-any.whl → 6.4.0.post4283__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.
@@ -19,6 +19,7 @@
19
19
  #
20
20
  import asyncio
21
21
  import base64
22
+ import time
22
23
  from contextlib import contextmanager
23
24
  from datetime import datetime, timezone
24
25
  from typing import Optional
@@ -41,6 +42,7 @@ from nucliadb.common.http_clients.processing import (
41
42
  )
42
43
  from nucliadb.common.maindb.driver import Driver
43
44
  from nucliadb.ingest import SERVICE_NAME, logger, logger_activity
45
+ from nucliadb.ingest.consumer.consumer import consumer_observer
44
46
  from nucliadb.ingest.orm.exceptions import ReallyStopPulling
45
47
  from nucliadb.ingest.orm.processor import Processor
46
48
  from nucliadb_protos.writer_pb2 import BrokerMessage, BrokerMessageBlobReference
@@ -52,7 +54,7 @@ from nucliadb_utils.cache.pubsub import PubSubDriver
52
54
  from nucliadb_utils.settings import nuclia_settings
53
55
  from nucliadb_utils.storages.storage import Storage
54
56
  from nucliadb_utils.transaction import MaxTransactionSizeExceededError
55
- from nucliadb_utils.utilities import get_storage, get_transaction_utility
57
+ from nucliadb_utils.utilities import get_storage, get_transaction_utility, pull_subscriber_utilization
56
58
 
57
59
  processing_pending_messages = Gauge("nucliadb_processing_pending_messages")
58
60
 
@@ -309,11 +311,13 @@ class PullV2Worker:
309
311
 
310
312
  logger.debug(f"Resource: {pb.uuid} KB: {pb.kbid} ProcessingID: {pb.processing_id}")
311
313
 
312
- await self.processor.process(
313
- pb,
314
- seq,
315
- transaction_check=False,
316
- )
314
+ source = "writer" if pb.source == pb.MessageSource.WRITER else "processor"
315
+ with consumer_observer({"source": source, "partition": "-1"}):
316
+ await self.processor.process(
317
+ pb,
318
+ seq,
319
+ transaction_check=False,
320
+ )
317
321
 
318
322
  async def loop(self):
319
323
  """
@@ -331,6 +335,7 @@ class PullV2Worker:
331
335
  await asyncio.sleep(10)
332
336
 
333
337
  async def _loop(self):
338
+ usage_metric = pull_subscriber_utilization
334
339
  headers = {}
335
340
  data = None
336
341
  if nuclia_settings.nuclia_service_account is not None:
@@ -346,6 +351,8 @@ class PullV2Worker:
346
351
  async with ProcessingHTTPClient() as processing_http_client:
347
352
  while True:
348
353
  try:
354
+ start_time = time.monotonic()
355
+
349
356
  # The code is only really prepared to pull 1 message at a time. If changing this, review MessageProgressUpdate usage
350
357
  pull = await processing_http_client.pull_v2(ack_tokens=ack_tokens, limit=1)
351
358
  ack_tokens.clear()
@@ -353,10 +360,14 @@ class PullV2Worker:
353
360
  processing_pending_messages.set(0)
354
361
  logger_activity.debug(f"No messages waiting in processing pull")
355
362
  await asyncio.sleep(self.pull_time_empty_backoff)
363
+ usage_metric.inc({"status": "waiting"}, time.monotonic() - start_time)
356
364
  continue
357
365
 
358
- logger.info("Message received from proxy", extra={"seq": [pull.messages[0].seq]})
366
+ received_time = time.monotonic()
367
+ usage_metric.inc({"status": "waiting"}, received_time - start_time)
359
368
  processing_pending_messages.set(pull.pending)
369
+
370
+ logger.info("Message received from proxy", extra={"seq": [pull.messages[0].seq]})
360
371
  try:
361
372
  for message in pull.messages:
362
373
  async with ProcessingPullMessageProgressUpdater(
@@ -365,6 +376,8 @@ class PullV2Worker:
365
376
  with run_in_span(message.headers):
366
377
  await self.handle_message(message.seq, message.payload)
367
378
  ack_tokens.append(message.ack_token)
379
+
380
+ usage_metric.inc({"status": "processing"}, time.monotonic() - received_time)
368
381
  except Exception as e:
369
382
  errors.capture_exception(e)
370
383
  logger.exception("Error while pulling and processing message/s")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nucliadb
3
- Version: 6.4.0.post4279
3
+ Version: 6.4.0.post4283
4
4
  Summary: NucliaDB
5
5
  Author-email: Nuclia <nucliadb@nuclia.com>
6
6
  License: AGPL
@@ -20,11 +20,11 @@ Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Programming Language :: Python :: 3 :: Only
21
21
  Requires-Python: <4,>=3.9
22
22
  Description-Content-Type: text/markdown
23
- Requires-Dist: nucliadb-telemetry[all]>=6.4.0.post4279
24
- Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.4.0.post4279
25
- Requires-Dist: nucliadb-protos>=6.4.0.post4279
26
- Requires-Dist: nucliadb-models>=6.4.0.post4279
27
- Requires-Dist: nidx-protos>=6.4.0.post4279
23
+ Requires-Dist: nucliadb-telemetry[all]>=6.4.0.post4283
24
+ Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.4.0.post4283
25
+ Requires-Dist: nucliadb-protos>=6.4.0.post4283
26
+ Requires-Dist: nucliadb-models>=6.4.0.post4283
27
+ Requires-Dist: nidx-protos>=6.4.0.post4283
28
28
  Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
29
29
  Requires-Dist: nuclia-models>=0.24.2
30
30
  Requires-Dist: uvicorn[standard]
@@ -134,7 +134,7 @@ nucliadb/ingest/consumer/auditing.py,sha256=xK21DIa_ZAiOJVVbnkmT4jgCRGshNGyPyxsq
134
134
  nucliadb/ingest/consumer/consumer.py,sha256=GfdlrNlnt7PWYyk75xtyzn2SHZse7475U4U9q_9jKr0,13711
135
135
  nucliadb/ingest/consumer/materializer.py,sha256=tgD_rDI2twQzcz8kKNiW_L4YIth16IGh9mUfD5wiSD4,3858
136
136
  nucliadb/ingest/consumer/metrics.py,sha256=ji1l_4cKiHJthQd8YNem1ft4iMbw9KThmVvJmLcv3Xg,1075
137
- nucliadb/ingest/consumer/pull.py,sha256=gfdyQ8IMFA_bpGnEpmRB9qmOJywBEwxn7pGYaueZizU,16874
137
+ nucliadb/ingest/consumer/pull.py,sha256=x39G6AcNXSnw_GRPxJfafmD5pehZzMBd6v_f_yrNbUI,17594
138
138
  nucliadb/ingest/consumer/service.py,sha256=WXBN8dY7MlmYWxqQHIbIO7w_SdVJRY1RuHAWlQUXf8o,8852
139
139
  nucliadb/ingest/consumer/shard_creator.py,sha256=w0smEu01FU_2cjZnsfBRNqT_Ntho11X17zTMST-vKbc,4359
140
140
  nucliadb/ingest/consumer/utils.py,sha256=jpX8D4lKzuPCpArQLZeX_Zczq3pfen_zAf8sPJfOEZU,2642
@@ -368,8 +368,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
368
368
  nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
369
369
  nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
370
370
  nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
371
- nucliadb-6.4.0.post4279.dist-info/METADATA,sha256=ISm2mlidMfyHGlEXRXBJcbnPe52rP58sBjj5NLRFf68,4223
372
- nucliadb-6.4.0.post4279.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
373
- nucliadb-6.4.0.post4279.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
374
- nucliadb-6.4.0.post4279.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
375
- nucliadb-6.4.0.post4279.dist-info/RECORD,,
371
+ nucliadb-6.4.0.post4283.dist-info/METADATA,sha256=qNXC_Jl6XRiEVh5KfaC09owsizR7ozLE3OJ2FG_Ygsg,4223
372
+ nucliadb-6.4.0.post4283.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
373
+ nucliadb-6.4.0.post4283.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
374
+ nucliadb-6.4.0.post4283.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
375
+ nucliadb-6.4.0.post4283.dist-info/RECORD,,