nucliadb-utils 6.4.0.post4158__py3-none-any.whl → 6.4.0.post4167__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.
- nucliadb_utils/audit/stream.py +3 -2
- nucliadb_utils/cache/nats.py +4 -2
- nucliadb_utils/nats.py +12 -17
- nucliadb_utils/transaction.py +9 -4
- {nucliadb_utils-6.4.0.post4158.dist-info → nucliadb_utils-6.4.0.post4167.dist-info}/METADATA +3 -3
- {nucliadb_utils-6.4.0.post4158.dist-info → nucliadb_utils-6.4.0.post4167.dist-info}/RECORD +8 -8
- {nucliadb_utils-6.4.0.post4158.dist-info → nucliadb_utils-6.4.0.post4167.dist-info}/WHEEL +1 -1
- {nucliadb_utils-6.4.0.post4158.dist-info → nucliadb_utils-6.4.0.post4167.dist-info}/top_level.txt +0 -0
nucliadb_utils/audit/stream.py
CHANGED
@@ -58,9 +58,9 @@ from nucliadb_protos.kb_usage_pb2 import (
|
|
58
58
|
ClientType as ClientTypeKbUsage,
|
59
59
|
)
|
60
60
|
from nucliadb_protos.resources_pb2 import FieldID
|
61
|
+
from nucliadb_telemetry.jetstream import get_traced_jetstream, get_traced_nats_client
|
61
62
|
from nucliadb_utils import logger
|
62
63
|
from nucliadb_utils.audit.audit import AuditStorage
|
63
|
-
from nucliadb_utils.nats import get_traced_jetstream
|
64
64
|
from nucliadb_utils.nuclia_usage.utils.kb_usage_report import KbUsageReportUtility
|
65
65
|
|
66
66
|
|
@@ -207,7 +207,8 @@ class StreamAuditStorage(AuditStorage):
|
|
207
207
|
if len(self.nats_servers) > 0:
|
208
208
|
options["servers"] = self.nats_servers
|
209
209
|
|
210
|
-
|
210
|
+
nc = await nats.connect(**options)
|
211
|
+
self.nc = get_traced_nats_client(nc, self.service)
|
211
212
|
|
212
213
|
self.js = get_traced_jetstream(self.nc, self.service)
|
213
214
|
self.task = asyncio.create_task(self.run())
|
nucliadb_utils/cache/nats.py
CHANGED
@@ -34,6 +34,7 @@ from nats.aio.subscription import Subscription
|
|
34
34
|
from nats.js.client import JetStreamContext
|
35
35
|
from nats.js.manager import JetStreamManager
|
36
36
|
|
37
|
+
from nucliadb_telemetry.jetstream import get_traced_nats_client
|
37
38
|
from nucliadb_utils import logger
|
38
39
|
from nucliadb_utils.cache.pubsub import Callback, PubSubDriver
|
39
40
|
from nucliadb_utils.nats import get_traced_jetstream
|
@@ -91,7 +92,7 @@ class NatsPubsub(PubSubDriver):
|
|
91
92
|
# No asyncio loop to run
|
92
93
|
|
93
94
|
async with self.lock:
|
94
|
-
|
95
|
+
nc = Client()
|
95
96
|
options = {
|
96
97
|
"servers": self._hosts,
|
97
98
|
"disconnected_cb": self.disconnected_cb,
|
@@ -104,11 +105,12 @@ class NatsPubsub(PubSubDriver):
|
|
104
105
|
if self.user_credentials_file is not None:
|
105
106
|
options["user_credentials"] = self.user_credentials_file
|
106
107
|
try:
|
107
|
-
await
|
108
|
+
await nc.connect(**options)
|
108
109
|
except ErrNoServers:
|
109
110
|
logger.exception("No servers found")
|
110
111
|
raise
|
111
112
|
|
113
|
+
self.nc = get_traced_nats_client(nc, "nucliadb_pubsub")
|
112
114
|
logger.info("Connected to nats")
|
113
115
|
|
114
116
|
self.initialized = True
|
nucliadb_utils/nats.py
CHANGED
@@ -33,24 +33,18 @@ from nats.aio.subscription import Subscription
|
|
33
33
|
from nats.js.client import JetStreamContext
|
34
34
|
|
35
35
|
from nucliadb_telemetry.errors import capture_exception
|
36
|
-
from nucliadb_telemetry.jetstream import
|
36
|
+
from nucliadb_telemetry.jetstream import (
|
37
|
+
JetStreamContextTelemetry,
|
38
|
+
NatsClientTelemetry,
|
39
|
+
get_traced_nats_client,
|
40
|
+
)
|
37
41
|
from nucliadb_telemetry.metrics import Counter
|
38
|
-
from nucliadb_telemetry.utils import get_telemetry
|
39
42
|
|
40
43
|
logger = logging.getLogger(__name__)
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
) -> Union[JetStreamContext, JetStreamContextTelemetry]:
|
46
|
-
jetstream = nc.jetstream()
|
47
|
-
tracer_provider = get_telemetry(service_name)
|
48
|
-
|
49
|
-
if tracer_provider is not None and jetstream is not None: # pragma: no cover
|
50
|
-
logger.info(f"Configuring {service_name} jetstream with telemetry")
|
51
|
-
return JetStreamContextTelemetry(jetstream, service_name, tracer_provider)
|
52
|
-
else:
|
53
|
-
return jetstream
|
45
|
+
# Re-export for bw/c. This function was defined here but makes more sense in the
|
46
|
+
# telemetry library
|
47
|
+
from nucliadb_telemetry.jetstream import get_traced_jetstream # noqa
|
54
48
|
|
55
49
|
|
56
50
|
class MessageProgressUpdater:
|
@@ -105,7 +99,7 @@ class MessageProgressUpdater:
|
|
105
99
|
|
106
100
|
|
107
101
|
class NatsConnectionManager:
|
108
|
-
_nc: NATSClient
|
102
|
+
_nc: Union[NATSClient, NatsClientTelemetry]
|
109
103
|
_subscriptions: list[tuple[Subscription, Callable[[], Awaitable[None]]]]
|
110
104
|
_pull_subscriptions: list[
|
111
105
|
tuple[
|
@@ -169,7 +163,8 @@ class NatsConnectionManager:
|
|
169
163
|
options["servers"] = self._nats_servers
|
170
164
|
|
171
165
|
async with self._lock:
|
172
|
-
|
166
|
+
nc = await nats.connect(**options)
|
167
|
+
self._nc = get_traced_nats_client(nc, self._service_name)
|
173
168
|
|
174
169
|
self._expected_subscription_task = asyncio.create_task(self._verify_expected_subscriptions())
|
175
170
|
|
@@ -310,7 +305,7 @@ class NatsConnectionManager:
|
|
310
305
|
logger.info("Connection is closed on NATS")
|
311
306
|
|
312
307
|
@property
|
313
|
-
def nc(self) -> NATSClient:
|
308
|
+
def nc(self) -> Union[NATSClient, NatsClientTelemetry]:
|
314
309
|
return self._nc
|
315
310
|
|
316
311
|
@cached_property
|
nucliadb_utils/transaction.py
CHANGED
@@ -35,10 +35,14 @@ from nucliadb_protos.writer_pb2 import (
|
|
35
35
|
Notification,
|
36
36
|
OpStatusWriter,
|
37
37
|
)
|
38
|
-
from nucliadb_telemetry.jetstream import
|
38
|
+
from nucliadb_telemetry.jetstream import (
|
39
|
+
JetStreamContextTelemetry,
|
40
|
+
NatsClientTelemetry,
|
41
|
+
get_traced_jetstream,
|
42
|
+
get_traced_nats_client,
|
43
|
+
)
|
39
44
|
from nucliadb_utils import const, logger
|
40
45
|
from nucliadb_utils.cache.pubsub import PubSubDriver
|
41
|
-
from nucliadb_utils.nats import get_traced_jetstream
|
42
46
|
from nucliadb_utils.utilities import get_pubsub
|
43
47
|
|
44
48
|
|
@@ -95,7 +99,7 @@ class LocalTransactionUtility:
|
|
95
99
|
|
96
100
|
|
97
101
|
class TransactionUtility:
|
98
|
-
nc: Client
|
102
|
+
nc: Union[Client, NatsClientTelemetry]
|
99
103
|
js: Union[JetStreamContext, JetStreamContextTelemetry]
|
100
104
|
pubsub: PubSubDriver
|
101
105
|
|
@@ -177,7 +181,8 @@ class TransactionUtility:
|
|
177
181
|
if len(self.nats_servers) > 0:
|
178
182
|
options["servers"] = self.nats_servers
|
179
183
|
|
180
|
-
|
184
|
+
nc = await nats.connect(**options)
|
185
|
+
self.nc = get_traced_nats_client(nc, service_name or "nucliadb")
|
181
186
|
self.js = get_traced_jetstream(self.nc, service_name or "nucliadb")
|
182
187
|
|
183
188
|
async def finalize(self):
|
{nucliadb_utils-6.4.0.post4158.dist-info → nucliadb_utils-6.4.0.post4167.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nucliadb_utils
|
3
|
-
Version: 6.4.0.
|
3
|
+
Version: 6.4.0.post4167
|
4
4
|
Summary: NucliaDB util library
|
5
5
|
Author-email: Nuclia <nucliadb@nuclia.com>
|
6
6
|
License: AGPL
|
@@ -27,8 +27,8 @@ Requires-Dist: nats-py[nkeys]>=2.6.0
|
|
27
27
|
Requires-Dist: PyNaCl
|
28
28
|
Requires-Dist: pyjwt>=2.4.0
|
29
29
|
Requires-Dist: mrflagly>=0.2.9
|
30
|
-
Requires-Dist: nucliadb-protos>=6.4.0.
|
31
|
-
Requires-Dist: nucliadb-telemetry>=6.4.0.
|
30
|
+
Requires-Dist: nucliadb-protos>=6.4.0.post4167
|
31
|
+
Requires-Dist: nucliadb-telemetry>=6.4.0.post4167
|
32
32
|
Provides-Extra: cache
|
33
33
|
Requires-Dist: redis>=4.3.4; extra == "cache"
|
34
34
|
Requires-Dist: orjson>=3.6.7; extra == "cache"
|
@@ -7,14 +7,14 @@ nucliadb_utils/exceptions.py,sha256=y_3wk77WLVUtdo-5FtbBsdSkCtK_DsJkdWb5BoPn3qo,
|
|
7
7
|
nucliadb_utils/featureflagging.py,sha256=SYqr31e0_NeOMx6dZgSiDO9VJiV6xxYhM_gWkk8ITTQ,2386
|
8
8
|
nucliadb_utils/grpc.py,sha256=apu0uePnkGHCAT7GRQ9YZfRYyFj26kJ440i8jitbM3U,3314
|
9
9
|
nucliadb_utils/helpers.py,sha256=nPw8yod3hP-pxq80VF8QC36s7ygSg0dBUdfI-LatvCs,1600
|
10
|
-
nucliadb_utils/nats.py,sha256=
|
10
|
+
nucliadb_utils/nats.py,sha256=T5A_pH0koGPNH9IPNPv1LsYGnAS5hnJgN8VuNCqO_p8,15989
|
11
11
|
nucliadb_utils/partition.py,sha256=jBgy4Hu5Iwn4gjbPPcthSykwf-qNx-GcLAIwbzPd1d0,1157
|
12
12
|
nucliadb_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
13
|
nucliadb_utils/run.py,sha256=Es0_Bu5Yc-LWczvwL6gzWqSwC85RjDCk-0oFQAJi9g4,1827
|
14
14
|
nucliadb_utils/settings.py,sha256=RnGhEUvwv6faNqALiqDCivvzNOyyXVBflYh_37uNkow,8193
|
15
15
|
nucliadb_utils/signals.py,sha256=lo_Mk12NIX5Au--3H3WObvDOXq_OMurql2qiC2TnAao,2676
|
16
16
|
nucliadb_utils/store.py,sha256=kQ35HemE0v4_Qg6xVqNIJi8vSFAYQtwI3rDtMsNy62Y,890
|
17
|
-
nucliadb_utils/transaction.py,sha256=
|
17
|
+
nucliadb_utils/transaction.py,sha256=K_eXwbbC_exc1DKqce-eIYkMEwbLISmR4dqVOb8geAo,8051
|
18
18
|
nucliadb_utils/utilities.py,sha256=w4nsdyiFgZVEq5aBhjzVg176UDJNxfhIEfDbEi8bJdA,15604
|
19
19
|
nucliadb_utils/aiopynecone/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
20
20
|
nucliadb_utils/aiopynecone/client.py,sha256=MPyHnDXwhukJr7U3CJh7BpsekfSuOkyM4g5b9LLtzc8,22941
|
@@ -23,10 +23,10 @@ nucliadb_utils/aiopynecone/models.py,sha256=XkNIZx4bxdbVo9zYVn8IRp70q4DWUMWN79yb
|
|
23
23
|
nucliadb_utils/audit/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
24
24
|
nucliadb_utils/audit/audit.py,sha256=QNrohgWcWkO0exDOi-U7wp1YY7s8ezJqJESWGx4KnYM,3493
|
25
25
|
nucliadb_utils/audit/basic.py,sha256=4NX3IkZtTM_F2jD9TGE8-1eoS-hc-_zWwFGYVahGNSs,4141
|
26
|
-
nucliadb_utils/audit/stream.py,sha256=
|
26
|
+
nucliadb_utils/audit/stream.py,sha256=XEY4wRxEPdrwaBtepT2-4fmeNSaCcyhMf4sZjiJVA6A,17261
|
27
27
|
nucliadb_utils/cache/__init__.py,sha256=itSI7dtTwFP55YMX4iK7JzdMHS5CQVUiB1XzQu4UBh8,833
|
28
28
|
nucliadb_utils/cache/exceptions.py,sha256=Zu-O_-0-yctOEgoDGI92gPzWfBMRrpiAyESA62ld6MA,975
|
29
|
-
nucliadb_utils/cache/nats.py,sha256
|
29
|
+
nucliadb_utils/cache/nats.py,sha256=zCZNJ2kxT6L0y-KPwqB7IIRyssVQBTtpKM2-jQslln4,7159
|
30
30
|
nucliadb_utils/cache/pubsub.py,sha256=l8i_RwRf7OPzfmPy-gyn66xgYFs5aHidCIjEaU9VOHE,1654
|
31
31
|
nucliadb_utils/cache/settings.py,sha256=WVeHOE6Re5i4k2hUHdFKfkoL4n83v_Z6UPBK6GHYb8g,1059
|
32
32
|
nucliadb_utils/encryption/__init__.py,sha256=oav6jFOTGgmIen88sdmy-bCK-uj1tyDt2hr7lB2YKik,2690
|
@@ -57,7 +57,7 @@ nucliadb_utils/tests/gcs.py,sha256=MBMzn_UHU5SU6iILuCsB5zU4umhNcaCw_MKrxZhwvOc,4
|
|
57
57
|
nucliadb_utils/tests/local.py,sha256=cxIfPrKuqs5Ef0nbrVYQQAH2mwc4E0iD9bC2sWegS-c,1934
|
58
58
|
nucliadb_utils/tests/nats.py,sha256=RWHjwqq5esuO7OFbP24yYX1cXnpPLcWJwDUdmwCpH28,1897
|
59
59
|
nucliadb_utils/tests/s3.py,sha256=DACUh3HvgH3BchKFZ9R7RFUzsrg3v9A-cxTcXx4nmvA,3734
|
60
|
-
nucliadb_utils-6.4.0.
|
61
|
-
nucliadb_utils-6.4.0.
|
62
|
-
nucliadb_utils-6.4.0.
|
63
|
-
nucliadb_utils-6.4.0.
|
60
|
+
nucliadb_utils-6.4.0.post4167.dist-info/METADATA,sha256=OxK4wMK1RRNHI10gstT-ItclGBL_0bpw66kyqo5-GwU,2205
|
61
|
+
nucliadb_utils-6.4.0.post4167.dist-info/WHEEL,sha256=ooBFpIzZCPdw3uqIQsOo4qqbA4ZRPxHnOH7peeONza0,91
|
62
|
+
nucliadb_utils-6.4.0.post4167.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
|
63
|
+
nucliadb_utils-6.4.0.post4167.dist-info/RECORD,,
|
{nucliadb_utils-6.4.0.post4158.dist-info → nucliadb_utils-6.4.0.post4167.dist-info}/top_level.txt
RENAMED
File without changes
|