temporal-flowrensic-python-sdk 0.6.63__tar.gz

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.
Files changed (55) hide show
  1. temporal_flowrensic_python_sdk-0.6.63/LICENSE +202 -0
  2. temporal_flowrensic_python_sdk-0.6.63/PKG-INFO +74 -0
  3. temporal_flowrensic_python_sdk-0.6.63/README.md +61 -0
  4. temporal_flowrensic_python_sdk-0.6.63/pyproject.toml +23 -0
  5. temporal_flowrensic_python_sdk-0.6.63/pyproject.toml.orig +23 -0
  6. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/__init__.py +2 -0
  7. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_calls.py +185 -0
  8. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_ci.py +56 -0
  9. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_deploy.py +65 -0
  10. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/activity_metrics_pb2.py +76 -0
  11. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/activity_metrics_pb2.pyi +301 -0
  12. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/catalog_pb2.py +60 -0
  13. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/catalog_pb2.pyi +127 -0
  14. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/catch_up_pb2.py +42 -0
  15. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/catch_up_pb2.pyi +71 -0
  16. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/client_calls_pb2.py +49 -0
  17. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/client_calls_pb2.pyi +90 -0
  18. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/cost_pb2.py +52 -0
  19. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/cost_pb2.pyi +107 -0
  20. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/deploy_pb2.py +51 -0
  21. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/deploy_pb2.pyi +92 -0
  22. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/ephemeral_run_pb2.py +107 -0
  23. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/ephemeral_run_pb2.pyi +344 -0
  24. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/finding_pb2.py +76 -0
  25. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/finding_pb2.pyi +371 -0
  26. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/job_pb2.py +46 -0
  27. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/job_pb2.pyi +51 -0
  28. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/load_pb2.py +51 -0
  29. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/load_pb2.pyi +118 -0
  30. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/page_pb2.py +38 -0
  31. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/page_pb2.pyi +23 -0
  32. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/remediation_pb2.py +60 -0
  33. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/remediation_pb2.pyi +157 -0
  34. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/replay_pb2.py +84 -0
  35. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/replay_pb2.pyi +309 -0
  36. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/server_config_pb2.py +48 -0
  37. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/server_config_pb2.pyi +97 -0
  38. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/services_connect.py +3621 -0
  39. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/services_pb2.py +60 -0
  40. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/services_pb2.pyi +20 -0
  41. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/stored_data_pb2.py +43 -0
  42. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/stored_data_pb2.pyi +50 -0
  43. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/workflow_history_pb2.py +47 -0
  44. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/workflow_history_pb2.pyi +102 -0
  45. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/workflow_types_pb2.py +55 -0
  46. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_gen/flowrensic/v1/workflow_types_pb2.pyi +197 -0
  47. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_names.py +42 -0
  48. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_queries.py +61 -0
  49. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_replay.py +378 -0
  50. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_sink.py +574 -0
  51. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/_telemetry.py +559 -0
  52. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/activity.py +136 -0
  53. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/client.py +166 -0
  54. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/py.typed +0 -0
  55. temporal_flowrensic_python_sdk-0.6.63/src/temporal_flowrensic/workflow.py +103 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,74 @@
1
+ Metadata-Version: 2.4
2
+ Name: temporal-flowrensic-python-sdk
3
+ Version: 0.6.63
4
+ Summary: Connects a Temporal Python worker to Flowrensic.
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Requires-Dist: temporalio>=1.18.1
8
+ Requires-Dist: connect-python>=0.9.0
9
+ Requires-Dist: protobuf>=6.31.1,<8
10
+ Requires-Python: >=3.10
11
+ Project-URL: Homepage, https://flowrensic.com
12
+ Description-Content-Type: text/markdown
13
+
14
+ # Flowrensic Python SDK
15
+
16
+ Pre-release. This package is an early preview and not ready for production. Its API can change in any version.
17
+
18
+ Flowrensic is a platform that runs beside Temporal. It watches what your workflows and workers do and tells you what went wrong, before and after a deploy.
19
+
20
+ ## What it does today
21
+
22
+ - Connects a Temporal Python worker to your Flowrensic server, with your env access key, so the worker shows up in Flowrensic. Call temporal_flowrensic.client.connect.
23
+ - Every call to Flowrensic carries your env, its access key and the ephemeral run in the headers Flowrensic-Current-Env, Flowrensic-Env-Access-Key and Flowrensic-Current-Ephemeral-Run. Each part takes them as current_env, env_access_key and current_ephemeral_run. An env of kind ephemeral takes the ephemeral run, such as the CI build number, and without one the run is default. The SDK reads no environment variable: you pass the values in code.
24
+ - Records each activity attempt: its result, error type, attempt number and time, with the timeouts and retry limit it ran under. Register temporal_flowrensic.activity.Interceptor in Worker(interceptors=[...]) and give it a sink from temporal_flowrensic.client.create_attempt_sink. Each attempt carries the namespace Temporal gives the activity, so there is no namespace setting. It never changes what an activity returns or raises.
25
+ - The sink keeps the attempts in the worker's memory and sends them to Flowrensic in batches, in the background. Each send has a time limit. When Flowrensic does not answer, the attempts wait and are sent again later. The buffer has a limit on records and on memory, and past it the oldest are dropped and counted.
26
+
27
+ ```python
28
+ import temporal_flowrensic.activity
29
+ import temporal_flowrensic.client
30
+
31
+ sink = temporal_flowrensic.client.create_attempt_sink(
32
+ "http://flowrensic:8080", current_env="prod", env_access_key=env_access_key, current_ephemeral_run="prod-1",
33
+ worker_name="orders-worker",
34
+ )
35
+ worker = Worker(
36
+ client,
37
+ task_queue="main",
38
+ workflows=[...],
39
+ activities=[...],
40
+ interceptors=[temporal_flowrensic.activity.Interceptor(sink, current_env="prod", current_ephemeral_run="prod-1", version=build_id)],
41
+ )
42
+ ```
43
+
44
+ - Worker telemetry: temporal_flowrensic.client.start_telemetry says hello, then sends regular beats so Flowrensic knows the worker is up, the engine's and the worker's own metrics, and the history of each run the worker saw. At shutdown it hands the ephemeral run over. When Flowrensic does not answer, the worker still starts and keeps trying in the background. Give telemetry.sink to the activity interceptor.
45
+
46
+ ```python
47
+ telemetry = await temporal_flowrensic.client.start_telemetry(
48
+ server_base_url="http://flowrensic:8080",
49
+ current_env="prod",
50
+ env_access_key=env_access_key,
51
+ current_ephemeral_run="prod-1",
52
+ version=build_id,
53
+ namespace="default",
54
+ temporal_client=client,
55
+ )
56
+ interceptor = temporal_flowrensic.activity.Interceptor(telemetry.sink, current_env="prod", current_ephemeral_run="prod-1", version=build_id)
57
+ # ... run the worker ...
58
+ await telemetry.shutdown()
59
+ ```
60
+
61
+ - Client calls: temporal_flowrensic.client.ClientInterceptor in Client.connect(plugins=[...]) sends every query and signal that fails, and whether it ended on its deadline, under the namespace of the client. temporal_flowrensic.workflow.Interceptor in Worker(interceptors=[...]) counts the queries your workflows answer. Neither changes what a call returns or raises, or what a workflow does.
62
+
63
+ - Replay before deploy: in CI, temporal_flowrensic.client.fetch_replay_set writes the histories Flowrensic picks for a workflow type from each env of replay_history_from_envs, such as ["prod", "staging"], asked as your current_env, which must be of kind ephemeral, since a persistent env is refused, you replay them with temporalio's Replayer, and temporal_flowrensic.client.publish_verdicts sends the result back, with the names of the workflow interceptors the replay ran with, as temporal_flowrensic.client.interceptor_name gives them. Give the same interceptors to start_telemetry, so Flowrensic can compare the two lists.
64
+ - Deploy reports from CI: temporal_flowrensic.client.report_deploy_stage sends each stage of a deploy. Every CI call has a time limit and stops with a message that says Flowrensic could not be reached or what it answered. A failed deploy report does not fail the job unless you ask it to.
65
+
66
+ ## Planned
67
+
68
+ - Each new part of the Node SDK, @flowrensic/temporal-flowrensic-node-sdk, comes to the Python SDK too.
69
+
70
+ ## Install
71
+
72
+ ```sh
73
+ pip install temporal-flowrensic-python-sdk
74
+ ```
@@ -0,0 +1,61 @@
1
+ # Flowrensic Python SDK
2
+
3
+ Pre-release. This package is an early preview and not ready for production. Its API can change in any version.
4
+
5
+ Flowrensic is a platform that runs beside Temporal. It watches what your workflows and workers do and tells you what went wrong, before and after a deploy.
6
+
7
+ ## What it does today
8
+
9
+ - Connects a Temporal Python worker to your Flowrensic server, with your env access key, so the worker shows up in Flowrensic. Call temporal_flowrensic.client.connect.
10
+ - Every call to Flowrensic carries your env, its access key and the ephemeral run in the headers Flowrensic-Current-Env, Flowrensic-Env-Access-Key and Flowrensic-Current-Ephemeral-Run. Each part takes them as current_env, env_access_key and current_ephemeral_run. An env of kind ephemeral takes the ephemeral run, such as the CI build number, and without one the run is default. The SDK reads no environment variable: you pass the values in code.
11
+ - Records each activity attempt: its result, error type, attempt number and time, with the timeouts and retry limit it ran under. Register temporal_flowrensic.activity.Interceptor in Worker(interceptors=[...]) and give it a sink from temporal_flowrensic.client.create_attempt_sink. Each attempt carries the namespace Temporal gives the activity, so there is no namespace setting. It never changes what an activity returns or raises.
12
+ - The sink keeps the attempts in the worker's memory and sends them to Flowrensic in batches, in the background. Each send has a time limit. When Flowrensic does not answer, the attempts wait and are sent again later. The buffer has a limit on records and on memory, and past it the oldest are dropped and counted.
13
+
14
+ ```python
15
+ import temporal_flowrensic.activity
16
+ import temporal_flowrensic.client
17
+
18
+ sink = temporal_flowrensic.client.create_attempt_sink(
19
+ "http://flowrensic:8080", current_env="prod", env_access_key=env_access_key, current_ephemeral_run="prod-1",
20
+ worker_name="orders-worker",
21
+ )
22
+ worker = Worker(
23
+ client,
24
+ task_queue="main",
25
+ workflows=[...],
26
+ activities=[...],
27
+ interceptors=[temporal_flowrensic.activity.Interceptor(sink, current_env="prod", current_ephemeral_run="prod-1", version=build_id)],
28
+ )
29
+ ```
30
+
31
+ - Worker telemetry: temporal_flowrensic.client.start_telemetry says hello, then sends regular beats so Flowrensic knows the worker is up, the engine's and the worker's own metrics, and the history of each run the worker saw. At shutdown it hands the ephemeral run over. When Flowrensic does not answer, the worker still starts and keeps trying in the background. Give telemetry.sink to the activity interceptor.
32
+
33
+ ```python
34
+ telemetry = await temporal_flowrensic.client.start_telemetry(
35
+ server_base_url="http://flowrensic:8080",
36
+ current_env="prod",
37
+ env_access_key=env_access_key,
38
+ current_ephemeral_run="prod-1",
39
+ version=build_id,
40
+ namespace="default",
41
+ temporal_client=client,
42
+ )
43
+ interceptor = temporal_flowrensic.activity.Interceptor(telemetry.sink, current_env="prod", current_ephemeral_run="prod-1", version=build_id)
44
+ # ... run the worker ...
45
+ await telemetry.shutdown()
46
+ ```
47
+
48
+ - Client calls: temporal_flowrensic.client.ClientInterceptor in Client.connect(plugins=[...]) sends every query and signal that fails, and whether it ended on its deadline, under the namespace of the client. temporal_flowrensic.workflow.Interceptor in Worker(interceptors=[...]) counts the queries your workflows answer. Neither changes what a call returns or raises, or what a workflow does.
49
+
50
+ - Replay before deploy: in CI, temporal_flowrensic.client.fetch_replay_set writes the histories Flowrensic picks for a workflow type from each env of replay_history_from_envs, such as ["prod", "staging"], asked as your current_env, which must be of kind ephemeral, since a persistent env is refused, you replay them with temporalio's Replayer, and temporal_flowrensic.client.publish_verdicts sends the result back, with the names of the workflow interceptors the replay ran with, as temporal_flowrensic.client.interceptor_name gives them. Give the same interceptors to start_telemetry, so Flowrensic can compare the two lists.
51
+ - Deploy reports from CI: temporal_flowrensic.client.report_deploy_stage sends each stage of a deploy. Every CI call has a time limit and stops with a message that says Flowrensic could not be reached or what it answered. A failed deploy report does not fail the job unless you ask it to.
52
+
53
+ ## Planned
54
+
55
+ - Each new part of the Node SDK, @flowrensic/temporal-flowrensic-node-sdk, comes to the Python SDK too.
56
+
57
+ ## Install
58
+
59
+ ```sh
60
+ pip install temporal-flowrensic-python-sdk
61
+ ```
@@ -0,0 +1,23 @@
1
+ [project]
2
+ name = "temporal-flowrensic-python-sdk"
3
+ version = "0.6.63"
4
+ description = "Connects a Temporal Python worker to Flowrensic."
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.10"
9
+ dependencies = [
10
+ "temporalio>=1.18.1",
11
+ "connect-python>=0.9.0",
12
+ "protobuf>=6.31.1,<8",
13
+ ]
14
+
15
+ [project.urls]
16
+ Homepage = "https://flowrensic.com"
17
+
18
+ [build-system]
19
+ requires = ["uv_build>=0.11.0,<0.14"]
20
+ build-backend = "uv_build"
21
+
22
+ [tool.uv.build-backend]
23
+ module-name = "temporal_flowrensic"
@@ -0,0 +1,23 @@
1
+ [project]
2
+ name = "temporal-flowrensic-python-sdk"
3
+ version = "0.6.63"
4
+ description = "Connects a Temporal Python worker to Flowrensic."
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.10"
9
+ dependencies = [
10
+ "temporalio>=1.18.1",
11
+ "connect-python>=0.9.0",
12
+ "protobuf>=6.31.1,<8",
13
+ ]
14
+
15
+ [project.urls]
16
+ Homepage = "https://flowrensic.com"
17
+
18
+ [build-system]
19
+ requires = ["uv_build>=0.11.0,<0.14"]
20
+ build-backend = "uv_build"
21
+
22
+ [tool.uv.build-backend]
23
+ module-name = "temporal_flowrensic"
@@ -0,0 +1,2 @@
1
+ """Flowrensic for Temporal Python workers. The parts follow temporalio:
2
+ temporal_flowrensic.activity, temporal_flowrensic.client and temporal_flowrensic.workflow."""
@@ -0,0 +1,185 @@
1
+ """The client interceptor: every query and signal of a temporalio Client that
2
+ raises is sent to Flowrensic, through the record buffer."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import time
7
+ from typing import Any, Optional
8
+
9
+ import temporalio.client
10
+ import temporalio.service
11
+ from temporalio.service import RPCError, RPCStatusCode
12
+
13
+ from temporal_flowrensic._gen.flowrensic.v1.client_calls_pb2 import (
14
+ CLIENT_CALL_OUTCOME_FAILED,
15
+ CLIENT_CALL_OUTCOME_TIMED_OUT,
16
+ ClientCall,
17
+ IngestClientCallsRequest,
18
+ )
19
+ from temporal_flowrensic._sink import (
20
+ DEFAULT_BATCH_SIZE,
21
+ DEFAULT_FLUSH_INTERVAL,
22
+ DEFAULT_MAX_BATCH_SIZE,
23
+ DEFAULT_MAX_WAITING,
24
+ DEFAULT_MAX_WAITING_BYTES,
25
+ DEFAULT_TIMEOUT_MS,
26
+ BufferTarget,
27
+ RecordSink,
28
+ SendId,
29
+ SinkCounts,
30
+ ingest_client_sync,
31
+ client_headers,
32
+ )
33
+
34
+ __all__ = ["ClientInterceptor"]
35
+
36
+
37
+ # The error type Flowrensic knows a query by that a worker answered with an
38
+ # error, the name the TypeScript client gives it. The Python client raises
39
+ # WorkflowQueryFailedError for the same case.
40
+ _ANSWERED_QUERY_ERROR = "QueryNotRegisteredError"
41
+
42
+
43
+ def _error_type(err: BaseException) -> str:
44
+ if isinstance(err, temporalio.client.WorkflowQueryFailedError):
45
+ return _ANSWERED_QUERY_ERROR
46
+ return type(err).__name__
47
+
48
+
49
+ def _timed_out(err: BaseException) -> bool:
50
+ """Whether the call ended on its deadline: deadline exceeded, or cancelled by the server."""
51
+ return isinstance(err, RPCError) and err.status in (RPCStatusCode.DEADLINE_EXCEEDED, RPCStatusCode.CANCELLED)
52
+
53
+
54
+ class _CallTarget(BufferTarget[ClientCall]):
55
+ def __init__(self, server_base_url: str, headers: dict[str, str]) -> None:
56
+ self._ingest = ingest_client_sync(server_base_url)
57
+ self._headers = headers
58
+
59
+ def send(self, records: list[ClientCall], timeout_ms: int, id: SendId) -> None:
60
+ self._ingest.ingest_client_calls(
61
+ IngestClientCallsRequest(calls=records, sender=id.sender, send_number=id.send_number),
62
+ headers=self._headers,
63
+ timeout_ms=max(1, timeout_ms),
64
+ )
65
+
66
+
67
+ # The namespace a temporalio Client talks to when it is given none.
68
+ _DEFAULT_NAMESPACE = "default"
69
+
70
+
71
+ class ClientInterceptor(temporalio.client.Interceptor, temporalio.client.Plugin):
72
+ """Put in Client.connect(plugins=[...]). Every query and signal that
73
+ raises is sent to Flowrensic with its name, the workflow it was for and
74
+ whether it ended on its deadline. A call that works is not sent. The calls
75
+ wait in a buffer and leave in batches, as the attempts of the worker do,
76
+ so sending never changes what the caller gets or how long it waits. Call
77
+ close before the process ends, so the calls still waiting are sent.
78
+
79
+ As a client plugin it reads the namespace of the client and puts itself in
80
+ the interceptors of the client, so each call is sent under the namespace
81
+ the client talks to. current_env, env_access_key and current_ephemeral_run
82
+ go in their headers on every send. Times are in seconds."""
83
+
84
+ def __init__(
85
+ self,
86
+ server_base_url: str,
87
+ *,
88
+ current_env: str = "",
89
+ env_access_key: str = "",
90
+ current_ephemeral_run: str = "",
91
+ batch_size: int = DEFAULT_BATCH_SIZE,
92
+ flush_interval: float = DEFAULT_FLUSH_INTERVAL,
93
+ timeout_ms: int = DEFAULT_TIMEOUT_MS,
94
+ max_waiting: int = DEFAULT_MAX_WAITING,
95
+ max_batch_size: int = DEFAULT_MAX_BATCH_SIZE,
96
+ max_waiting_bytes: int = DEFAULT_MAX_WAITING_BYTES,
97
+ ) -> None:
98
+ if not server_base_url:
99
+ raise ValueError("flowrensic: server_base_url is required")
100
+ self._namespace = _DEFAULT_NAMESPACE
101
+ self._next_plugin: Optional[temporalio.client.Plugin] = None
102
+ self._buffer: RecordSink[ClientCall] = RecordSink(
103
+ _CallTarget(server_base_url, client_headers(current_env, env_access_key, current_ephemeral_run)),
104
+ batch_size=batch_size,
105
+ flush_interval=flush_interval,
106
+ timeout_ms=timeout_ms,
107
+ max_waiting=max_waiting,
108
+ max_batch_size=max_batch_size,
109
+ max_waiting_bytes=max_waiting_bytes,
110
+ )
111
+
112
+ def intercept_client(self, next: temporalio.client.OutboundInterceptor) -> temporalio.client.OutboundInterceptor:
113
+ return _ClientOutbound(next, self)
114
+
115
+ def init_client_plugin(self, next: temporalio.client.Plugin) -> None:
116
+ """Keeps the next plugin, for the temporalio versions that chain them."""
117
+ self._next_plugin = next
118
+
119
+ def configure_client(self, config: Any) -> Any:
120
+ """Reads the namespace of the client and adds this interceptor to its interceptors."""
121
+ self._namespace = config.get("namespace") or _DEFAULT_NAMESPACE
122
+ interceptors = list(config.get("interceptors") or [])
123
+ if not any(one is self for one in interceptors):
124
+ interceptors.append(self)
125
+ config["interceptors"] = interceptors
126
+ if self._next_plugin is not None:
127
+ return self._next_plugin.configure_client(config)
128
+ return config
129
+
130
+ async def connect_service_client(self, config: Any, next: Any = None) -> Any:
131
+ """Connects as the next plugin or temporalio would, unchanged."""
132
+ if next is not None:
133
+ return await next(config)
134
+ if self._next_plugin is not None:
135
+ return await self._next_plugin.connect_service_client(config)
136
+ return await temporalio.service.ServiceClient.connect(config)
137
+
138
+ async def flush(self) -> None:
139
+ """Sends what waits and waits for it to land."""
140
+ await self._buffer.flush()
141
+
142
+ async def close(self) -> None:
143
+ """Sends what waits and stops."""
144
+ await self._buffer.close()
145
+
146
+ def counts(self) -> SinkCounts:
147
+ """What the buffer lost and holds."""
148
+ return self._buffer.counts()
149
+
150
+ def _record(self, kind: str, name: str, workflow_id: str, run_id: Optional[str], err: BaseException) -> None:
151
+ """Records a call that raised, and never raises itself."""
152
+ try:
153
+ call = ClientCall(
154
+ namespace=self._namespace,
155
+ workflow_id=workflow_id,
156
+ run_id=run_id or "",
157
+ kind=kind,
158
+ name=name,
159
+ outcome=CLIENT_CALL_OUTCOME_TIMED_OUT if _timed_out(err) else CLIENT_CALL_OUTCOME_FAILED,
160
+ error_type=_error_type(err),
161
+ )
162
+ call.ended_at.FromNanoseconds(int(time.time() * 1_000_000_000))
163
+ self._buffer.record(call)
164
+ except Exception: # noqa: BLE001
165
+ return
166
+
167
+
168
+ class _ClientOutbound(temporalio.client.OutboundInterceptor):
169
+ def __init__(self, next: temporalio.client.OutboundInterceptor, owner: ClientInterceptor) -> None:
170
+ super().__init__(next)
171
+ self._owner = owner
172
+
173
+ async def query_workflow(self, input: temporalio.client.QueryWorkflowInput) -> Any:
174
+ try:
175
+ return await super().query_workflow(input)
176
+ except Exception as err:
177
+ self._owner._record("query", input.query, input.id, input.run_id, err)
178
+ raise
179
+
180
+ async def signal_workflow(self, input: temporalio.client.SignalWorkflowInput) -> None:
181
+ try:
182
+ await super().signal_workflow(input)
183
+ except Exception as err:
184
+ self._owner._record("signal", input.signal, input.id, input.run_id, err)
185
+ raise
@@ -0,0 +1,56 @@
1
+ """What the CI side of the SDK shares: the error a call that has to fail
2
+ raises, and the message that says Flowrensic could not be reached or what it
3
+ answered."""
4
+
5
+ from __future__ import annotations
6
+
7
+ from typing import Optional
8
+
9
+ from connectrpc.code import Code
10
+ from connectrpc.errors import ConnectError
11
+
12
+ __all__ = ["CIError", "ci_error", "ci_failure", "not_reached"]
13
+
14
+
15
+ class CIError(Exception):
16
+ """A CI call to Flowrensic that failed. Its text says that Flowrensic
17
+ could not be reached in time, or what it answered. code is the Connect code
18
+ Flowrensic answered with, None when it was not reached."""
19
+
20
+ def __init__(self, message: str, code: Optional[Code] = None) -> None:
21
+ super().__init__(message)
22
+ self.message = message
23
+ self.code = code
24
+
25
+
26
+ def not_reached(error: BaseException) -> bool:
27
+ """Whether a call failed because nothing answered in time or no connection
28
+ could be made. The client raises a transport error, such as a refused
29
+ connection, as a ConnectError raised from that error, while an answer of
30
+ Flowrensic carries no error under it."""
31
+ if not isinstance(error, ConnectError):
32
+ return True
33
+ if error.code in (Code.DEADLINE_EXCEEDED, Code.CANCELED):
34
+ return True
35
+ return error.__cause__ is not None
36
+
37
+
38
+ def _seconds(timeout_ms: int) -> str:
39
+ return f"{timeout_ms / 1000:g}"
40
+
41
+
42
+ def ci_failure(what: str, server_base_url: str, timeout_ms: int, error: BaseException) -> str:
43
+ """The message a CI call stops with: that Flowrensic could not be reached
44
+ in time, or what it answered, the code in brackets as Connect writes it and
45
+ the message. what names the call, such as deploy report."""
46
+ if not_reached(error):
47
+ cause = error.message if isinstance(error, ConnectError) else str(error)
48
+ return f"{what}: Flowrensic at {server_base_url} could not be reached within {_seconds(timeout_ms)} seconds: {cause}"
49
+ assert isinstance(error, ConnectError)
50
+ return f"{what}: Flowrensic at {server_base_url} answered [{error.code.value}] {error.message}"
51
+
52
+
53
+ def ci_error(what: str, server_base_url: str, timeout_ms: int, error: BaseException) -> CIError:
54
+ """The error a CI call that has to fail raises, with the message of ci_failure."""
55
+ code = None if not_reached(error) or not isinstance(error, ConnectError) else error.code
56
+ return CIError(ci_failure(what, server_base_url, timeout_ms, error), code)