@temporalio/core-bridge 1.13.2 → 1.14.0

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 (388) hide show
  1. package/Cargo.lock +135 -100
  2. package/Cargo.toml +3 -2
  3. package/{sdk-core/fsm/rustfsm_trait/LICENSE.txt → LICENSE} +5 -5
  4. package/README.md +0 -1
  5. package/bridge-macros/Cargo.toml +16 -0
  6. package/bridge-macros/src/derive_js_function.rs +126 -0
  7. package/bridge-macros/src/derive_tryfromjs.rs +138 -0
  8. package/bridge-macros/src/derive_tryintojs.rs +151 -0
  9. package/bridge-macros/src/lib.rs +42 -0
  10. package/lib/native.d.ts +13 -6
  11. package/package.json +6 -5
  12. package/releases/aarch64-apple-darwin/index.node +0 -0
  13. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  14. package/releases/x86_64-apple-darwin/index.node +0 -0
  15. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  16. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  17. package/sdk-core/.cargo/config.toml +9 -3
  18. package/sdk-core/.github/workflows/per-pr.yml +42 -5
  19. package/sdk-core/AGENTS.md +17 -19
  20. package/sdk-core/Cargo.toml +6 -7
  21. package/sdk-core/README.md +12 -15
  22. package/sdk-core/arch_docs/diagrams/deps.svg +102 -0
  23. package/sdk-core/{client → crates/client}/Cargo.toml +7 -9
  24. package/sdk-core/{client → crates/client}/src/lib.rs +110 -159
  25. package/sdk-core/{client → crates/client}/src/metrics.rs +1 -1
  26. package/sdk-core/{client → crates/client}/src/raw.rs +73 -44
  27. package/sdk-core/crates/client/src/request_extensions.rs +40 -0
  28. package/sdk-core/{client → crates/client}/src/retry.rs +24 -17
  29. package/sdk-core/crates/client/src/worker/mod.rs +1468 -0
  30. package/sdk-core/{client → crates/client}/src/workflow_handle/mod.rs +4 -4
  31. package/sdk-core/{core-api → crates/common}/Cargo.toml +17 -8
  32. package/sdk-core/crates/common/protos/api_cloud_upstream/VERSION +1 -0
  33. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/account/v1/message.proto +18 -0
  34. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/request_response.proto +38 -11
  35. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/service.proto +21 -4
  36. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/operation/v1/message.proto +6 -6
  37. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/sink/v1/message.proto +22 -0
  38. package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/create-release.yml +5 -0
  39. package/sdk-core/{core-api → crates/common}/src/envconfig.rs +2 -2
  40. package/sdk-core/{core-api → crates/common}/src/errors.rs +8 -1
  41. package/sdk-core/{fsm/rustfsm_trait/src/lib.rs → crates/common/src/fsm_trait.rs} +1 -27
  42. package/sdk-core/{core-api → crates/common}/src/lib.rs +24 -9
  43. package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/canned_histories.rs +1 -1
  44. package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/history_builder.rs +1 -1
  45. package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/history_info.rs +2 -2
  46. package/sdk-core/{sdk-core-protos/src/lib.rs → crates/common/src/protos/mod.rs} +18 -17
  47. package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/test_utils.rs +1 -1
  48. package/sdk-core/{core-api → crates/common}/src/telemetry/metrics.rs +447 -50
  49. package/sdk-core/{core-api → crates/common}/src/telemetry.rs +3 -1
  50. package/sdk-core/{core-api → crates/common}/src/worker.rs +112 -18
  51. package/sdk-core/crates/common/tests/worker_task_types_test.rs +129 -0
  52. package/sdk-core/crates/macros/Cargo.toml +23 -0
  53. package/sdk-core/{fsm/rustfsm_procmacro → crates/macros}/src/lib.rs +6 -11
  54. package/sdk-core/{sdk → crates/sdk}/Cargo.toml +10 -10
  55. package/sdk-core/{sdk → crates/sdk}/src/activity_context.rs +8 -6
  56. package/sdk-core/{sdk → crates/sdk}/src/interceptors.rs +1 -1
  57. package/sdk-core/{sdk → crates/sdk}/src/lib.rs +42 -37
  58. package/sdk-core/{sdk → crates/sdk}/src/workflow_context/options.rs +2 -2
  59. package/sdk-core/{sdk → crates/sdk}/src/workflow_context.rs +21 -19
  60. package/sdk-core/{sdk → crates/sdk}/src/workflow_future.rs +1 -1
  61. package/sdk-core/{core → crates/sdk-core}/Cargo.toml +32 -25
  62. package/sdk-core/{tests → crates/sdk-core/benches}/workflow_replay_bench.rs +10 -10
  63. package/sdk-core/crates/sdk-core/machine_coverage/ActivityMachine_Coverage.puml +32 -0
  64. package/sdk-core/crates/sdk-core/machine_coverage/CancelExternalMachine_Coverage.puml +9 -0
  65. package/sdk-core/crates/sdk-core/machine_coverage/CancelWorkflowMachine_Coverage.puml +6 -0
  66. package/sdk-core/crates/sdk-core/machine_coverage/ChildWorkflowMachine_Coverage.puml +27 -0
  67. package/sdk-core/crates/sdk-core/machine_coverage/CompleteWorkflowMachine_Coverage.puml +6 -0
  68. package/sdk-core/crates/sdk-core/machine_coverage/ContinueAsNewWorkflowMachine_Coverage.puml +6 -0
  69. package/sdk-core/crates/sdk-core/machine_coverage/FailWorkflowMachine_Coverage.puml +6 -0
  70. package/sdk-core/crates/sdk-core/machine_coverage/LocalActivityMachine_Coverage.puml +23 -0
  71. package/sdk-core/crates/sdk-core/machine_coverage/ModifyWorkflowPropertiesMachine_Coverage.puml +5 -0
  72. package/sdk-core/crates/sdk-core/machine_coverage/PatchMachine_Coverage.puml +8 -0
  73. package/sdk-core/crates/sdk-core/machine_coverage/SignalExternalMachine_Coverage.puml +12 -0
  74. package/sdk-core/crates/sdk-core/machine_coverage/TimerMachine_Coverage.puml +13 -0
  75. package/sdk-core/crates/sdk-core/machine_coverage/UpdateMachine_Coverage.puml +19 -0
  76. package/sdk-core/crates/sdk-core/machine_coverage/UpsertSearchAttributesMachine_Coverage.puml +5 -0
  77. package/sdk-core/crates/sdk-core/machine_coverage/WorkflowTaskMachine_Coverage.puml +11 -0
  78. package/sdk-core/{core → crates/sdk-core}/src/abstractions.rs +62 -6
  79. package/sdk-core/crates/sdk-core/src/antithesis.rs +60 -0
  80. package/sdk-core/{core → crates/sdk-core}/src/core_tests/activity_tasks.rs +36 -31
  81. package/sdk-core/{core → crates/sdk-core}/src/core_tests/mod.rs +12 -9
  82. package/sdk-core/{core → crates/sdk-core}/src/core_tests/queries.rs +24 -21
  83. package/sdk-core/{core → crates/sdk-core}/src/core_tests/replay_flag.rs +10 -8
  84. package/sdk-core/{core → crates/sdk-core}/src/core_tests/updates.rs +17 -15
  85. package/sdk-core/{core → crates/sdk-core}/src/core_tests/workers.rs +242 -17
  86. package/sdk-core/{core → crates/sdk-core}/src/core_tests/workflow_cancels.rs +1 -1
  87. package/sdk-core/{core → crates/sdk-core}/src/core_tests/workflow_tasks.rs +126 -39
  88. package/sdk-core/{core → crates/sdk-core}/src/debug_client.rs +1 -1
  89. package/sdk-core/{core → crates/sdk-core}/src/ephemeral_server/mod.rs +3 -3
  90. package/sdk-core/crates/sdk-core/src/histfetch.rs +33 -0
  91. package/sdk-core/{core → crates/sdk-core}/src/internal_flags.rs +4 -3
  92. package/sdk-core/{core → crates/sdk-core}/src/lib.rs +85 -43
  93. package/sdk-core/{core → crates/sdk-core}/src/pollers/mod.rs +8 -6
  94. package/sdk-core/{core → crates/sdk-core}/src/pollers/poll_buffer.rs +51 -16
  95. package/sdk-core/{core → crates/sdk-core}/src/protosext/mod.rs +1 -1
  96. package/sdk-core/{core → crates/sdk-core}/src/protosext/protocol_messages.rs +1 -1
  97. package/sdk-core/{core → crates/sdk-core}/src/replay/mod.rs +14 -11
  98. package/sdk-core/{core → crates/sdk-core}/src/retry_logic.rs +19 -1
  99. package/sdk-core/{core → crates/sdk-core}/src/telemetry/log_export.rs +2 -2
  100. package/sdk-core/{core → crates/sdk-core}/src/telemetry/metrics.rs +80 -34
  101. package/sdk-core/{core → crates/sdk-core}/src/telemetry/mod.rs +4 -4
  102. package/sdk-core/{core → crates/sdk-core}/src/telemetry/otel.rs +1 -1
  103. package/sdk-core/{core → crates/sdk-core}/src/telemetry/prometheus_meter.rs +13 -13
  104. package/sdk-core/{core → crates/sdk-core}/src/telemetry/prometheus_server.rs +2 -2
  105. package/sdk-core/{core → crates/sdk-core}/src/test_help/integ_helpers.rs +127 -40
  106. package/sdk-core/{core → crates/sdk-core}/src/test_help/unit_helpers.rs +13 -11
  107. package/sdk-core/{core → crates/sdk-core}/src/worker/activities/activity_heartbeat_manager.rs +2 -2
  108. package/sdk-core/{core → crates/sdk-core}/src/worker/activities/local_activities.rs +14 -12
  109. package/sdk-core/{core → crates/sdk-core}/src/worker/activities.rs +21 -12
  110. package/sdk-core/{core → crates/sdk-core}/src/worker/client/mocks.rs +25 -12
  111. package/sdk-core/{core → crates/sdk-core}/src/worker/client.rs +164 -71
  112. package/sdk-core/crates/sdk-core/src/worker/heartbeat.rs +246 -0
  113. package/sdk-core/crates/sdk-core/src/worker/mod.rs +1462 -0
  114. package/sdk-core/{core → crates/sdk-core}/src/worker/nexus.rs +15 -14
  115. package/sdk-core/{core → crates/sdk-core}/src/worker/slot_provider.rs +12 -13
  116. package/sdk-core/{core → crates/sdk-core}/src/worker/tuner/fixed_size.rs +5 -1
  117. package/sdk-core/{core → crates/sdk-core}/src/worker/tuner/resource_based.rs +453 -57
  118. package/sdk-core/{core → crates/sdk-core}/src/worker/tuner.rs +21 -4
  119. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/driven_workflow.rs +1 -1
  120. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/history_update.rs +2 -2
  121. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/activity_state_machine.rs +147 -37
  122. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/cancel_external_state_machine.rs +8 -9
  123. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/cancel_nexus_op_state_machine.rs +14 -12
  124. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/cancel_workflow_state_machine.rs +6 -7
  125. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/child_workflow_state_machine.rs +31 -37
  126. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/complete_workflow_state_machine.rs +13 -8
  127. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +6 -7
  128. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/fail_workflow_state_machine.rs +6 -7
  129. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/local_activity_state_machine.rs +33 -30
  130. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/mod.rs +22 -17
  131. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +4 -3
  132. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/nexus_operation_state_machine.rs +20 -22
  133. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/patch_state_machine.rs +12 -11
  134. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/signal_external_state_machine.rs +9 -12
  135. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/timer_state_machine.rs +26 -13
  136. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/transition_coverage.rs +1 -2
  137. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/update_state_machine.rs +19 -13
  138. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +20 -18
  139. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_machines/local_acts.rs +1 -1
  140. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_machines.rs +61 -70
  141. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_task_state_machine.rs +13 -15
  142. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/managed_run.rs +55 -37
  143. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/mod.rs +166 -60
  144. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/run_cache.rs +10 -7
  145. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/wft_extraction.rs +4 -2
  146. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/wft_poller.rs +15 -4
  147. package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/workflow_stream.rs +30 -16
  148. package/sdk-core/{tests → crates/sdk-core/tests}/c_bridge_smoke_test.c +1 -1
  149. package/sdk-core/{tests → crates/sdk-core/tests}/cloud_tests.rs +1 -1
  150. package/sdk-core/crates/sdk-core/tests/common/fake_grpc_server.rs +106 -0
  151. package/sdk-core/{tests → crates/sdk-core/tests}/common/http_proxy.rs +1 -1
  152. package/sdk-core/{tests → crates/sdk-core/tests}/common/mod.rs +93 -74
  153. package/sdk-core/{tests → crates/sdk-core/tests}/common/workflows.rs +4 -3
  154. package/sdk-core/crates/sdk-core/tests/fsm_procmacro.rs +6 -0
  155. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/dupe_transitions_fail.rs +1 -3
  156. package/sdk-core/crates/sdk-core/tests/fsm_trybuild/dupe_transitions_fail.stderr +12 -0
  157. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/dynamic_dest_pass.rs +2 -4
  158. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/forgot_name_fail.rs +1 -3
  159. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/forgot_name_fail.stderr +4 -4
  160. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/handler_arg_pass.rs +2 -4
  161. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/handler_pass.rs +2 -4
  162. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/medium_complex_pass.rs +2 -4
  163. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/no_handle_conversions_require_into_fail.rs +2 -4
  164. package/sdk-core/crates/sdk-core/tests/fsm_trybuild/no_handle_conversions_require_into_fail.stderr +15 -0
  165. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/simple_pass.rs +2 -4
  166. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/struct_event_variant_fail.rs +1 -3
  167. package/sdk-core/crates/sdk-core/tests/fsm_trybuild/struct_event_variant_fail.stderr +5 -0
  168. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/tuple_more_item_event_variant_fail.rs +1 -3
  169. package/sdk-core/crates/sdk-core/tests/fsm_trybuild/tuple_more_item_event_variant_fail.stderr +5 -0
  170. package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/tuple_zero_item_event_variant_fail.rs +1 -3
  171. package/sdk-core/crates/sdk-core/tests/fsm_trybuild/tuple_zero_item_event_variant_fail.stderr +5 -0
  172. package/sdk-core/{tests → crates/sdk-core/tests}/global_metric_tests.rs +14 -15
  173. package/sdk-core/{tests → crates/sdk-core/tests/heavy_tests}/fuzzy_workflow.rs +3 -3
  174. package/sdk-core/{tests → crates/sdk-core/tests}/heavy_tests.rs +19 -12
  175. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/activity_functions.rs +1 -1
  176. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/client_tests.rs +16 -111
  177. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/ephemeral_server_tests.rs +5 -6
  178. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/heartbeat_tests.rs +23 -19
  179. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/metrics_tests.rs +134 -60
  180. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/pagination_tests.rs +4 -4
  181. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/polling_tests.rs +37 -36
  182. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/queries_tests.rs +12 -10
  183. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/update_tests.rs +41 -29
  184. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/visibility_tests.rs +24 -19
  185. package/sdk-core/crates/sdk-core/tests/integ_tests/worker_heartbeat_tests.rs +1061 -0
  186. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/worker_tests.rs +113 -51
  187. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/worker_versioning_tests.rs +19 -17
  188. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/activities.rs +35 -30
  189. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/appdata_propagation.rs +3 -3
  190. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/cancel_external.rs +14 -9
  191. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/cancel_wf.rs +13 -8
  192. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/child_workflows.rs +48 -35
  193. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/continue_as_new.rs +14 -9
  194. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/determinism.rs +24 -15
  195. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/eager.rs +9 -4
  196. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/local_activities.rs +47 -47
  197. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/modify_wf_properties.rs +16 -11
  198. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/nexus.rs +51 -23
  199. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/patches.rs +22 -10
  200. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/replay.rs +19 -17
  201. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/resets.rs +14 -5
  202. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/signals.rs +24 -15
  203. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/stickyness.rs +8 -6
  204. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/timers.rs +28 -18
  205. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/upsert_search_attrs.rs +18 -13
  206. package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests.rs +46 -41
  207. package/sdk-core/{tests → crates/sdk-core/tests}/main.rs +15 -9
  208. package/sdk-core/{tests → crates/sdk-core/tests}/manual_tests.rs +20 -14
  209. package/sdk-core/{tests → crates/sdk-core/tests}/runner.rs +2 -2
  210. package/sdk-core/{tests → crates/sdk-core/tests}/shared_tests/mod.rs +10 -5
  211. package/sdk-core/{tests → crates/sdk-core/tests}/shared_tests/priority.rs +5 -5
  212. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/Cargo.toml +13 -10
  213. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/include/temporal-sdk-core-c-bridge.h +32 -23
  214. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/client.rs +55 -32
  215. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/envconfig.rs +1 -1
  216. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/lib.rs +1 -1
  217. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/metric.rs +1 -1
  218. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/runtime.rs +24 -9
  219. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/testing.rs +1 -1
  220. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/context.rs +11 -10
  221. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/mod.rs +7 -7
  222. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/utils.rs +3 -4
  223. package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/worker.rs +111 -58
  224. package/sdk-core/docker-cgroup-tests.sh +24 -0
  225. package/sdk-core/{docker → etc/docker}/docker-compose-ci.yaml +9 -9
  226. package/sdk-core/{docker → etc/docker}/docker-compose-telem.yaml +11 -11
  227. package/sdk-core/{docker → etc/docker}/docker-compose.yaml +8 -8
  228. package/sdk-core/{integ-with-otel.sh → etc/integ-with-otel.sh} +1 -1
  229. package/sdk-core/etc/regen-depgraph.sh +2 -2
  230. package/src/client.rs +24 -33
  231. package/src/helpers/try_from_js.rs +1 -1
  232. package/src/logs.rs +1 -1
  233. package/src/metrics.rs +3 -3
  234. package/src/runtime.rs +42 -28
  235. package/src/testing.rs +3 -3
  236. package/src/worker.rs +70 -36
  237. package/ts/native.ts +13 -6
  238. package/LICENSE.md +0 -23
  239. package/sdk-core/client/src/worker_registry/mod.rs +0 -282
  240. package/sdk-core/core/src/worker/heartbeat.rs +0 -230
  241. package/sdk-core/core/src/worker/mod.rs +0 -990
  242. package/sdk-core/etc/deps.svg +0 -162
  243. package/sdk-core/fsm/Cargo.toml +0 -21
  244. package/sdk-core/fsm/README.md +0 -3
  245. package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +0 -27
  246. package/sdk-core/fsm/rustfsm_procmacro/LICENSE.txt +0 -21
  247. package/sdk-core/fsm/rustfsm_procmacro/tests/progress.rs +0 -8
  248. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +0 -12
  249. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +0 -15
  250. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.stderr +0 -5
  251. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.stderr +0 -5
  252. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.stderr +0 -5
  253. package/sdk-core/fsm/rustfsm_trait/Cargo.toml +0 -14
  254. package/sdk-core/fsm/src/lib.rs +0 -2
  255. package/sdk-core/sdk-core-protos/Cargo.toml +0 -37
  256. package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/VERSION +0 -1
  257. /package/sdk-core/{client → crates/client}/src/callback_based.rs +0 -0
  258. /package/sdk-core/{client → crates/client}/src/proxy.rs +0 -0
  259. /package/sdk-core/{client → crates/client}/src/replaceable.rs +0 -0
  260. /package/sdk-core/{sdk-core-protos → crates/common}/build.rs +0 -0
  261. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/.github/workflows/build.yaml +0 -0
  262. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/.github/workflows/push-to-buf.yml +0 -0
  263. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/CODEOWNERS +0 -0
  264. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/LICENSE +0 -0
  265. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/Makefile +0 -0
  266. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/README.md +0 -0
  267. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.gen.yaml +0 -0
  268. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.lock +0 -0
  269. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.yaml +0 -0
  270. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/connectivityrule/v1/message.proto +0 -0
  271. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/identity/v1/message.proto +0 -0
  272. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/namespace/v1/message.proto +0 -0
  273. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/nexus/v1/message.proto +0 -0
  274. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/region/v1/message.proto +0 -0
  275. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/resource/v1/message.proto +0 -0
  276. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/usage/v1/message.proto +0 -0
  277. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/CODEOWNERS +0 -0
  278. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  279. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/ci.yml +0 -0
  280. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/publish-docs.yml +0 -0
  281. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/push-to-buf.yml +0 -0
  282. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-delete-release.yml +0 -0
  283. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-publish-release.yml +0 -0
  284. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-update.yml +0 -0
  285. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/LICENSE +0 -0
  286. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/Makefile +0 -0
  287. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/README.md +0 -0
  288. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/api-linter.yaml +0 -0
  289. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.gen.yaml +0 -0
  290. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.lock +0 -0
  291. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.yaml +0 -0
  292. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/api/annotations.proto +0 -0
  293. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/api/http.proto +0 -0
  294. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/any.proto +0 -0
  295. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/descriptor.proto +0 -0
  296. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/duration.proto +0 -0
  297. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/empty.proto +0 -0
  298. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/struct.proto +0 -0
  299. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/timestamp.proto +0 -0
  300. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/wrappers.proto +0 -0
  301. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/openapiv2.json +0 -0
  302. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/openapiv3.yaml +0 -0
  303. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/payload_description.txt +0 -0
  304. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/activity/v1/message.proto +0 -0
  305. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/batch/v1/message.proto +0 -0
  306. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/command/v1/message.proto +0 -0
  307. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/common/v1/message.proto +0 -0
  308. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/deployment/v1/message.proto +0 -0
  309. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +0 -0
  310. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/command_type.proto +0 -0
  311. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/common.proto +0 -0
  312. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/deployment.proto +0 -0
  313. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/event_type.proto +0 -0
  314. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +0 -0
  315. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/namespace.proto +0 -0
  316. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/nexus.proto +0 -0
  317. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/query.proto +0 -0
  318. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/reset.proto +0 -0
  319. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/schedule.proto +0 -0
  320. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +0 -0
  321. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/update.proto +0 -0
  322. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/workflow.proto +0 -0
  323. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/errordetails/v1/message.proto +0 -0
  324. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/export/v1/message.proto +0 -0
  325. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/failure/v1/message.proto +0 -0
  326. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/filter/v1/message.proto +0 -0
  327. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/history/v1/message.proto +0 -0
  328. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/namespace/v1/message.proto +0 -0
  329. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/nexus/v1/message.proto +0 -0
  330. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +0 -0
  331. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +0 -0
  332. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/protocol/v1/message.proto +0 -0
  333. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/query/v1/message.proto +0 -0
  334. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/replication/v1/message.proto +0 -0
  335. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/rules/v1/message.proto +0 -0
  336. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/schedule/v1/message.proto +0 -0
  337. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/enhanced_stack_trace.proto +0 -0
  338. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +0 -0
  339. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/user_metadata.proto +0 -0
  340. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/worker_config.proto +0 -0
  341. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/workflow_metadata.proto +0 -0
  342. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +0 -0
  343. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/update/v1/message.proto +0 -0
  344. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/version/v1/message.proto +0 -0
  345. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/worker/v1/message.proto +0 -0
  346. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflow/v1/message.proto +0 -0
  347. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +0 -0
  348. /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +0 -0
  349. /package/sdk-core/{sdk-core-protos → crates/common}/protos/google/rpc/status.proto +0 -0
  350. /package/sdk-core/{sdk-core-protos → crates/common}/protos/grpc/health/v1/health.proto +0 -0
  351. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/activity_result/activity_result.proto +0 -0
  352. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/activity_task/activity_task.proto +0 -0
  353. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +0 -0
  354. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/common/common.proto +0 -0
  355. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/core_interface.proto +0 -0
  356. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/external_data/external_data.proto +0 -0
  357. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/nexus/nexus.proto +0 -0
  358. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +0 -0
  359. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +0 -0
  360. /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +0 -0
  361. /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/Makefile +0 -0
  362. /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/api-linter.yaml +0 -0
  363. /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/buf.yaml +0 -0
  364. /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +0 -0
  365. /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +0 -0
  366. /package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/constants.rs +0 -0
  367. /package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/task_token.rs +0 -0
  368. /package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/utilities.rs +0 -0
  369. /package/sdk-core/{fsm → crates/macros}/LICENSE.txt +0 -0
  370. /package/sdk-core/{sdk → crates/sdk}/src/app_data.rs +0 -0
  371. /package/sdk-core/{core → crates/sdk-core}/src/abstractions/take_cell.rs +0 -0
  372. /package/sdk-core/{core → crates/sdk-core}/src/test_help/mod.rs +0 -0
  373. /package/sdk-core/{core → crates/sdk-core}/src/worker/slot_supplier.rs +0 -0
  374. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/ends_empty_wft_complete.bin +0 -0
  375. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-16_history.bin +0 -0
  376. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-23_history.bin +0 -0
  377. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-85_history.bin +0 -0
  378. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/fail_wf_task.bin +0 -0
  379. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-0_history.bin +0 -0
  380. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-1_history.bin +0 -0
  381. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-2_history.bin +0 -0
  382. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-3_history.bin +0 -0
  383. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/old_change_marker_format.bin +0 -0
  384. /package/sdk-core/{histories → crates/sdk-core/tests/histories}/timer_workflow_history.bin +0 -0
  385. /package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/priority.rs +0 -0
  386. /package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/build.rs +0 -0
  387. /package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/random.rs +0 -0
  388. /package/sdk-core/{cargo-tokio-console.sh → etc/cargo-tokio-console.sh} +0 -0
@@ -5,7 +5,10 @@ use std::{
5
5
  collections::{BTreeMap, HashMap},
6
6
  fmt::{Debug, Display},
7
7
  ops::Deref,
8
- sync::{Arc, OnceLock},
8
+ sync::{
9
+ Arc, OnceLock,
10
+ atomic::{AtomicU64, Ordering},
11
+ },
9
12
  time::Duration,
10
13
  };
11
14
 
@@ -26,6 +29,18 @@ pub trait CoreMeter: Send + Sync + Debug {
26
29
  attribs: NewAttributes,
27
30
  ) -> MetricAttributes;
28
31
  fn counter(&self, params: MetricParameters) -> Counter;
32
+
33
+ /// Create a counter with in-memory tracking for worker heartbeating reporting
34
+ fn counter_with_in_memory(
35
+ &self,
36
+ params: MetricParameters,
37
+ in_memory_counter: HeartbeatMetricType,
38
+ ) -> Counter {
39
+ let primary_counter = self.counter(params);
40
+
41
+ Counter::new_with_in_memory(primary_counter.primary.metric.clone(), in_memory_counter)
42
+ }
43
+
29
44
  fn histogram(&self, params: MetricParameters) -> Histogram;
30
45
  fn histogram_f64(&self, params: MetricParameters) -> HistogramF64;
31
46
  /// Create a histogram which records Durations. Implementations should choose to emit in
@@ -33,10 +48,217 @@ pub trait CoreMeter: Send + Sync + Debug {
33
48
  /// [MetricParameters::unit] should be overwritten by implementations to be `ms` or `s`
34
49
  /// accordingly.
35
50
  fn histogram_duration(&self, params: MetricParameters) -> HistogramDuration;
51
+
52
+ /// Create a histogram duration with in-memory tracking for worker heartbeating reporting
53
+ fn histogram_duration_with_in_memory(
54
+ &self,
55
+ params: MetricParameters,
56
+ in_memory_hist: HeartbeatMetricType,
57
+ ) -> HistogramDuration {
58
+ let primary_hist = self.histogram_duration(params);
59
+
60
+ HistogramDuration::new_with_in_memory(primary_hist.primary.metric.clone(), in_memory_hist)
61
+ }
36
62
  fn gauge(&self, params: MetricParameters) -> Gauge;
63
+
64
+ /// Create a gauge with in-memory tracking for worker heartbeating reporting
65
+ fn gauge_with_in_memory(
66
+ &self,
67
+ params: MetricParameters,
68
+ in_memory_metrics: HeartbeatMetricType,
69
+ ) -> Gauge {
70
+ let primary_gauge = self.gauge(params.clone());
71
+ Gauge::new_with_in_memory(primary_gauge.primary.metric.clone(), in_memory_metrics)
72
+ }
73
+
37
74
  fn gauge_f64(&self, params: MetricParameters) -> GaugeF64;
38
75
  }
39
76
 
77
+ /// Provides a generic way to record metrics in memory.
78
+ /// This can be done either with individual metrics or more fine-grained metrics
79
+ /// that vary by a set of labels for the same metric.
80
+ #[derive(Clone, Debug)]
81
+ pub enum HeartbeatMetricType {
82
+ Individual(Arc<AtomicU64>),
83
+ WithLabel {
84
+ label_key: String,
85
+ metrics: HashMap<String, Arc<AtomicU64>>,
86
+ },
87
+ }
88
+
89
+ impl HeartbeatMetricType {
90
+ fn record_counter(&self, delta: u64) {
91
+ match self {
92
+ HeartbeatMetricType::Individual(metric) => {
93
+ metric.fetch_add(delta, Ordering::Relaxed);
94
+ }
95
+ HeartbeatMetricType::WithLabel { .. } => {
96
+ dbg_panic!("Counter does not support in-memory metric with labels");
97
+ }
98
+ }
99
+ }
100
+
101
+ fn record_histogram_observation(&self) {
102
+ match self {
103
+ HeartbeatMetricType::Individual(metric) => {
104
+ metric.fetch_add(1, Ordering::Relaxed);
105
+ }
106
+ HeartbeatMetricType::WithLabel { .. } => {
107
+ dbg_panic!("Histogram does not support in-memory metric with labels");
108
+ }
109
+ }
110
+ }
111
+
112
+ fn record_gauge(&self, value: u64, attributes: &MetricAttributes) {
113
+ match self {
114
+ HeartbeatMetricType::Individual(metric) => {
115
+ metric.store(value, Ordering::Relaxed);
116
+ }
117
+ HeartbeatMetricType::WithLabel { label_key, metrics } => {
118
+ if let Some(metric) = label_value_from_attributes(attributes, label_key.as_str())
119
+ .and_then(|label_value| metrics.get(label_value.as_str()))
120
+ {
121
+ metric.store(value, Ordering::Relaxed)
122
+ }
123
+ }
124
+ }
125
+ }
126
+ }
127
+
128
+ fn label_value_from_attributes(attributes: &MetricAttributes, key: &str) -> Option<String> {
129
+ match attributes {
130
+ MetricAttributes::Prometheus { labels } => labels.as_prom_labels().get(key).cloned(),
131
+ #[cfg(feature = "otel_impls")]
132
+ MetricAttributes::OTel { kvs } => kvs
133
+ .iter()
134
+ .find(|kv| kv.key.as_str() == key)
135
+ .map(|kv| kv.value.to_string()),
136
+ MetricAttributes::NoOp(labels) => labels.get(key).cloned(),
137
+ _ => None,
138
+ }
139
+ }
140
+
141
+ #[derive(Default, Debug)]
142
+ pub struct NumPollersMetric {
143
+ pub wft_current_pollers: Arc<AtomicU64>,
144
+ pub sticky_wft_current_pollers: Arc<AtomicU64>,
145
+ pub activity_current_pollers: Arc<AtomicU64>,
146
+ pub nexus_current_pollers: Arc<AtomicU64>,
147
+ }
148
+
149
+ impl NumPollersMetric {
150
+ pub fn as_map(&self) -> HashMap<String, Arc<AtomicU64>> {
151
+ HashMap::from([
152
+ (
153
+ "workflow_task".to_string(),
154
+ self.wft_current_pollers.clone(),
155
+ ),
156
+ (
157
+ "sticky_workflow_task".to_string(),
158
+ self.sticky_wft_current_pollers.clone(),
159
+ ),
160
+ (
161
+ "activity_task".to_string(),
162
+ self.activity_current_pollers.clone(),
163
+ ),
164
+ ("nexus_task".to_string(), self.nexus_current_pollers.clone()),
165
+ ])
166
+ }
167
+ }
168
+
169
+ #[derive(Default, Debug)]
170
+ pub struct SlotMetrics {
171
+ pub workflow_worker: Arc<AtomicU64>,
172
+ pub activity_worker: Arc<AtomicU64>,
173
+ pub nexus_worker: Arc<AtomicU64>,
174
+ pub local_activity_worker: Arc<AtomicU64>,
175
+ }
176
+
177
+ impl SlotMetrics {
178
+ pub fn as_map(&self) -> HashMap<String, Arc<AtomicU64>> {
179
+ HashMap::from([
180
+ ("WorkflowWorker".to_string(), self.workflow_worker.clone()),
181
+ ("ActivityWorker".to_string(), self.activity_worker.clone()),
182
+ ("NexusWorker".to_string(), self.nexus_worker.clone()),
183
+ (
184
+ "LocalActivityWorker".to_string(),
185
+ self.local_activity_worker.clone(),
186
+ ),
187
+ ])
188
+ }
189
+ }
190
+
191
+ #[derive(Default, Debug)]
192
+ pub struct WorkerHeartbeatMetrics {
193
+ pub sticky_cache_size: Arc<AtomicU64>,
194
+ pub total_sticky_cache_hit: Arc<AtomicU64>,
195
+ pub total_sticky_cache_miss: Arc<AtomicU64>,
196
+ pub num_pollers: NumPollersMetric,
197
+ pub worker_task_slots_used: SlotMetrics,
198
+ pub worker_task_slots_available: SlotMetrics,
199
+ pub workflow_task_execution_failed: Arc<AtomicU64>,
200
+ pub activity_execution_failed: Arc<AtomicU64>,
201
+ pub nexus_task_execution_failed: Arc<AtomicU64>,
202
+ pub local_activity_execution_failed: Arc<AtomicU64>,
203
+ pub activity_execution_latency: Arc<AtomicU64>,
204
+ pub local_activity_execution_latency: Arc<AtomicU64>,
205
+ pub workflow_task_execution_latency: Arc<AtomicU64>,
206
+ pub nexus_task_execution_latency: Arc<AtomicU64>,
207
+ }
208
+
209
+ impl WorkerHeartbeatMetrics {
210
+ pub fn get_metric(&self, name: &str) -> Option<HeartbeatMetricType> {
211
+ match name {
212
+ "sticky_cache_size" => Some(HeartbeatMetricType::Individual(
213
+ self.sticky_cache_size.clone(),
214
+ )),
215
+ "sticky_cache_hit" => Some(HeartbeatMetricType::Individual(
216
+ self.total_sticky_cache_hit.clone(),
217
+ )),
218
+ "sticky_cache_miss" => Some(HeartbeatMetricType::Individual(
219
+ self.total_sticky_cache_miss.clone(),
220
+ )),
221
+ "num_pollers" => Some(HeartbeatMetricType::WithLabel {
222
+ label_key: "poller_type".to_string(),
223
+ metrics: self.num_pollers.as_map(),
224
+ }),
225
+ "worker_task_slots_used" => Some(HeartbeatMetricType::WithLabel {
226
+ label_key: "worker_type".to_string(),
227
+ metrics: self.worker_task_slots_used.as_map(),
228
+ }),
229
+ "worker_task_slots_available" => Some(HeartbeatMetricType::WithLabel {
230
+ label_key: "worker_type".to_string(),
231
+ metrics: self.worker_task_slots_available.as_map(),
232
+ }),
233
+ "workflow_task_execution_failed" => Some(HeartbeatMetricType::Individual(
234
+ self.workflow_task_execution_failed.clone(),
235
+ )),
236
+ "activity_execution_failed" => Some(HeartbeatMetricType::Individual(
237
+ self.activity_execution_failed.clone(),
238
+ )),
239
+ "nexus_task_execution_failed" => Some(HeartbeatMetricType::Individual(
240
+ self.nexus_task_execution_failed.clone(),
241
+ )),
242
+ "local_activity_execution_failed" => Some(HeartbeatMetricType::Individual(
243
+ self.local_activity_execution_failed.clone(),
244
+ )),
245
+ "activity_execution_latency" => Some(HeartbeatMetricType::Individual(
246
+ self.activity_execution_latency.clone(),
247
+ )),
248
+ "local_activity_execution_latency" => Some(HeartbeatMetricType::Individual(
249
+ self.local_activity_execution_latency.clone(),
250
+ )),
251
+ "workflow_task_execution_latency" => Some(HeartbeatMetricType::Individual(
252
+ self.workflow_task_execution_latency.clone(),
253
+ )),
254
+ "nexus_task_execution_latency" => Some(HeartbeatMetricType::Individual(
255
+ self.nexus_task_execution_latency.clone(),
256
+ )),
257
+ _ => None,
258
+ }
259
+ }
260
+ }
261
+
40
262
  #[derive(Debug, Clone, derive_builder::Builder)]
41
263
  pub struct MetricParameters {
42
264
  /// The name for the new metric/instrument
@@ -125,6 +347,7 @@ pub enum MetricAttributes {
125
347
  },
126
348
  Buffer(BufferAttributes),
127
349
  Dynamic(Arc<dyn CustomMetricAttributes>),
350
+ NoOp(Arc<HashMap<String, String>>),
128
351
  Empty,
129
352
  }
130
353
 
@@ -156,6 +379,16 @@ where
156
379
  }
157
380
  }
158
381
 
382
+ impl From<NewAttributes> for HashMap<String, String> {
383
+ fn from(value: NewAttributes) -> Self {
384
+ value
385
+ .attributes
386
+ .into_iter()
387
+ .map(|kv| (kv.key, kv.value.to_string()))
388
+ .collect()
389
+ }
390
+ }
391
+
159
392
  /// A K/V pair that can be used to label a specific recording of a metric
160
393
  #[derive(Clone, Debug, PartialEq)]
161
394
  pub struct MetricKeyValue {
@@ -228,43 +461,79 @@ impl<T, B> LazyBoundMetric<T, B> {
228
461
  pub trait CounterBase: Send + Sync {
229
462
  fn adds(&self, value: u64);
230
463
  }
231
- pub type Counter = LazyBoundMetric<
464
+
465
+ pub type CounterImpl = LazyBoundMetric<
232
466
  Arc<dyn MetricAttributable<Box<dyn CounterBase>> + Send + Sync>,
233
467
  Arc<dyn CounterBase>,
234
468
  >;
469
+
470
+ #[derive(Clone)]
471
+ pub struct Counter {
472
+ primary: CounterImpl,
473
+ in_memory: Option<HeartbeatMetricType>,
474
+ }
235
475
  impl Counter {
236
476
  pub fn new(inner: Arc<dyn MetricAttributable<Box<dyn CounterBase>> + Send + Sync>) -> Self {
237
477
  Self {
238
- metric: inner,
239
- attributes: MetricAttributes::Empty,
240
- bound_cache: OnceLock::new(),
478
+ primary: LazyBoundMetric {
479
+ metric: inner,
480
+ attributes: MetricAttributes::Empty,
481
+ bound_cache: OnceLock::new(),
482
+ },
483
+ in_memory: None,
484
+ }
485
+ }
486
+
487
+ pub fn new_with_in_memory(
488
+ primary: Arc<dyn MetricAttributable<Box<dyn CounterBase>> + Send + Sync>,
489
+ in_memory: HeartbeatMetricType,
490
+ ) -> Self {
491
+ Self {
492
+ primary: LazyBoundMetric {
493
+ metric: primary,
494
+ attributes: MetricAttributes::Empty,
495
+ bound_cache: OnceLock::new(),
496
+ },
497
+ in_memory: Some(in_memory),
241
498
  }
242
499
  }
500
+
243
501
  pub fn add(&self, value: u64, attributes: &MetricAttributes) {
244
- match self.metric.with_attributes(attributes) {
245
- Ok(base) => {
246
- base.adds(value);
247
- }
502
+ match self.primary.metric.with_attributes(attributes) {
503
+ Ok(base) => base.adds(value),
248
504
  Err(e) => {
249
- dbg_panic!("Failed to initialize metric, will drop values: {e:?}",);
505
+ dbg_panic!("Failed to initialize primary metric, will drop values: {e:?}");
250
506
  }
251
507
  }
508
+
509
+ if let Some(ref in_mem) = self.in_memory {
510
+ in_mem.record_counter(value);
511
+ }
512
+ }
513
+
514
+ pub fn update_attributes(&mut self, new_attributes: MetricAttributes) {
515
+ self.primary.update_attributes(new_attributes.clone());
252
516
  }
253
517
  }
254
518
  impl CounterBase for Counter {
255
519
  fn adds(&self, value: u64) {
256
520
  // TODO: Replace all of these with below when stable
257
521
  // https://doc.rust-lang.org/std/sync/struct.OnceLock.html#method.get_or_try_init
258
- let bound = self.bound_cache.get_or_init(|| {
259
- self.metric
260
- .with_attributes(&self.attributes)
522
+ let bound = self.primary.bound_cache.get_or_init(|| {
523
+ self.primary
524
+ .metric
525
+ .with_attributes(&self.primary.attributes)
261
526
  .map(Into::into)
262
527
  .unwrap_or_else(|e| {
263
- dbg_panic!("Failed to initialize metric, will drop values: {e:?}");
528
+ dbg_panic!("Failed to initialize primary metric, will drop values: {e:?}");
264
529
  Arc::new(NoOpInstrument) as Arc<dyn CounterBase>
265
530
  })
266
531
  });
267
532
  bound.adds(value);
533
+
534
+ if let Some(ref in_mem) = self.in_memory {
535
+ in_mem.record_counter(value);
536
+ }
268
537
  }
269
538
  }
270
539
  impl MetricAttributable<Counter> for Counter {
@@ -272,10 +541,15 @@ impl MetricAttributable<Counter> for Counter {
272
541
  &self,
273
542
  attributes: &MetricAttributes,
274
543
  ) -> Result<Counter, Box<dyn std::error::Error>> {
275
- Ok(Self {
276
- metric: self.metric.clone(),
544
+ let primary = LazyBoundMetric {
545
+ metric: self.primary.metric.clone(),
277
546
  attributes: attributes.clone(),
278
547
  bound_cache: OnceLock::new(),
548
+ };
549
+
550
+ Ok(Counter {
551
+ primary,
552
+ in_memory: self.in_memory.clone(),
279
553
  })
280
554
  }
281
555
  }
@@ -391,22 +665,45 @@ impl MetricAttributable<HistogramF64> for HistogramF64 {
391
665
  pub trait HistogramDurationBase: Send + Sync {
392
666
  fn records(&self, value: Duration);
393
667
  }
394
- pub type HistogramDuration = LazyBoundMetric<
668
+
669
+ pub type HistogramDurationImpl = LazyBoundMetric<
395
670
  Arc<dyn MetricAttributable<Box<dyn HistogramDurationBase>> + Send + Sync>,
396
671
  Arc<dyn HistogramDurationBase>,
397
672
  >;
673
+
674
+ #[derive(Clone)]
675
+ pub struct HistogramDuration {
676
+ primary: HistogramDurationImpl,
677
+ in_memory: Option<HeartbeatMetricType>,
678
+ }
398
679
  impl HistogramDuration {
399
680
  pub fn new(
400
681
  inner: Arc<dyn MetricAttributable<Box<dyn HistogramDurationBase>> + Send + Sync>,
401
682
  ) -> Self {
402
683
  Self {
403
- metric: inner,
404
- attributes: MetricAttributes::Empty,
405
- bound_cache: OnceLock::new(),
684
+ primary: LazyBoundMetric {
685
+ metric: inner,
686
+ attributes: MetricAttributes::Empty,
687
+ bound_cache: OnceLock::new(),
688
+ },
689
+ in_memory: None,
690
+ }
691
+ }
692
+ pub fn new_with_in_memory(
693
+ primary: Arc<dyn MetricAttributable<Box<dyn HistogramDurationBase>> + Send + Sync>,
694
+ in_memory: HeartbeatMetricType,
695
+ ) -> Self {
696
+ Self {
697
+ primary: LazyBoundMetric {
698
+ metric: primary,
699
+ attributes: MetricAttributes::Empty,
700
+ bound_cache: OnceLock::new(),
701
+ },
702
+ in_memory: Some(in_memory),
406
703
  }
407
704
  }
408
705
  pub fn record(&self, value: Duration, attributes: &MetricAttributes) {
409
- match self.metric.with_attributes(attributes) {
706
+ match self.primary.metric.with_attributes(attributes) {
410
707
  Ok(base) => {
411
708
  base.records(value);
412
709
  }
@@ -414,13 +711,22 @@ impl HistogramDuration {
414
711
  dbg_panic!("Failed to initialize metric, will drop values: {e:?}",);
415
712
  }
416
713
  }
714
+
715
+ if let Some(ref in_mem) = self.in_memory {
716
+ in_mem.record_histogram_observation();
717
+ }
718
+ }
719
+
720
+ pub fn update_attributes(&mut self, new_attributes: MetricAttributes) {
721
+ self.primary.update_attributes(new_attributes.clone());
417
722
  }
418
723
  }
419
724
  impl HistogramDurationBase for HistogramDuration {
420
725
  fn records(&self, value: Duration) {
421
- let bound = self.bound_cache.get_or_init(|| {
422
- self.metric
423
- .with_attributes(&self.attributes)
726
+ let bound = self.primary.bound_cache.get_or_init(|| {
727
+ self.primary
728
+ .metric
729
+ .with_attributes(&self.primary.attributes)
424
730
  .map(Into::into)
425
731
  .unwrap_or_else(|e| {
426
732
  dbg_panic!("Failed to initialize metric, will drop values: {e:?}");
@@ -428,6 +734,10 @@ impl HistogramDurationBase for HistogramDuration {
428
734
  })
429
735
  });
430
736
  bound.records(value);
737
+
738
+ if let Some(ref in_mem) = self.in_memory {
739
+ in_mem.record_histogram_observation();
740
+ }
431
741
  }
432
742
  }
433
743
  impl MetricAttributable<HistogramDuration> for HistogramDuration {
@@ -435,10 +745,15 @@ impl MetricAttributable<HistogramDuration> for HistogramDuration {
435
745
  &self,
436
746
  attributes: &MetricAttributes,
437
747
  ) -> Result<HistogramDuration, Box<dyn std::error::Error>> {
438
- Ok(Self {
439
- metric: self.metric.clone(),
748
+ let primary = LazyBoundMetric {
749
+ metric: self.primary.metric.clone(),
440
750
  attributes: attributes.clone(),
441
751
  bound_cache: OnceLock::new(),
752
+ };
753
+
754
+ Ok(HistogramDuration {
755
+ primary,
756
+ in_memory: self.in_memory.clone(),
442
757
  })
443
758
  }
444
759
  }
@@ -446,41 +761,77 @@ impl MetricAttributable<HistogramDuration> for HistogramDuration {
446
761
  pub trait GaugeBase: Send + Sync {
447
762
  fn records(&self, value: u64);
448
763
  }
449
- pub type Gauge = LazyBoundMetric<
764
+
765
+ pub type GaugeImpl = LazyBoundMetric<
450
766
  Arc<dyn MetricAttributable<Box<dyn GaugeBase>> + Send + Sync>,
451
767
  Arc<dyn GaugeBase>,
452
768
  >;
769
+
770
+ #[derive(Clone)]
771
+ pub struct Gauge {
772
+ primary: GaugeImpl,
773
+ in_memory: Option<HeartbeatMetricType>,
774
+ }
453
775
  impl Gauge {
454
776
  pub fn new(inner: Arc<dyn MetricAttributable<Box<dyn GaugeBase>> + Send + Sync>) -> Self {
455
777
  Self {
456
- metric: inner,
457
- attributes: MetricAttributes::Empty,
458
- bound_cache: OnceLock::new(),
778
+ primary: LazyBoundMetric {
779
+ metric: inner,
780
+ attributes: MetricAttributes::Empty,
781
+ bound_cache: OnceLock::new(),
782
+ },
783
+ in_memory: None,
459
784
  }
460
785
  }
786
+
787
+ pub fn new_with_in_memory(
788
+ primary: Arc<dyn MetricAttributable<Box<dyn GaugeBase>> + Send + Sync>,
789
+ in_memory: HeartbeatMetricType,
790
+ ) -> Self {
791
+ Self {
792
+ primary: LazyBoundMetric {
793
+ metric: primary,
794
+ attributes: MetricAttributes::Empty,
795
+ bound_cache: OnceLock::new(),
796
+ },
797
+ in_memory: Some(in_memory),
798
+ }
799
+ }
800
+
461
801
  pub fn record(&self, value: u64, attributes: &MetricAttributes) {
462
- match self.metric.with_attributes(attributes) {
463
- Ok(base) => {
464
- base.records(value);
465
- }
802
+ match self.primary.metric.with_attributes(attributes) {
803
+ Ok(base) => base.records(value),
466
804
  Err(e) => {
467
- dbg_panic!("Failed to initialize metric, will drop values: {e:?}",);
805
+ dbg_panic!("Failed to initialize primary metric, will drop values: {e:?}");
468
806
  }
469
807
  }
808
+
809
+ if let Some(ref in_mem) = self.in_memory {
810
+ in_mem.record_gauge(value, attributes);
811
+ }
812
+ }
813
+
814
+ pub fn update_attributes(&mut self, new_attributes: MetricAttributes) {
815
+ self.primary.update_attributes(new_attributes.clone());
470
816
  }
471
817
  }
472
818
  impl GaugeBase for Gauge {
473
819
  fn records(&self, value: u64) {
474
- let bound = self.bound_cache.get_or_init(|| {
475
- self.metric
476
- .with_attributes(&self.attributes)
820
+ let bound = self.primary.bound_cache.get_or_init(|| {
821
+ self.primary
822
+ .metric
823
+ .with_attributes(&self.primary.attributes)
477
824
  .map(Into::into)
478
825
  .unwrap_or_else(|e| {
479
- dbg_panic!("Failed to initialize metric, will drop values: {e:?}");
826
+ dbg_panic!("Failed to initialize primary metric, will drop values: {e:?}");
480
827
  Arc::new(NoOpInstrument) as Arc<dyn GaugeBase>
481
828
  })
482
829
  });
483
830
  bound.records(value);
831
+
832
+ if let Some(ref in_mem) = self.in_memory {
833
+ in_mem.record_gauge(value, &self.primary.attributes);
834
+ }
484
835
  }
485
836
  }
486
837
  impl MetricAttributable<Gauge> for Gauge {
@@ -488,10 +839,15 @@ impl MetricAttributable<Gauge> for Gauge {
488
839
  &self,
489
840
  attributes: &MetricAttributes,
490
841
  ) -> Result<Gauge, Box<dyn std::error::Error>> {
491
- Ok(Self {
492
- metric: self.metric.clone(),
842
+ let primary = LazyBoundMetric {
843
+ metric: self.primary.metric.clone(),
493
844
  attributes: attributes.clone(),
494
845
  bound_cache: OnceLock::new(),
846
+ };
847
+
848
+ Ok(Gauge {
849
+ primary,
850
+ in_memory: self.in_memory.clone(),
495
851
  })
496
852
  }
497
853
  }
@@ -634,12 +990,23 @@ impl<T> LazyRef<T> {
634
990
  #[derive(Debug)]
635
991
  pub struct NoOpCoreMeter;
636
992
  impl CoreMeter for NoOpCoreMeter {
637
- fn new_attributes(&self, _: NewAttributes) -> MetricAttributes {
638
- MetricAttributes::Dynamic(Arc::new(NoOpAttributes))
993
+ fn new_attributes(&self, attribs: NewAttributes) -> MetricAttributes {
994
+ MetricAttributes::NoOp(Arc::new(attribs.into()))
639
995
  }
640
996
 
641
- fn extend_attributes(&self, existing: MetricAttributes, _: NewAttributes) -> MetricAttributes {
642
- existing
997
+ fn extend_attributes(
998
+ &self,
999
+ existing: MetricAttributes,
1000
+ attribs: NewAttributes,
1001
+ ) -> MetricAttributes {
1002
+ if let MetricAttributes::NoOp(labels) = existing {
1003
+ let mut labels = (*labels).clone();
1004
+ labels.extend::<HashMap<String, String>>(attribs.into());
1005
+ MetricAttributes::NoOp(Arc::new(labels))
1006
+ } else {
1007
+ dbg_panic!("Must use NoOp attributes with a NoOp metric implementation");
1008
+ existing
1009
+ }
643
1010
  }
644
1011
 
645
1012
  fn counter(&self, _: MetricParameters) -> Counter {
@@ -702,11 +1069,41 @@ impl_no_op!(HistogramDurationBase, Duration);
702
1069
  impl_no_op!(GaugeBase, u64);
703
1070
  impl_no_op!(GaugeF64Base, f64);
704
1071
 
705
- #[derive(Debug, Clone)]
706
- pub struct NoOpAttributes;
707
- impl CustomMetricAttributes for NoOpAttributes {
708
- fn as_any(self: Arc<Self>) -> Arc<dyn Any + Send + Sync> {
709
- self as Arc<dyn Any + Send + Sync>
1072
+ #[cfg(test)]
1073
+ mod tests {
1074
+ use super::*;
1075
+ use std::{
1076
+ collections::HashMap,
1077
+ sync::{
1078
+ Arc,
1079
+ atomic::{AtomicU64, Ordering},
1080
+ },
1081
+ };
1082
+
1083
+ #[test]
1084
+ fn in_memory_attributes_provide_label_values() {
1085
+ let meter = NoOpCoreMeter;
1086
+ let base_attrs = meter.new_attributes(NewAttributes::default());
1087
+ let attrs = meter.extend_attributes(
1088
+ base_attrs,
1089
+ NewAttributes::from(vec![MetricKeyValue::new("poller_type", "workflow_task")]),
1090
+ );
1091
+
1092
+ let value = Arc::new(AtomicU64::new(0));
1093
+ let mut metrics = HashMap::new();
1094
+ metrics.insert("workflow_task".to_string(), value.clone());
1095
+ let heartbeat_metric = HeartbeatMetricType::WithLabel {
1096
+ label_key: "poller_type".to_string(),
1097
+ metrics,
1098
+ };
1099
+
1100
+ heartbeat_metric.record_gauge(3, &attrs);
1101
+
1102
+ assert_eq!(value.load(Ordering::Relaxed), 3);
1103
+ assert_eq!(
1104
+ label_value_from_attributes(&attrs, "poller_type").as_deref(),
1105
+ Some("workflow_task")
1106
+ );
710
1107
  }
711
1108
  }
712
1109
 
@@ -1,3 +1,5 @@
1
+ //! Contains tracing/logging and metrics related functionality
2
+
1
3
  pub mod metrics;
2
4
 
3
5
  use crate::telemetry::metrics::CoreMeter;
@@ -173,7 +175,7 @@ pub enum Logger {
173
175
  filter: String,
174
176
  },
175
177
  /// Push logs to Lang. Can be used with
176
- /// temporal_sdk_core::telemetry::log_export::CoreLogBufferedConsumer to buffer.
178
+ /// temporalio_sdk_core::telemetry::log_export::CoreLogBufferedConsumer to buffer.
177
179
  Push {
178
180
  /// An [EnvFilter](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/struct.EnvFilter.html) filter string.
179
181
  filter: String,