hatchet-sdk 1.10.0__py3-none-any.whl → 1.10.1__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.
Potentially problematic release.
This version of hatchet-sdk might be problematic. Click here for more details.
- hatchet_sdk/__init__.py +5 -1
- hatchet_sdk/clients/dispatcher/action_listener.py +29 -22
- hatchet_sdk/config.py +13 -0
- hatchet_sdk/opentelemetry/instrumentor.py +7 -2
- hatchet_sdk/utils/opentelemetry.py +19 -0
- {hatchet_sdk-1.10.0.dist-info → hatchet_sdk-1.10.1.dist-info}/METADATA +1 -1
- {hatchet_sdk-1.10.0.dist-info → hatchet_sdk-1.10.1.dist-info}/RECORD +9 -8
- {hatchet_sdk-1.10.0.dist-info → hatchet_sdk-1.10.1.dist-info}/WHEEL +0 -0
- {hatchet_sdk-1.10.0.dist-info → hatchet_sdk-1.10.1.dist-info}/entry_points.txt +0 -0
hatchet_sdk/__init__.py
CHANGED
|
@@ -130,7 +130,7 @@ from hatchet_sdk.clients.rest.models.workflow_version_definition import (
|
|
|
130
130
|
WorkflowVersionDefinition,
|
|
131
131
|
)
|
|
132
132
|
from hatchet_sdk.clients.rest.models.workflow_version_meta import WorkflowVersionMeta
|
|
133
|
-
from hatchet_sdk.config import ClientConfig
|
|
133
|
+
from hatchet_sdk.config import ClientConfig, ClientTLSConfig, OpenTelemetryConfig
|
|
134
134
|
from hatchet_sdk.context.context import Context, DurableContext
|
|
135
135
|
from hatchet_sdk.context.worker_context import WorkerContext
|
|
136
136
|
from hatchet_sdk.contracts.workflows_pb2 import (
|
|
@@ -149,6 +149,7 @@ from hatchet_sdk.runnables.types import (
|
|
|
149
149
|
TaskDefaults,
|
|
150
150
|
WorkflowConfig,
|
|
151
151
|
)
|
|
152
|
+
from hatchet_sdk.utils.opentelemetry import OTelAttribute
|
|
152
153
|
from hatchet_sdk.waits import (
|
|
153
154
|
Condition,
|
|
154
155
|
OrGroup,
|
|
@@ -271,4 +272,7 @@ __all__ = [
|
|
|
271
272
|
"BulkCancelReplayOpts",
|
|
272
273
|
"RunFilter",
|
|
273
274
|
"V1TaskStatus",
|
|
275
|
+
"OTelAttribute",
|
|
276
|
+
"OpenTelemetryConfig",
|
|
277
|
+
"ClientTLSConfig",
|
|
274
278
|
]
|
|
@@ -3,7 +3,7 @@ import json
|
|
|
3
3
|
import time
|
|
4
4
|
from dataclasses import field
|
|
5
5
|
from enum import Enum
|
|
6
|
-
from typing import Any, AsyncGenerator, cast
|
|
6
|
+
from typing import TYPE_CHECKING, Any, AsyncGenerator, cast
|
|
7
7
|
|
|
8
8
|
import grpc
|
|
9
9
|
import grpc.aio
|
|
@@ -18,7 +18,6 @@ from hatchet_sdk.clients.events import proto_timestamp_now
|
|
|
18
18
|
from hatchet_sdk.clients.listeners.run_event_listener import (
|
|
19
19
|
DEFAULT_ACTION_LISTENER_RETRY_INTERVAL,
|
|
20
20
|
)
|
|
21
|
-
from hatchet_sdk.config import ClientConfig
|
|
22
21
|
from hatchet_sdk.connection import new_conn
|
|
23
22
|
from hatchet_sdk.contracts.dispatcher_pb2 import ActionType as ActionTypeProto
|
|
24
23
|
from hatchet_sdk.contracts.dispatcher_pb2 import (
|
|
@@ -32,9 +31,14 @@ from hatchet_sdk.contracts.dispatcher_pb2_grpc import DispatcherStub
|
|
|
32
31
|
from hatchet_sdk.logger import logger
|
|
33
32
|
from hatchet_sdk.metadata import get_metadata
|
|
34
33
|
from hatchet_sdk.utils.backoff import exp_backoff_sleep
|
|
34
|
+
from hatchet_sdk.utils.opentelemetry import OTelAttribute
|
|
35
35
|
from hatchet_sdk.utils.proto_enums import convert_proto_enum_to_python
|
|
36
36
|
from hatchet_sdk.utils.typing import JSONSerializableMapping
|
|
37
37
|
|
|
38
|
+
if TYPE_CHECKING:
|
|
39
|
+
from hatchet_sdk.config import ClientConfig
|
|
40
|
+
|
|
41
|
+
|
|
38
42
|
DEFAULT_ACTION_TIMEOUT = 600 # seconds
|
|
39
43
|
DEFAULT_ACTION_LISTENER_RETRY_COUNT = 15
|
|
40
44
|
|
|
@@ -134,32 +138,35 @@ class Action(BaseModel):
|
|
|
134
138
|
except Exception:
|
|
135
139
|
return str(self.action_payload)
|
|
136
140
|
|
|
137
|
-
|
|
138
|
-
def otel_attributes(self) -> dict[str, str | int]:
|
|
141
|
+
def get_otel_attributes(self, config: "ClientConfig") -> dict[str, str | int]:
|
|
139
142
|
try:
|
|
140
143
|
payload_str = json.dumps(self.action_payload.model_dump(), default=str)
|
|
141
144
|
except Exception:
|
|
142
145
|
payload_str = str(self.action_payload)
|
|
143
146
|
|
|
144
|
-
attrs: dict[
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
147
|
+
attrs: dict[OTelAttribute, str | int | None] = {
|
|
148
|
+
OTelAttribute.TENANT_ID: self.tenant_id,
|
|
149
|
+
OTelAttribute.WORKER_ID: self.worker_id,
|
|
150
|
+
OTelAttribute.WORKFLOW_RUN_ID: self.workflow_run_id,
|
|
151
|
+
OTelAttribute.STEP_ID: self.step_id,
|
|
152
|
+
OTelAttribute.STEP_RUN_ID: self.step_run_id,
|
|
153
|
+
OTelAttribute.RETRY_COUNT: self.retry_count,
|
|
154
|
+
OTelAttribute.PARENT_WORKFLOW_RUN_ID: self.parent_workflow_run_id,
|
|
155
|
+
OTelAttribute.CHILD_WORKFLOW_INDEX: self.child_workflow_index,
|
|
156
|
+
OTelAttribute.CHILD_WORKFLOW_KEY: self.child_workflow_key,
|
|
157
|
+
OTelAttribute.ACTION_PAYLOAD: payload_str,
|
|
158
|
+
OTelAttribute.WORKFLOW_NAME: self.job_name,
|
|
159
|
+
OTelAttribute.ACTION_NAME: self.action_id,
|
|
160
|
+
OTelAttribute.GET_GROUP_KEY_RUN_ID: self.get_group_key_run_id,
|
|
161
|
+
OTelAttribute.WORKFLOW_ID: self.workflow_id,
|
|
162
|
+
OTelAttribute.WORKFLOW_VERSION_ID: self.workflow_version_id,
|
|
160
163
|
}
|
|
161
164
|
|
|
162
|
-
return {
|
|
165
|
+
return {
|
|
166
|
+
f"hatchet.{k.value}": v
|
|
167
|
+
for k, v in attrs.items()
|
|
168
|
+
if v and k not in config.otel.excluded_attributes
|
|
169
|
+
}
|
|
163
170
|
|
|
164
171
|
@property
|
|
165
172
|
def key(self) -> ActionKey:
|
|
@@ -185,7 +192,7 @@ def parse_additional_metadata(additional_metadata: str) -> JSONSerializableMappi
|
|
|
185
192
|
|
|
186
193
|
|
|
187
194
|
class ActionListener:
|
|
188
|
-
def __init__(self, config: ClientConfig, worker_id: str) -> None:
|
|
195
|
+
def __init__(self, config: "ClientConfig", worker_id: str) -> None:
|
|
189
196
|
self.config = config
|
|
190
197
|
self.worker_id = worker_id
|
|
191
198
|
|
hatchet_sdk/config.py
CHANGED
|
@@ -6,6 +6,7 @@ from pydantic import Field, field_validator, model_validator
|
|
|
6
6
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
7
7
|
|
|
8
8
|
from hatchet_sdk.token import get_addresses_from_jwt, get_tenant_id_from_jwt
|
|
9
|
+
from hatchet_sdk.utils.opentelemetry import OTelAttribute
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
def create_settings_config(env_prefix: str) -> SettingsConfigDict:
|
|
@@ -37,6 +38,17 @@ class HealthcheckConfig(BaseSettings):
|
|
|
37
38
|
enabled: bool = False
|
|
38
39
|
|
|
39
40
|
|
|
41
|
+
class OpenTelemetryConfig(BaseSettings):
|
|
42
|
+
model_config = create_settings_config(
|
|
43
|
+
env_prefix="HATCHET_CLIENT_OPENTELEMETRY_",
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
excluded_attributes: list[OTelAttribute] = Field(
|
|
47
|
+
default_factory=list,
|
|
48
|
+
description='Note that if specifying this field via an environment variable, the variable must be a valid JSON array. For example: \'["action_name", "action_payload"]\'',
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
40
52
|
DEFAULT_HOST_PORT = "localhost:7070"
|
|
41
53
|
|
|
42
54
|
|
|
@@ -55,6 +67,7 @@ class ClientConfig(BaseSettings):
|
|
|
55
67
|
|
|
56
68
|
tls_config: ClientTLSConfig = Field(default_factory=lambda: ClientTLSConfig())
|
|
57
69
|
healthcheck: HealthcheckConfig = Field(default_factory=lambda: HealthcheckConfig())
|
|
70
|
+
otel: OpenTelemetryConfig = Field(default_factory=lambda: OpenTelemetryConfig())
|
|
58
71
|
|
|
59
72
|
listener_v2_timeout: int | None = None
|
|
60
73
|
grpc_max_recv_message_length: int = Field(
|
|
@@ -27,6 +27,7 @@ except (RuntimeError, ImportError, ModuleNotFoundError):
|
|
|
27
27
|
)
|
|
28
28
|
|
|
29
29
|
import hatchet_sdk
|
|
30
|
+
from hatchet_sdk import ClientConfig
|
|
30
31
|
from hatchet_sdk.clients.admin import (
|
|
31
32
|
AdminClient,
|
|
32
33
|
TriggerWorkflowOptions,
|
|
@@ -148,13 +149,17 @@ class HatchetInstrumentor(BaseInstrumentor): # type: ignore[misc]
|
|
|
148
149
|
If not provided, the global tracer provider will be used.
|
|
149
150
|
:param meter_provider: MeterProvider | None: The OpenTelemetry MeterProvider to use.
|
|
150
151
|
If not provided, a no-op meter provider will be used.
|
|
152
|
+
:param config: ClientConfig | None: The configuration for the Hatchet client. If not provided,
|
|
153
|
+
a default configuration will be used.
|
|
151
154
|
"""
|
|
152
155
|
|
|
153
156
|
def __init__(
|
|
154
157
|
self,
|
|
155
158
|
tracer_provider: TracerProvider | None = None,
|
|
156
159
|
meter_provider: MeterProvider | None = None,
|
|
160
|
+
config: ClientConfig | None = None,
|
|
157
161
|
):
|
|
162
|
+
self.config = config or ClientConfig()
|
|
158
163
|
|
|
159
164
|
self.tracer_provider = tracer_provider or get_tracer_provider()
|
|
160
165
|
self.meter_provider = meter_provider or NoOpMeterProvider()
|
|
@@ -233,7 +238,7 @@ class HatchetInstrumentor(BaseInstrumentor): # type: ignore[misc]
|
|
|
233
238
|
|
|
234
239
|
with self._tracer.start_as_current_span(
|
|
235
240
|
"hatchet.start_step_run",
|
|
236
|
-
attributes=action.
|
|
241
|
+
attributes=action.get_otel_attributes(self.config),
|
|
237
242
|
context=traceparent,
|
|
238
243
|
) as span:
|
|
239
244
|
result = await wrapped(*args, **kwargs)
|
|
@@ -255,7 +260,7 @@ class HatchetInstrumentor(BaseInstrumentor): # type: ignore[misc]
|
|
|
255
260
|
|
|
256
261
|
with self._tracer.start_as_current_span(
|
|
257
262
|
"hatchet.get_group_key_run",
|
|
258
|
-
attributes=action.
|
|
263
|
+
attributes=action.get_otel_attributes(self.config),
|
|
259
264
|
) as span:
|
|
260
265
|
result = await wrapped(*args, **kwargs)
|
|
261
266
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class OTelAttribute(str, Enum):
|
|
5
|
+
ACTION_NAME = "action_name"
|
|
6
|
+
ACTION_PAYLOAD = "action_payload"
|
|
7
|
+
CHILD_WORKFLOW_INDEX = "child_workflow_index"
|
|
8
|
+
CHILD_WORKFLOW_KEY = "child_workflow_key"
|
|
9
|
+
GET_GROUP_KEY_RUN_ID = "get_group_key_run_id"
|
|
10
|
+
PARENT_WORKFLOW_RUN_ID = "parent_workflow_run_id"
|
|
11
|
+
RETRY_COUNT = "retry_count"
|
|
12
|
+
STEP_ID = "step_id"
|
|
13
|
+
STEP_RUN_ID = "step_run_id"
|
|
14
|
+
TENANT_ID = "tenant_id"
|
|
15
|
+
WORKER_ID = "worker_id"
|
|
16
|
+
WORKFLOW_ID = "workflow_id"
|
|
17
|
+
WORKFLOW_NAME = "workflow_name"
|
|
18
|
+
WORKFLOW_RUN_ID = "workflow_run_id"
|
|
19
|
+
WORKFLOW_VERSION_ID = "workflow_version_id"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
hatchet_sdk/__init__.py,sha256=
|
|
1
|
+
hatchet_sdk/__init__.py,sha256=TW5T_It9W79Lfu-QaxMYBXMjYaXQdOpOS6bvYJm6VjQ,10198
|
|
2
2
|
hatchet_sdk/client.py,sha256=7ONBiE29OKQci3Qaz7U5e-WSxO_ohnWq8F-MSgzG2fU,2312
|
|
3
3
|
hatchet_sdk/clients/admin.py,sha256=zV0Tehvq8m-QNdvB_9VHO38nnOtIhKMbQzsgp_E2KU4,16887
|
|
4
|
-
hatchet_sdk/clients/dispatcher/action_listener.py,sha256=
|
|
4
|
+
hatchet_sdk/clients/dispatcher/action_listener.py,sha256=XqWEgST9My-C7UzHRhBB9ppP_gL72KzNfTjrDohzA_E,17917
|
|
5
5
|
hatchet_sdk/clients/dispatcher/dispatcher.py,sha256=IL-hDXG8Lzas9FieVuNr47E_3Gvpc-aL4Xu_l385Vp8,8140
|
|
6
6
|
hatchet_sdk/clients/event_ts.py,sha256=MudFszIb9IcPKQYvBTzcatPkcWEy3nxbAtEQ0_NYxMg,2094
|
|
7
7
|
hatchet_sdk/clients/events.py,sha256=6nfZogeEgXC0Tzq6RDCTVPcBvLBVBlEonlTo-ticfrc,7200
|
|
@@ -227,7 +227,7 @@ hatchet_sdk/clients/rest/models/workflow_workers_count.py,sha256=qhzqfvjjIDyARki
|
|
|
227
227
|
hatchet_sdk/clients/rest/rest.py,sha256=zZHTzgl-NBdcK6XhG23m_s9RKRONGPPItzGe407s7GA,9262
|
|
228
228
|
hatchet_sdk/clients/rest/tenacity_utils.py,sha256=n6QvwuGwinLQpiWNU5GxrDNhFBE8_wZdg3WNur21rJ0,1055
|
|
229
229
|
hatchet_sdk/clients/v1/api_client.py,sha256=mJQUZ3cOxlFJiwWKK5F8jBxcpNZ7A2292HucrBqurbg,1205
|
|
230
|
-
hatchet_sdk/config.py,sha256=
|
|
230
|
+
hatchet_sdk/config.py,sha256=iQFnT8teWiov0c2l1BzByBuzn2fgKOxvMt5Yt33oLsE,5128
|
|
231
231
|
hatchet_sdk/connection.py,sha256=B5gT5NL9BBB5-l9U_cN6pMlraQk880rEYMnqaK_dgL0,2590
|
|
232
232
|
hatchet_sdk/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
233
233
|
hatchet_sdk/context/context.py,sha256=ue6ewQZ_y2k2DQ5fVvCrArV7sI-Q7fpehCkadZvi1vg,9334
|
|
@@ -264,7 +264,7 @@ hatchet_sdk/hatchet.py,sha256=BVWSrKL6GCzarTNAte_r0iWsaBXntxNzrR-syR6qENI,22885
|
|
|
264
264
|
hatchet_sdk/labels.py,sha256=nATgxWE3lFxRTnfISEpoIRLGbMfAZsHF4lZTuG4Mfic,182
|
|
265
265
|
hatchet_sdk/logger.py,sha256=5uOr52T4mImSQm1QvWT8HvZFK5WfPNh3Y1cBQZRFgUQ,333
|
|
266
266
|
hatchet_sdk/metadata.py,sha256=XkRbhnghJJGCdVvF-uzyGBcNaTqpeQ3uiQvNNP1wyBc,107
|
|
267
|
-
hatchet_sdk/opentelemetry/instrumentor.py,sha256=
|
|
267
|
+
hatchet_sdk/opentelemetry/instrumentor.py,sha256=uloBetAQTKjdyCVgNX4x7o9lNiMOF-kzzcW8GbzTQ34,14126
|
|
268
268
|
hatchet_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
269
269
|
hatchet_sdk/rate_limit.py,sha256=TwbCuggiZaWpYuo4mjVLlE-z1OfQ2mRBiVvCSaG3lv4,3919
|
|
270
270
|
hatchet_sdk/runnables/contextvars.py,sha256=6MDocAMmlyiRW37oQ1jyx10tAlJs-xgDjR3xPoPz05g,426
|
|
@@ -274,6 +274,7 @@ hatchet_sdk/runnables/types.py,sha256=5jf1c7_0QVUFh0bcXi4hIiaOdUiyhspU4LltoAFCwl
|
|
|
274
274
|
hatchet_sdk/runnables/workflow.py,sha256=lgN2z9or8E4jgHf6C31Kf1KsTa8_rEtE0AwIqGpNEH8,39926
|
|
275
275
|
hatchet_sdk/token.py,sha256=KjIiInwG5Kqd_FO4BSW1x_5Uc7PFbnzIVJqr50-ZldE,779
|
|
276
276
|
hatchet_sdk/utils/backoff.py,sha256=6B5Rb5nLKw_TqqgpJMYjIBV1PTTtbOMRZCveisVhg_I,353
|
|
277
|
+
hatchet_sdk/utils/opentelemetry.py,sha256=EadD6jy6J_kTBqDukH5ufg7kJA_VF8LLKUd-NpSZoD8,626
|
|
277
278
|
hatchet_sdk/utils/proto_enums.py,sha256=0UybwE3s7TcqmzoQSO8YnhgAKOS8WZXsyPchB8-eksw,1247
|
|
278
279
|
hatchet_sdk/utils/timedelta_to_expression.py,sha256=kwuYZ51JdDdc3h9Sw4vgBFmJBMPkgbGJA4v9uO4_NGk,660
|
|
279
280
|
hatchet_sdk/utils/typing.py,sha256=P6-Nd5K_Hk-VhEkGj6LYki_9ddw05rJtzRA56qGXHag,914
|
|
@@ -516,7 +517,7 @@ hatchet_sdk/worker/runner/runner.py,sha256=CdsWl0l4tFp8Yy35uLsR74jNsBs-fIHiDAJZw
|
|
|
516
517
|
hatchet_sdk/worker/runner/utils/capture_logs.py,sha256=nHRPSiDBqzhObM7i2X7t03OupVFnE7kQBdR2Ckgg-2w,2709
|
|
517
518
|
hatchet_sdk/worker/worker.py,sha256=tFXqyPFR4Cplb4zcuzEpZq0VXLtTJrYh7WB0wNC2lTQ,16106
|
|
518
519
|
hatchet_sdk/workflow_run.py,sha256=ZwH0HLFGFVXz6jbiqSv4w0Om2XuR52Tzzw6LH4y65jQ,2765
|
|
519
|
-
hatchet_sdk-1.10.
|
|
520
|
-
hatchet_sdk-1.10.
|
|
521
|
-
hatchet_sdk-1.10.
|
|
522
|
-
hatchet_sdk-1.10.
|
|
520
|
+
hatchet_sdk-1.10.1.dist-info/METADATA,sha256=ii9Qs9tEXjenj8F3avWio6jPaDv3fnbQfCC2T4A7H78,3636
|
|
521
|
+
hatchet_sdk-1.10.1.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
522
|
+
hatchet_sdk-1.10.1.dist-info/entry_points.txt,sha256=Un_76pcLse-ZGBlwebhQpnTPyQrripeHW8J7qmEpGOk,1400
|
|
523
|
+
hatchet_sdk-1.10.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|