temporalio 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +180 -7
- data/bridge/Cargo.lock +208 -76
- data/bridge/Cargo.toml +5 -2
- data/bridge/sdk-core/Cargo.toml +1 -1
- data/bridge/sdk-core/README.md +20 -10
- data/bridge/sdk-core/client/Cargo.toml +1 -1
- data/bridge/sdk-core/client/src/lib.rs +227 -59
- data/bridge/sdk-core/client/src/metrics.rs +17 -8
- data/bridge/sdk-core/client/src/raw.rs +13 -12
- data/bridge/sdk-core/client/src/retry.rs +132 -43
- data/bridge/sdk-core/core/Cargo.toml +28 -15
- data/bridge/sdk-core/core/benches/workflow_replay.rs +13 -10
- data/bridge/sdk-core/core/src/abstractions.rs +225 -36
- data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +217 -79
- data/bridge/sdk-core/core/src/core_tests/determinism.rs +165 -2
- data/bridge/sdk-core/core/src/core_tests/local_activities.rs +565 -34
- data/bridge/sdk-core/core/src/core_tests/queries.rs +247 -90
- data/bridge/sdk-core/core/src/core_tests/workers.rs +3 -5
- data/bridge/sdk-core/core/src/core_tests/workflow_cancels.rs +1 -1
- data/bridge/sdk-core/core/src/core_tests/workflow_tasks.rs +430 -67
- data/bridge/sdk-core/core/src/ephemeral_server/mod.rs +106 -12
- data/bridge/sdk-core/core/src/internal_flags.rs +136 -0
- data/bridge/sdk-core/core/src/lib.rs +148 -34
- data/bridge/sdk-core/core/src/protosext/mod.rs +1 -1
- data/bridge/sdk-core/core/src/replay/mod.rs +185 -41
- data/bridge/sdk-core/core/src/telemetry/log_export.rs +190 -0
- data/bridge/sdk-core/core/src/telemetry/metrics.rs +219 -140
- data/bridge/sdk-core/core/src/telemetry/mod.rs +326 -315
- data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +20 -14
- data/bridge/sdk-core/core/src/test_help/mod.rs +85 -21
- data/bridge/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +112 -156
- data/bridge/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +89 -0
- data/bridge/sdk-core/core/src/worker/activities/local_activities.rs +364 -128
- data/bridge/sdk-core/core/src/worker/activities.rs +263 -170
- data/bridge/sdk-core/core/src/worker/client/mocks.rs +23 -3
- data/bridge/sdk-core/core/src/worker/client.rs +48 -6
- data/bridge/sdk-core/core/src/worker/mod.rs +186 -75
- data/bridge/sdk-core/core/src/worker/workflow/bridge.rs +1 -3
- data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +13 -24
- data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +879 -226
- data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +101 -48
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +8 -12
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +6 -9
- data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +90 -32
- data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +6 -9
- data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +7 -10
- data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +6 -9
- data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +160 -83
- data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +36 -54
- data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +179 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +104 -157
- data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +8 -12
- data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +9 -13
- data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +10 -4
- data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +14 -11
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +6 -17
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +395 -299
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +12 -20
- data/bridge/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +33 -18
- data/bridge/sdk-core/core/src/worker/workflow/managed_run.rs +1032 -374
- data/bridge/sdk-core/core/src/worker/workflow/mod.rs +525 -392
- data/bridge/sdk-core/core/src/worker/workflow/run_cache.rs +40 -57
- data/bridge/sdk-core/core/src/worker/workflow/wft_extraction.rs +125 -0
- data/bridge/sdk-core/core/src/worker/workflow/wft_poller.rs +3 -6
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +117 -0
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/tonic_status_serde.rs +24 -0
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream.rs +456 -681
- data/bridge/sdk-core/core-api/Cargo.toml +6 -4
- data/bridge/sdk-core/core-api/src/errors.rs +1 -34
- data/bridge/sdk-core/core-api/src/lib.rs +7 -45
- data/bridge/sdk-core/core-api/src/telemetry.rs +141 -0
- data/bridge/sdk-core/core-api/src/worker.rs +27 -1
- data/bridge/sdk-core/etc/deps.svg +115 -140
- data/bridge/sdk-core/etc/regen-depgraph.sh +5 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +18 -15
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
- data/bridge/sdk-core/fsm/rustfsm_trait/src/lib.rs +8 -3
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-16_history.bin +0 -0
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-23_history.bin +0 -0
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-85_history.bin +0 -0
- data/bridge/sdk-core/protos/api_upstream/buf.yaml +0 -3
- data/bridge/sdk-core/protos/api_upstream/build/go.mod +7 -0
- data/bridge/sdk-core/protos/api_upstream/build/go.sum +5 -0
- data/bridge/sdk-core/protos/api_upstream/{temporal/api/enums/v1/cluster.proto → build/tools.go} +7 -18
- data/bridge/sdk-core/protos/api_upstream/go.mod +6 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +12 -9
- data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +15 -26
- data/bridge/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +13 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +4 -9
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +10 -8
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +28 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +24 -19
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +62 -26
- data/bridge/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +4 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +24 -61
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +2 -21
- data/bridge/sdk-core/protos/api_upstream/temporal/api/protocol/v1/message.proto +57 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +110 -31
- data/bridge/sdk-core/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +63 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +4 -4
- data/bridge/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +71 -6
- data/bridge/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +111 -36
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +19 -5
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/common/common.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +9 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +9 -1
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +6 -0
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +2 -2
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +2 -2
- data/bridge/sdk-core/sdk/Cargo.toml +4 -3
- data/bridge/sdk-core/sdk/src/interceptors.rs +36 -3
- data/bridge/sdk-core/sdk/src/lib.rs +94 -25
- data/bridge/sdk-core/sdk/src/workflow_context.rs +13 -2
- data/bridge/sdk-core/sdk/src/workflow_future.rs +10 -13
- data/bridge/sdk-core/sdk-core-protos/Cargo.toml +5 -2
- data/bridge/sdk-core/sdk-core-protos/build.rs +36 -2
- data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +164 -104
- data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +27 -23
- data/bridge/sdk-core/sdk-core-protos/src/lib.rs +252 -74
- data/bridge/sdk-core/sdk-core-protos/src/task_token.rs +12 -2
- data/bridge/sdk-core/test-utils/Cargo.toml +4 -1
- data/bridge/sdk-core/test-utils/src/canned_histories.rs +106 -296
- data/bridge/sdk-core/test-utils/src/histfetch.rs +1 -1
- data/bridge/sdk-core/test-utils/src/lib.rs +161 -50
- data/bridge/sdk-core/test-utils/src/wf_input_saver.rs +50 -0
- data/bridge/sdk-core/test-utils/src/workflows.rs +29 -0
- data/bridge/sdk-core/tests/fuzzy_workflow.rs +130 -0
- data/bridge/sdk-core/tests/{load_tests.rs → heavy_tests.rs} +125 -51
- data/bridge/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +25 -3
- data/bridge/sdk-core/tests/integ_tests/heartbeat_tests.rs +10 -5
- data/bridge/sdk-core/tests/integ_tests/metrics_tests.rs +239 -0
- data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +4 -60
- data/bridge/sdk-core/tests/integ_tests/queries_tests.rs +5 -128
- data/bridge/sdk-core/tests/integ_tests/visibility_tests.rs +83 -25
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/activities.rs +93 -69
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +6 -13
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +6 -2
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +3 -10
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +151 -116
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +54 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/patches.rs +7 -28
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/replay.rs +115 -24
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/signals.rs +18 -14
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +6 -20
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/timers.rs +10 -21
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +6 -4
- data/bridge/sdk-core/tests/integ_tests/workflow_tests.rs +27 -18
- data/bridge/sdk-core/tests/main.rs +8 -16
- data/bridge/sdk-core/tests/runner.rs +75 -36
- data/bridge/sdk-core/tests/wf_input_replay.rs +32 -0
- data/bridge/src/connection.rs +117 -82
- data/bridge/src/lib.rs +356 -42
- data/bridge/src/runtime.rs +10 -3
- data/bridge/src/test_server.rs +153 -0
- data/bridge/src/worker.rs +133 -9
- data/lib/gen/temporal/api/batch/v1/message_pb.rb +8 -6
- data/lib/gen/temporal/api/command/v1/message_pb.rb +10 -16
- data/lib/gen/temporal/api/common/v1/message_pb.rb +5 -1
- data/lib/gen/temporal/api/enums/v1/batch_operation_pb.rb +2 -1
- data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +3 -3
- data/lib/gen/temporal/api/enums/v1/common_pb.rb +2 -1
- data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +5 -4
- data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +9 -1
- data/lib/gen/temporal/api/enums/v1/namespace_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/query_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/reset_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/schedule_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/task_queue_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/update_pb.rb +7 -10
- data/lib/gen/temporal/api/enums/v1/workflow_pb.rb +1 -1
- data/lib/gen/temporal/api/errordetails/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/failure/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/filter/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/history/v1/message_pb.rb +34 -25
- data/lib/gen/temporal/api/namespace/v1/message_pb.rb +2 -1
- data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +14 -51
- data/lib/gen/temporal/api/operatorservice/v1/service_pb.rb +1 -1
- data/lib/gen/temporal/api/protocol/v1/message_pb.rb +30 -0
- data/lib/gen/temporal/api/query/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/replication/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/schedule/v1/message_pb.rb +22 -1
- data/lib/gen/temporal/api/sdk/v1/task_complete_metadata_pb.rb +23 -0
- data/lib/gen/temporal/api/taskqueue/v1/message_pb.rb +2 -2
- data/lib/gen/temporal/api/testservice/v1/request_response_pb.rb +49 -0
- data/lib/gen/temporal/api/testservice/v1/service_pb.rb +21 -0
- data/lib/gen/temporal/api/update/v1/message_pb.rb +49 -3
- data/lib/gen/temporal/api/version/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/workflow/v1/message_pb.rb +2 -1
- data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +47 -20
- data/lib/gen/temporal/api/workflowservice/v1/service_pb.rb +1 -1
- data/lib/gen/temporal/sdk/core/activity_result/activity_result_pb.rb +13 -9
- data/lib/gen/temporal/sdk/core/activity_task/activity_task_pb.rb +10 -6
- data/lib/gen/temporal/sdk/core/child_workflow/child_workflow_pb.rb +13 -9
- data/lib/gen/temporal/sdk/core/common/common_pb.rb +7 -3
- data/lib/gen/temporal/sdk/core/core_interface_pb.rb +9 -3
- data/lib/gen/temporal/sdk/core/external_data/external_data_pb.rb +7 -3
- data/lib/gen/temporal/sdk/core/workflow_activation/workflow_activation_pb.rb +28 -21
- data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +32 -24
- data/lib/gen/temporal/sdk/core/workflow_completion/workflow_completion_pb.rb +12 -5
- data/lib/temporalio/activity/context.rb +102 -0
- data/lib/temporalio/activity/info.rb +67 -0
- data/lib/temporalio/activity.rb +85 -0
- data/lib/temporalio/bridge/connect_options.rb +15 -0
- data/lib/temporalio/bridge/error.rb +8 -0
- data/lib/temporalio/bridge/retry_config.rb +24 -0
- data/lib/temporalio/bridge/tls_options.rb +19 -0
- data/lib/temporalio/bridge.rb +14 -0
- data/lib/{temporal → temporalio}/client/implementation.rb +57 -56
- data/lib/{temporal → temporalio}/client/workflow_handle.rb +35 -35
- data/lib/{temporal → temporalio}/client.rb +19 -32
- data/lib/temporalio/connection/retry_config.rb +44 -0
- data/lib/temporalio/connection/service.rb +20 -0
- data/lib/temporalio/connection/test_service.rb +92 -0
- data/lib/temporalio/connection/tls_options.rb +51 -0
- data/lib/temporalio/connection/workflow_service.rb +731 -0
- data/lib/temporalio/connection.rb +86 -0
- data/lib/{temporal → temporalio}/data_converter.rb +76 -35
- data/lib/{temporal → temporalio}/error/failure.rb +6 -6
- data/lib/{temporal → temporalio}/error/workflow_failure.rb +4 -2
- data/lib/{temporal → temporalio}/errors.rb +19 -1
- data/lib/{temporal → temporalio}/failure_converter/base.rb +5 -5
- data/lib/{temporal → temporalio}/failure_converter/basic.rb +58 -52
- data/lib/temporalio/failure_converter.rb +7 -0
- data/lib/temporalio/interceptor/activity_inbound.rb +22 -0
- data/lib/temporalio/interceptor/activity_outbound.rb +24 -0
- data/lib/{temporal → temporalio}/interceptor/chain.rb +7 -6
- data/lib/{temporal → temporalio}/interceptor/client.rb +27 -2
- data/lib/temporalio/interceptor.rb +22 -0
- data/lib/{temporal → temporalio}/payload_codec/base.rb +5 -5
- data/lib/{temporal → temporalio}/payload_converter/base.rb +3 -3
- data/lib/{temporal → temporalio}/payload_converter/bytes.rb +4 -3
- data/lib/{temporal → temporalio}/payload_converter/composite.rb +7 -5
- data/lib/{temporal → temporalio}/payload_converter/encoding_base.rb +4 -4
- data/lib/{temporal → temporalio}/payload_converter/json.rb +4 -3
- data/lib/{temporal → temporalio}/payload_converter/nil.rb +4 -3
- data/lib/temporalio/payload_converter.rb +14 -0
- data/lib/{temporal → temporalio}/retry_policy.rb +17 -7
- data/lib/{temporal → temporalio}/retry_state.rb +1 -1
- data/lib/temporalio/runtime.rb +25 -0
- data/lib/temporalio/testing/time_skipping_handle.rb +32 -0
- data/lib/temporalio/testing/time_skipping_interceptor.rb +23 -0
- data/lib/temporalio/testing/workflow_environment.rb +112 -0
- data/lib/temporalio/testing.rb +175 -0
- data/lib/{temporal → temporalio}/timeout_type.rb +2 -2
- data/lib/temporalio/version.rb +3 -0
- data/lib/temporalio/worker/activity_runner.rb +114 -0
- data/lib/temporalio/worker/activity_worker.rb +164 -0
- data/lib/temporalio/worker/reactor.rb +46 -0
- data/lib/temporalio/worker/runner.rb +63 -0
- data/lib/temporalio/worker/sync_worker.rb +124 -0
- data/lib/temporalio/worker/thread_pool_executor.rb +51 -0
- data/lib/temporalio/worker.rb +204 -0
- data/lib/temporalio/workflow/async.rb +46 -0
- data/lib/{temporal → temporalio}/workflow/execution_info.rb +4 -4
- data/lib/{temporal → temporalio}/workflow/execution_status.rb +1 -1
- data/lib/temporalio/workflow/future.rb +138 -0
- data/lib/{temporal → temporalio}/workflow/id_reuse_policy.rb +6 -6
- data/lib/temporalio/workflow/info.rb +76 -0
- data/lib/{temporal → temporalio}/workflow/query_reject_condition.rb +5 -5
- data/lib/temporalio.rb +12 -3
- data/temporalio.gemspec +11 -6
- metadata +137 -64
- data/bridge/sdk-core/Cargo.lock +0 -2606
- data/bridge/sdk-core/bridge-ffi/Cargo.toml +0 -24
- data/bridge/sdk-core/bridge-ffi/LICENSE.txt +0 -23
- data/bridge/sdk-core/bridge-ffi/build.rs +0 -25
- data/bridge/sdk-core/bridge-ffi/include/sdk-core-bridge.h +0 -249
- data/bridge/sdk-core/bridge-ffi/src/lib.rs +0 -825
- data/bridge/sdk-core/bridge-ffi/src/wrappers.rs +0 -211
- data/bridge/sdk-core/core/src/log_export.rs +0 -62
- data/bridge/sdk-core/core/src/worker/workflow/machines/mutable_side_effect_state_machine.rs +0 -127
- data/bridge/sdk-core/core/src/worker/workflow/machines/side_effect_state_machine.rs +0 -71
- data/bridge/sdk-core/protos/api_upstream/temporal/api/cluster/v1/message.proto +0 -83
- data/bridge/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +0 -210
- data/bridge/sdk-core/sdk/src/conversions.rs +0 -8
- data/lib/bridge.so +0 -0
- data/lib/gen/temporal/api/cluster/v1/message_pb.rb +0 -67
- data/lib/gen/temporal/api/enums/v1/cluster_pb.rb +0 -26
- data/lib/gen/temporal/sdk/core/bridge/bridge_pb.rb +0 -222
- data/lib/temporal/bridge.rb +0 -14
- data/lib/temporal/connection.rb +0 -736
- data/lib/temporal/failure_converter.rb +0 -8
- data/lib/temporal/payload_converter.rb +0 -14
- data/lib/temporal/runtime.rb +0 -22
- data/lib/temporal/version.rb +0 -3
- data/lib/temporal.rb +0 -8
@@ -1,38 +1,113 @@
|
|
1
|
-
use
|
2
|
-
use crate::telemetry::GLOBAL_TELEM_DAT;
|
3
|
-
use opentelemetry::sdk::metrics::aggregators::Aggregator;
|
4
|
-
use opentelemetry::sdk::metrics::sdk_api::{Descriptor, InstrumentKind};
|
1
|
+
use crate::telemetry::TelemetryInstance;
|
5
2
|
use opentelemetry::{
|
6
|
-
|
7
|
-
metrics::{Counter, Histogram, Meter},
|
3
|
+
metrics::{noop::NoopMeterProvider, Counter, Histogram, Meter, MeterProvider},
|
8
4
|
sdk::{
|
9
5
|
export::metrics::AggregatorSelector,
|
10
|
-
metrics::
|
6
|
+
metrics::{
|
7
|
+
aggregators::{histogram, last_value, sum, Aggregator},
|
8
|
+
sdk_api::{Descriptor, InstrumentKind},
|
9
|
+
},
|
11
10
|
},
|
12
11
|
Context, KeyValue,
|
13
12
|
};
|
14
|
-
use std::{sync::Arc, time::Duration};
|
13
|
+
use std::{ops::Deref, sync::Arc, time::Duration};
|
14
|
+
use temporal_client::ClientMetricProvider;
|
15
15
|
|
16
16
|
/// Used to track context associated with metrics, and record/update them
|
17
17
|
///
|
18
18
|
/// Possible improvement: make generic over some type tag so that methods are only exposed if the
|
19
19
|
/// appropriate k/vs have already been set.
|
20
|
-
#[derive(
|
20
|
+
#[derive(Clone)]
|
21
21
|
pub(crate) struct MetricsContext {
|
22
22
|
ctx: Context,
|
23
23
|
kvs: Arc<Vec<KeyValue>>,
|
24
|
+
instruments: Arc<Instruments>,
|
25
|
+
}
|
26
|
+
|
27
|
+
/// Wraps OTel's [Meter] to ensure we name our metrics properly, or any other temporal-specific
|
28
|
+
/// metrics customizations
|
29
|
+
#[derive(derive_more::Constructor)]
|
30
|
+
pub struct TemporalMeter<'a> {
|
31
|
+
inner: &'a Meter,
|
32
|
+
metrics_prefix: &'static str,
|
33
|
+
}
|
34
|
+
|
35
|
+
impl<'a> TemporalMeter<'a> {
|
36
|
+
pub(crate) fn counter(&self, name: &'static str) -> Counter<u64> {
|
37
|
+
self.inner
|
38
|
+
.u64_counter(self.metrics_prefix.to_string() + name)
|
39
|
+
.init()
|
40
|
+
}
|
41
|
+
|
42
|
+
pub(crate) fn histogram(&self, name: &'static str) -> Histogram<u64> {
|
43
|
+
self.inner
|
44
|
+
.u64_histogram(self.metrics_prefix.to_string() + name)
|
45
|
+
.init()
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
impl<'a> ClientMetricProvider for TemporalMeter<'a> {
|
50
|
+
fn counter(&self, name: &'static str) -> Counter<u64> {
|
51
|
+
self.counter(name)
|
52
|
+
}
|
53
|
+
|
54
|
+
fn histogram(&self, name: &'static str) -> Histogram<u64> {
|
55
|
+
self.histogram(name)
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
impl<'a> Deref for TemporalMeter<'a> {
|
60
|
+
type Target = dyn ClientMetricProvider + 'a;
|
61
|
+
|
62
|
+
fn deref(&self) -> &Self::Target {
|
63
|
+
self as &Self::Target
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
struct Instruments {
|
68
|
+
wf_completed_counter: Counter<u64>,
|
69
|
+
wf_canceled_counter: Counter<u64>,
|
70
|
+
wf_failed_counter: Counter<u64>,
|
71
|
+
wf_cont_counter: Counter<u64>,
|
72
|
+
wf_e2e_latency: Histogram<u64>,
|
73
|
+
wf_task_queue_poll_empty_counter: Counter<u64>,
|
74
|
+
wf_task_queue_poll_succeed_counter: Counter<u64>,
|
75
|
+
wf_task_execution_failure_counter: Counter<u64>,
|
76
|
+
wf_task_sched_to_start_latency: Histogram<u64>,
|
77
|
+
wf_task_replay_latency: Histogram<u64>,
|
78
|
+
wf_task_execution_latency: Histogram<u64>,
|
79
|
+
act_poll_no_task: Counter<u64>,
|
80
|
+
act_task_received_counter: Counter<u64>,
|
81
|
+
act_execution_failed: Counter<u64>,
|
82
|
+
act_sched_to_start_latency: Histogram<u64>,
|
83
|
+
act_exec_latency: Histogram<u64>,
|
84
|
+
worker_registered: Counter<u64>,
|
85
|
+
num_pollers: Histogram<u64>,
|
86
|
+
task_slots_available: Histogram<u64>,
|
87
|
+
sticky_cache_hit: Counter<u64>,
|
88
|
+
sticky_cache_miss: Counter<u64>,
|
89
|
+
sticky_cache_size: Histogram<u64>,
|
24
90
|
}
|
25
91
|
|
26
92
|
impl MetricsContext {
|
27
|
-
fn
|
93
|
+
pub(crate) fn no_op() -> Self {
|
28
94
|
Self {
|
29
|
-
ctx:
|
30
|
-
kvs:
|
95
|
+
ctx: Default::default(),
|
96
|
+
kvs: Default::default(),
|
97
|
+
instruments: Arc::new(Instruments::new_explicit(TemporalMeter::new(
|
98
|
+
&NoopMeterProvider::new().meter("fakemeter"),
|
99
|
+
"fakemetrics",
|
100
|
+
))),
|
31
101
|
}
|
32
102
|
}
|
33
103
|
|
34
|
-
pub(crate) fn top_level(namespace: String) -> Self {
|
35
|
-
|
104
|
+
pub(crate) fn top_level(namespace: String, telemetry: &TelemetryInstance) -> Self {
|
105
|
+
let kvs = vec![KeyValue::new(KEY_NAMESPACE, namespace)];
|
106
|
+
Self {
|
107
|
+
ctx: Context::current(),
|
108
|
+
kvs: Arc::new(kvs),
|
109
|
+
instruments: Arc::new(Instruments::new(telemetry)),
|
110
|
+
}
|
36
111
|
}
|
37
112
|
|
38
113
|
pub(crate) fn with_task_q(mut self, tq: String) -> Self {
|
@@ -47,155 +122,213 @@ impl MetricsContext {
|
|
47
122
|
Self {
|
48
123
|
ctx: Context::current(),
|
49
124
|
kvs,
|
125
|
+
instruments: self.instruments.clone(),
|
50
126
|
}
|
51
127
|
}
|
52
128
|
|
53
129
|
/// A workflow task queue poll succeeded
|
54
130
|
pub(crate) fn wf_tq_poll_ok(&self) {
|
55
|
-
|
131
|
+
self.instruments
|
132
|
+
.wf_task_queue_poll_succeed_counter
|
133
|
+
.add(&self.ctx, 1, &self.kvs);
|
56
134
|
}
|
57
135
|
|
58
136
|
/// A workflow task queue poll timed out / had empty response
|
59
137
|
pub(crate) fn wf_tq_poll_empty(&self) {
|
60
|
-
|
138
|
+
self.instruments
|
139
|
+
.wf_task_queue_poll_empty_counter
|
140
|
+
.add(&self.ctx, 1, &self.kvs);
|
61
141
|
}
|
62
142
|
|
63
143
|
/// A workflow task execution failed
|
64
144
|
pub(crate) fn wf_task_failed(&self) {
|
65
|
-
|
145
|
+
self.instruments
|
146
|
+
.wf_task_execution_failure_counter
|
147
|
+
.add(&self.ctx, 1, &self.kvs);
|
66
148
|
}
|
67
149
|
|
68
150
|
/// A workflow completed successfully
|
69
151
|
pub(crate) fn wf_completed(&self) {
|
70
|
-
|
152
|
+
self.instruments
|
153
|
+
.wf_completed_counter
|
154
|
+
.add(&self.ctx, 1, &self.kvs);
|
71
155
|
}
|
72
156
|
|
73
157
|
/// A workflow ended cancelled
|
74
158
|
pub(crate) fn wf_canceled(&self) {
|
75
|
-
|
159
|
+
self.instruments
|
160
|
+
.wf_canceled_counter
|
161
|
+
.add(&self.ctx, 1, &self.kvs);
|
76
162
|
}
|
77
163
|
|
78
164
|
/// A workflow ended failed
|
79
165
|
pub(crate) fn wf_failed(&self) {
|
80
|
-
|
166
|
+
self.instruments
|
167
|
+
.wf_failed_counter
|
168
|
+
.add(&self.ctx, 1, &self.kvs);
|
81
169
|
}
|
82
170
|
|
83
171
|
/// A workflow continued as new
|
84
172
|
pub(crate) fn wf_continued_as_new(&self) {
|
85
|
-
|
173
|
+
self.instruments
|
174
|
+
.wf_cont_counter
|
175
|
+
.add(&self.ctx, 1, &self.kvs);
|
86
176
|
}
|
87
177
|
|
88
178
|
/// Record workflow total execution time in milliseconds
|
89
179
|
pub(crate) fn wf_e2e_latency(&self, dur: Duration) {
|
90
|
-
|
180
|
+
self.instruments
|
181
|
+
.wf_e2e_latency
|
182
|
+
.record(&self.ctx, dur.as_millis() as u64, &self.kvs);
|
91
183
|
}
|
92
184
|
|
93
185
|
/// Record workflow task schedule to start time in millis
|
94
186
|
pub(crate) fn wf_task_sched_to_start_latency(&self, dur: Duration) {
|
95
|
-
|
187
|
+
self.instruments.wf_task_sched_to_start_latency.record(
|
188
|
+
&self.ctx,
|
189
|
+
dur.as_millis() as u64,
|
190
|
+
&self.kvs,
|
191
|
+
);
|
96
192
|
}
|
97
193
|
|
98
194
|
/// Record workflow task execution time in milliseconds
|
99
195
|
pub(crate) fn wf_task_latency(&self, dur: Duration) {
|
100
|
-
|
196
|
+
self.instruments.wf_task_execution_latency.record(
|
197
|
+
&self.ctx,
|
198
|
+
dur.as_millis() as u64,
|
199
|
+
&self.kvs,
|
200
|
+
);
|
101
201
|
}
|
102
202
|
|
103
203
|
/// Record time it takes to catch up on replaying a WFT
|
104
204
|
pub(crate) fn wf_task_replay_latency(&self, dur: Duration) {
|
105
|
-
|
205
|
+
self.instruments.wf_task_replay_latency.record(
|
206
|
+
&self.ctx,
|
207
|
+
dur.as_millis() as u64,
|
208
|
+
&self.kvs,
|
209
|
+
);
|
106
210
|
}
|
107
211
|
|
108
212
|
/// An activity long poll timed out
|
109
213
|
pub(crate) fn act_poll_timeout(&self) {
|
110
|
-
|
214
|
+
self.instruments
|
215
|
+
.act_poll_no_task
|
216
|
+
.add(&self.ctx, 1, &self.kvs);
|
217
|
+
}
|
218
|
+
|
219
|
+
/// A count of activity tasks received
|
220
|
+
pub(crate) fn act_task_received(&self) {
|
221
|
+
self.instruments
|
222
|
+
.act_task_received_counter
|
223
|
+
.add(&self.ctx, 1, &self.kvs);
|
111
224
|
}
|
112
225
|
|
113
226
|
/// An activity execution failed
|
114
227
|
pub(crate) fn act_execution_failed(&self) {
|
115
|
-
|
228
|
+
self.instruments
|
229
|
+
.act_execution_failed
|
230
|
+
.add(&self.ctx, 1, &self.kvs);
|
116
231
|
}
|
117
232
|
|
118
233
|
/// Record activity task schedule to start time in millis
|
119
234
|
pub(crate) fn act_sched_to_start_latency(&self, dur: Duration) {
|
120
|
-
|
235
|
+
self.instruments.act_sched_to_start_latency.record(
|
236
|
+
&self.ctx,
|
237
|
+
dur.as_millis() as u64,
|
238
|
+
&self.kvs,
|
239
|
+
);
|
121
240
|
}
|
122
241
|
|
123
242
|
/// Record time it took to complete activity execution, from the time core generated the
|
124
243
|
/// activity task, to the time lang responded with a completion (failure or success).
|
125
244
|
pub(crate) fn act_execution_latency(&self, dur: Duration) {
|
126
|
-
|
245
|
+
self.instruments
|
246
|
+
.act_exec_latency
|
247
|
+
.record(&self.ctx, dur.as_millis() as u64, &self.kvs);
|
127
248
|
}
|
128
249
|
|
129
250
|
/// A worker was registered
|
130
251
|
pub(crate) fn worker_registered(&self) {
|
131
|
-
|
252
|
+
self.instruments
|
253
|
+
.worker_registered
|
254
|
+
.add(&self.ctx, 1, &self.kvs);
|
132
255
|
}
|
133
256
|
|
134
257
|
/// Record current number of available task slots. Context should have worker type set.
|
135
258
|
pub(crate) fn available_task_slots(&self, num: usize) {
|
136
|
-
|
259
|
+
self.instruments
|
260
|
+
.task_slots_available
|
261
|
+
.record(&self.ctx, num as u64, &self.kvs)
|
137
262
|
}
|
138
263
|
|
139
264
|
/// Record current number of pollers. Context should include poller type / task queue tag.
|
140
265
|
pub(crate) fn record_num_pollers(&self, num: usize) {
|
141
|
-
|
266
|
+
self.instruments
|
267
|
+
.num_pollers
|
268
|
+
.record(&self.ctx, num as u64, &self.kvs);
|
142
269
|
}
|
143
270
|
|
144
271
|
/// A workflow task found a cached workflow to run against
|
145
272
|
pub(crate) fn sticky_cache_hit(&self) {
|
146
|
-
|
273
|
+
self.instruments
|
274
|
+
.sticky_cache_hit
|
275
|
+
.add(&self.ctx, 1, &self.kvs);
|
147
276
|
}
|
148
277
|
|
149
278
|
/// A workflow task did not find a cached workflow
|
150
279
|
pub(crate) fn sticky_cache_miss(&self) {
|
151
|
-
|
280
|
+
self.instruments
|
281
|
+
.sticky_cache_miss
|
282
|
+
.add(&self.ctx, 1, &self.kvs);
|
152
283
|
}
|
153
284
|
|
154
285
|
/// Record current cache size (in number of wfs, not bytes)
|
155
286
|
pub(crate) fn cache_size(&self, size: u64) {
|
156
|
-
|
287
|
+
self.instruments
|
288
|
+
.sticky_cache_size
|
289
|
+
.record(&self.ctx, size, &self.kvs);
|
157
290
|
}
|
158
291
|
}
|
159
292
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
if
|
164
|
-
|
165
|
-
}
|
166
|
-
|
167
|
-
|
168
|
-
}
|
169
|
-
|
170
|
-
|
171
|
-
.get()
|
172
|
-
.map(|gtd| {
|
173
|
-
if gtd.no_temporal_prefix_for_metrics {
|
174
|
-
""
|
175
|
-
} else {
|
176
|
-
"temporal_"
|
177
|
-
}
|
178
|
-
})
|
179
|
-
.unwrap_or("")
|
180
|
-
}
|
293
|
+
impl Instruments {
|
294
|
+
fn new(telem: &TelemetryInstance) -> Self {
|
295
|
+
let no_op_meter: Meter;
|
296
|
+
let meter = if let Some(meter) = telem.get_metric_meter() {
|
297
|
+
meter
|
298
|
+
} else {
|
299
|
+
no_op_meter = NoopMeterProvider::default().meter("no_op");
|
300
|
+
TemporalMeter::new(&no_op_meter, "fakemetrics")
|
301
|
+
};
|
302
|
+
Self::new_explicit(meter)
|
303
|
+
}
|
181
304
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
305
|
+
fn new_explicit(meter: TemporalMeter) -> Self {
|
306
|
+
Self {
|
307
|
+
wf_completed_counter: meter.counter("workflow_completed"),
|
308
|
+
wf_canceled_counter: meter.counter("workflow_canceled"),
|
309
|
+
wf_failed_counter: meter.counter("workflow_failed"),
|
310
|
+
wf_cont_counter: meter.counter("workflow_continue_as_new"),
|
311
|
+
wf_e2e_latency: meter.histogram(WF_E2E_LATENCY_NAME),
|
312
|
+
wf_task_queue_poll_empty_counter: meter.counter("workflow_task_queue_poll_empty"),
|
313
|
+
wf_task_queue_poll_succeed_counter: meter.counter("workflow_task_queue_poll_succeed"),
|
314
|
+
wf_task_execution_failure_counter: meter.counter("workflow_task_execution_failed"),
|
315
|
+
wf_task_sched_to_start_latency: meter.histogram(WF_TASK_SCHED_TO_START_LATENCY_NAME),
|
316
|
+
wf_task_replay_latency: meter.histogram(WF_TASK_REPLAY_LATENCY_NAME),
|
317
|
+
wf_task_execution_latency: meter.histogram(WF_TASK_EXECUTION_LATENCY_NAME),
|
318
|
+
act_poll_no_task: meter.counter("activity_poll_no_task"),
|
319
|
+
act_task_received_counter: meter.counter("activity_task_received"),
|
320
|
+
act_execution_failed: meter.counter("activity_execution_failed"),
|
321
|
+
act_sched_to_start_latency: meter.histogram(ACT_SCHED_TO_START_LATENCY_NAME),
|
322
|
+
act_exec_latency: meter.histogram(ACT_EXEC_LATENCY_NAME),
|
323
|
+
// name kept as worker start for compat with old sdk / what users expect
|
324
|
+
worker_registered: meter.counter("worker_start"),
|
325
|
+
num_pollers: meter.histogram(NUM_POLLERS_NAME),
|
326
|
+
task_slots_available: meter.histogram(TASK_SLOTS_AVAILABLE_NAME),
|
327
|
+
sticky_cache_hit: meter.counter("sticky_cache_hit"),
|
328
|
+
sticky_cache_miss: meter.counter("sticky_cache_miss"),
|
329
|
+
sticky_cache_size: meter.histogram(STICKY_CACHE_SIZE_NAME),
|
197
330
|
}
|
198
|
-
}
|
331
|
+
}
|
199
332
|
}
|
200
333
|
|
201
334
|
const KEY_NAMESPACE: &str = "namespace";
|
@@ -204,6 +337,7 @@ const KEY_TASK_QUEUE: &str = "task_queue";
|
|
204
337
|
const KEY_ACT_TYPE: &str = "activity_type";
|
205
338
|
const KEY_POLLER_TYPE: &str = "poller_type";
|
206
339
|
const KEY_WORKER_TYPE: &str = "worker_type";
|
340
|
+
const KEY_EAGER: &str = "eager";
|
207
341
|
|
208
342
|
pub(crate) fn workflow_poller() -> KeyValue {
|
209
343
|
KeyValue::new(KEY_POLLER_TYPE, "workflow_task")
|
@@ -224,85 +358,27 @@ pub(crate) fn workflow_type(ty: String) -> KeyValue {
|
|
224
358
|
KeyValue::new(KEY_WF_TYPE, ty)
|
225
359
|
}
|
226
360
|
pub(crate) fn workflow_worker_type() -> KeyValue {
|
227
|
-
KeyValue
|
228
|
-
key: opentelemetry::Key::from_static_str(KEY_WORKER_TYPE),
|
229
|
-
value: opentelemetry::Value::String("WorkflowWorker".into()),
|
230
|
-
}
|
361
|
+
KeyValue::new(KEY_WORKER_TYPE, "WorkflowWorker")
|
231
362
|
}
|
232
363
|
pub(crate) fn activity_worker_type() -> KeyValue {
|
233
|
-
KeyValue
|
234
|
-
key: opentelemetry::Key::from_static_str(KEY_WORKER_TYPE),
|
235
|
-
value: opentelemetry::Value::String("ActivityWorker".into()),
|
236
|
-
}
|
364
|
+
KeyValue::new(KEY_WORKER_TYPE, "ActivityWorker")
|
237
365
|
}
|
238
366
|
pub(crate) fn local_activity_worker_type() -> KeyValue {
|
239
|
-
KeyValue
|
240
|
-
|
241
|
-
|
242
|
-
|
367
|
+
KeyValue::new(KEY_WORKER_TYPE, "LocalActivityWorker")
|
368
|
+
}
|
369
|
+
pub(crate) fn eager(is_eager: bool) -> KeyValue {
|
370
|
+
KeyValue::new(KEY_EAGER, is_eager)
|
243
371
|
}
|
244
372
|
|
245
|
-
tm!(ctr, WF_COMPLETED_COUNTER, "workflow_completed");
|
246
|
-
tm!(ctr, WF_CANCELED_COUNTER, "workflow_canceled");
|
247
|
-
tm!(ctr, WF_FAILED_COUNTER, "workflow_failed");
|
248
|
-
tm!(ctr, WF_CONT_COUNTER, "workflow_continue_as_new");
|
249
373
|
const WF_E2E_LATENCY_NAME: &str = "workflow_endtoend_latency";
|
250
|
-
tm!(vr_u64, WF_E2E_LATENCY, WF_E2E_LATENCY_NAME);
|
251
|
-
|
252
|
-
tm!(
|
253
|
-
ctr,
|
254
|
-
WF_TASK_QUEUE_POLL_EMPTY_COUNTER,
|
255
|
-
"workflow_task_queue_poll_empty"
|
256
|
-
);
|
257
|
-
tm!(
|
258
|
-
ctr,
|
259
|
-
WF_TASK_QUEUE_POLL_SUCCEED_COUNTER,
|
260
|
-
"workflow_task_queue_poll_succeed"
|
261
|
-
);
|
262
|
-
tm!(
|
263
|
-
ctr,
|
264
|
-
WF_TASK_EXECUTION_FAILURE_COUNTER,
|
265
|
-
"workflow_task_execution_failed"
|
266
|
-
);
|
267
374
|
const WF_TASK_SCHED_TO_START_LATENCY_NAME: &str = "workflow_task_schedule_to_start_latency";
|
268
|
-
tm!(
|
269
|
-
vr_u64,
|
270
|
-
WF_TASK_SCHED_TO_START_LATENCY,
|
271
|
-
WF_TASK_SCHED_TO_START_LATENCY_NAME
|
272
|
-
);
|
273
375
|
const WF_TASK_REPLAY_LATENCY_NAME: &str = "workflow_task_replay_latency";
|
274
|
-
tm!(vr_u64, WF_TASK_REPLAY_LATENCY, WF_TASK_REPLAY_LATENCY_NAME);
|
275
376
|
const WF_TASK_EXECUTION_LATENCY_NAME: &str = "workflow_task_execution_latency";
|
276
|
-
tm!(
|
277
|
-
vr_u64,
|
278
|
-
WF_TASK_EXECUTION_LATENCY,
|
279
|
-
WF_TASK_EXECUTION_LATENCY_NAME
|
280
|
-
);
|
281
|
-
|
282
|
-
tm!(ctr, ACT_POLL_NO_TASK, "activity_poll_no_task");
|
283
|
-
tm!(ctr, ACT_EXECUTION_FAILED, "activity_execution_failed");
|
284
|
-
// Act task unregistered can't be known by core right now since it's not well defined as an
|
285
|
-
// activity result. We could add a flag to the failed activity result if desired.
|
286
377
|
const ACT_SCHED_TO_START_LATENCY_NAME: &str = "activity_schedule_to_start_latency";
|
287
|
-
tm!(
|
288
|
-
vr_u64,
|
289
|
-
ACT_SCHED_TO_START_LATENCY,
|
290
|
-
ACT_SCHED_TO_START_LATENCY_NAME
|
291
|
-
);
|
292
378
|
const ACT_EXEC_LATENCY_NAME: &str = "activity_execution_latency";
|
293
|
-
tm!(vr_u64, ACT_EXEC_LATENCY, ACT_EXEC_LATENCY_NAME);
|
294
|
-
|
295
|
-
// name kept as worker start for compat with old sdk / what users expect
|
296
|
-
tm!(ctr, WORKER_REGISTERED, "worker_start");
|
297
379
|
const NUM_POLLERS_NAME: &str = "num_pollers";
|
298
|
-
tm!(vr_u64, NUM_POLLERS, NUM_POLLERS_NAME);
|
299
380
|
const TASK_SLOTS_AVAILABLE_NAME: &str = "worker_task_slots_available";
|
300
|
-
tm!(vr_u64, TASK_SLOTS_AVAILABLE, TASK_SLOTS_AVAILABLE_NAME);
|
301
|
-
|
302
|
-
tm!(ctr, STICKY_CACHE_HIT, "sticky_cache_hit");
|
303
|
-
tm!(ctr, STICKY_CACHE_MISS, "sticky_cache_miss");
|
304
381
|
const STICKY_CACHE_SIZE_NAME: &str = "sticky_cache_size";
|
305
|
-
tm!(vr_u64, STICKY_CACHE_SIZE, STICKY_CACHE_SIZE_NAME);
|
306
382
|
|
307
383
|
/// Artisanal, handcrafted latency buckets for workflow e2e latency which should expose a useful
|
308
384
|
/// set of buckets for < 1 day runtime workflows. Beyond that, this metric probably isn't very
|
@@ -335,15 +411,18 @@ static WF_TASK_MS_BUCKETS: &[f64] = &[1., 10., 20., 50., 100., 200., 500., 1000.
|
|
335
411
|
static ACT_EXE_MS_BUCKETS: &[f64] = &[50., 100., 500., 1000., 5000., 10_000., 60_000.];
|
336
412
|
|
337
413
|
/// Schedule-to-start latency buckets for both WFT and AT
|
338
|
-
static TASK_SCHED_TO_START_MS_BUCKETS: &[f64] =
|
414
|
+
static TASK_SCHED_TO_START_MS_BUCKETS: &[f64] =
|
415
|
+
&[100., 500., 1000., 5000., 10_000., 100_000., 1_000_000.];
|
339
416
|
|
340
417
|
/// Default buckets. Should never really be used as they will be meaningless for many things, but
|
341
418
|
/// broadly it's trying to represent latencies in millis.
|
342
419
|
pub(super) static DEFAULT_MS_BUCKETS: &[f64] = &[50., 100., 500., 1000., 2500., 10_000.];
|
343
420
|
|
344
421
|
/// Chooses appropriate aggregators for our metrics
|
345
|
-
#[derive(Debug)]
|
346
|
-
pub struct SDKAggSelector
|
422
|
+
#[derive(Debug, Clone)]
|
423
|
+
pub struct SDKAggSelector {
|
424
|
+
pub metric_prefix: &'static str,
|
425
|
+
}
|
347
426
|
|
348
427
|
impl AggregatorSelector for SDKAggSelector {
|
349
428
|
fn aggregator_for(&self, descriptor: &Descriptor) -> Option<Arc<dyn Aggregator + Send + Sync>> {
|
@@ -355,7 +434,7 @@ impl AggregatorSelector for SDKAggSelector {
|
|
355
434
|
if *descriptor.instrument_kind() == InstrumentKind::Histogram {
|
356
435
|
let dname = descriptor
|
357
436
|
.name()
|
358
|
-
.strip_prefix(metric_prefix
|
437
|
+
.strip_prefix(self.metric_prefix)
|
359
438
|
.unwrap_or_else(|| descriptor.name());
|
360
439
|
// Some recorders are just gauges
|
361
440
|
match dname {
|