temporalio 0.0.0 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +301 -0
- data/bridge/Cargo.lock +2888 -0
- data/bridge/Cargo.toml +27 -0
- data/bridge/sdk-core/ARCHITECTURE.md +76 -0
- data/bridge/sdk-core/Cargo.lock +2606 -0
- data/bridge/sdk-core/Cargo.toml +2 -0
- data/bridge/sdk-core/LICENSE.txt +23 -0
- data/bridge/sdk-core/README.md +104 -0
- data/bridge/sdk-core/arch_docs/diagrams/README.md +10 -0
- data/bridge/sdk-core/arch_docs/diagrams/sticky_queues.puml +40 -0
- data/bridge/sdk-core/arch_docs/diagrams/workflow_internals.svg +1 -0
- data/bridge/sdk-core/arch_docs/sticky_queues.md +51 -0
- data/bridge/sdk-core/client/Cargo.toml +40 -0
- data/bridge/sdk-core/client/LICENSE.txt +23 -0
- data/bridge/sdk-core/client/src/lib.rs +1286 -0
- data/bridge/sdk-core/client/src/metrics.rs +165 -0
- data/bridge/sdk-core/client/src/raw.rs +932 -0
- data/bridge/sdk-core/client/src/retry.rs +751 -0
- data/bridge/sdk-core/client/src/workflow_handle/mod.rs +185 -0
- data/bridge/sdk-core/core/Cargo.toml +116 -0
- data/bridge/sdk-core/core/LICENSE.txt +23 -0
- data/bridge/sdk-core/core/benches/workflow_replay.rs +76 -0
- data/bridge/sdk-core/core/src/abstractions.rs +166 -0
- data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +1014 -0
- data/bridge/sdk-core/core/src/core_tests/child_workflows.rs +221 -0
- data/bridge/sdk-core/core/src/core_tests/determinism.rs +107 -0
- data/bridge/sdk-core/core/src/core_tests/local_activities.rs +925 -0
- data/bridge/sdk-core/core/src/core_tests/mod.rs +100 -0
- data/bridge/sdk-core/core/src/core_tests/queries.rs +894 -0
- data/bridge/sdk-core/core/src/core_tests/replay_flag.rs +65 -0
- data/bridge/sdk-core/core/src/core_tests/workers.rs +259 -0
- data/bridge/sdk-core/core/src/core_tests/workflow_cancels.rs +124 -0
- data/bridge/sdk-core/core/src/core_tests/workflow_tasks.rs +2090 -0
- data/bridge/sdk-core/core/src/ephemeral_server/mod.rs +515 -0
- data/bridge/sdk-core/core/src/lib.rs +282 -0
- data/bridge/sdk-core/core/src/pollers/mod.rs +54 -0
- data/bridge/sdk-core/core/src/pollers/poll_buffer.rs +297 -0
- data/bridge/sdk-core/core/src/protosext/mod.rs +428 -0
- data/bridge/sdk-core/core/src/replay/mod.rs +215 -0
- data/bridge/sdk-core/core/src/retry_logic.rs +202 -0
- data/bridge/sdk-core/core/src/telemetry/log_export.rs +190 -0
- data/bridge/sdk-core/core/src/telemetry/metrics.rs +428 -0
- data/bridge/sdk-core/core/src/telemetry/mod.rs +407 -0
- data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +78 -0
- data/bridge/sdk-core/core/src/test_help/mod.rs +889 -0
- data/bridge/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +580 -0
- data/bridge/sdk-core/core/src/worker/activities/local_activities.rs +1048 -0
- data/bridge/sdk-core/core/src/worker/activities.rs +481 -0
- data/bridge/sdk-core/core/src/worker/client/mocks.rs +87 -0
- data/bridge/sdk-core/core/src/worker/client.rs +373 -0
- data/bridge/sdk-core/core/src/worker/mod.rs +570 -0
- data/bridge/sdk-core/core/src/worker/workflow/bridge.rs +37 -0
- data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +101 -0
- data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +532 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +907 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +294 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +167 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +858 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +136 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +157 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +129 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +1450 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +316 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +178 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +708 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +439 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +435 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +175 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +242 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +96 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +1200 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +272 -0
- data/bridge/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +198 -0
- data/bridge/sdk-core/core/src/worker/workflow/managed_run.rs +655 -0
- data/bridge/sdk-core/core/src/worker/workflow/mod.rs +1200 -0
- data/bridge/sdk-core/core/src/worker/workflow/run_cache.rs +145 -0
- data/bridge/sdk-core/core/src/worker/workflow/wft_poller.rs +88 -0
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream.rs +985 -0
- data/bridge/sdk-core/core-api/Cargo.toml +32 -0
- data/bridge/sdk-core/core-api/LICENSE.txt +23 -0
- data/bridge/sdk-core/core-api/src/errors.rs +95 -0
- data/bridge/sdk-core/core-api/src/lib.rs +109 -0
- data/bridge/sdk-core/core-api/src/telemetry.rs +147 -0
- data/bridge/sdk-core/core-api/src/worker.rs +148 -0
- data/bridge/sdk-core/etc/deps.svg +162 -0
- data/bridge/sdk-core/etc/dynamic-config.yaml +2 -0
- data/bridge/sdk-core/etc/otel-collector-config.yaml +36 -0
- data/bridge/sdk-core/etc/prometheus.yaml +6 -0
- data/bridge/sdk-core/etc/regen-depgraph.sh +5 -0
- data/bridge/sdk-core/fsm/Cargo.toml +18 -0
- data/bridge/sdk-core/fsm/LICENSE.txt +23 -0
- data/bridge/sdk-core/fsm/README.md +3 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +27 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/LICENSE.txt +23 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +647 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/progress.rs +8 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.rs +18 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +12 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dynamic_dest_pass.rs +41 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/forgot_name_fail.rs +14 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/forgot_name_fail.stderr +11 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/handler_arg_pass.rs +32 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/handler_pass.rs +31 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/medium_complex_pass.rs +46 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.rs +29 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +12 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/simple_pass.rs +32 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.rs +18 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.stderr +5 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.rs +11 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.stderr +5 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.rs +11 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.stderr +5 -0
- data/bridge/sdk-core/fsm/rustfsm_trait/Cargo.toml +14 -0
- data/bridge/sdk-core/fsm/rustfsm_trait/LICENSE.txt +23 -0
- data/bridge/sdk-core/fsm/rustfsm_trait/src/lib.rs +249 -0
- data/bridge/sdk-core/fsm/src/lib.rs +2 -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/histories/fail_wf_task.bin +0 -0
- data/bridge/sdk-core/histories/timer_workflow_history.bin +0 -0
- data/bridge/sdk-core/integ-with-otel.sh +7 -0
- data/bridge/sdk-core/protos/api_upstream/README.md +9 -0
- data/bridge/sdk-core/protos/api_upstream/api-linter.yaml +40 -0
- data/bridge/sdk-core/protos/api_upstream/buf.yaml +9 -0
- 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/build/tools.go +29 -0
- data/bridge/sdk-core/protos/api_upstream/dependencies/gogoproto/gogo.proto +141 -0
- data/bridge/sdk-core/protos/api_upstream/go.mod +6 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +89 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +260 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +112 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +47 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +57 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +56 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +170 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +118 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/interaction_type.proto +39 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +51 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +50 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +41 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +60 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +59 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +40 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +122 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +108 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +114 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +56 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +758 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/interaction/v1/message.proto +87 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +97 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +121 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +80 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +61 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +55 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +379 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +108 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +59 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +146 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +1168 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +415 -0
- data/bridge/sdk-core/protos/grpc/health/v1/health.proto +63 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +78 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +79 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +77 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/common/common.proto +15 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +30 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +30 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +263 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +304 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +29 -0
- data/bridge/sdk-core/protos/testsrv_upstream/api-linter.yaml +38 -0
- data/bridge/sdk-core/protos/testsrv_upstream/buf.yaml +13 -0
- data/bridge/sdk-core/protos/testsrv_upstream/dependencies/gogoproto/gogo.proto +141 -0
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +63 -0
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +90 -0
- data/bridge/sdk-core/rustfmt.toml +1 -0
- data/bridge/sdk-core/sdk/Cargo.toml +47 -0
- data/bridge/sdk-core/sdk/LICENSE.txt +23 -0
- data/bridge/sdk-core/sdk/src/activity_context.rs +230 -0
- data/bridge/sdk-core/sdk/src/app_data.rs +37 -0
- data/bridge/sdk-core/sdk/src/interceptors.rs +50 -0
- data/bridge/sdk-core/sdk/src/lib.rs +794 -0
- data/bridge/sdk-core/sdk/src/payload_converter.rs +11 -0
- data/bridge/sdk-core/sdk/src/workflow_context/options.rs +295 -0
- data/bridge/sdk-core/sdk/src/workflow_context.rs +694 -0
- data/bridge/sdk-core/sdk/src/workflow_future.rs +499 -0
- data/bridge/sdk-core/sdk-core-protos/Cargo.toml +30 -0
- data/bridge/sdk-core/sdk-core-protos/LICENSE.txt +23 -0
- data/bridge/sdk-core/sdk-core-protos/build.rs +107 -0
- data/bridge/sdk-core/sdk-core-protos/src/constants.rs +7 -0
- data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +544 -0
- data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +230 -0
- data/bridge/sdk-core/sdk-core-protos/src/lib.rs +1970 -0
- data/bridge/sdk-core/sdk-core-protos/src/task_token.rs +38 -0
- data/bridge/sdk-core/sdk-core-protos/src/utilities.rs +14 -0
- data/bridge/sdk-core/test-utils/Cargo.toml +36 -0
- data/bridge/sdk-core/test-utils/src/canned_histories.rs +1579 -0
- data/bridge/sdk-core/test-utils/src/histfetch.rs +28 -0
- data/bridge/sdk-core/test-utils/src/lib.rs +650 -0
- data/bridge/sdk-core/tests/integ_tests/client_tests.rs +36 -0
- data/bridge/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +128 -0
- data/bridge/sdk-core/tests/integ_tests/heartbeat_tests.rs +221 -0
- data/bridge/sdk-core/tests/integ_tests/metrics_tests.rs +37 -0
- data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +133 -0
- data/bridge/sdk-core/tests/integ_tests/queries_tests.rs +437 -0
- data/bridge/sdk-core/tests/integ_tests/visibility_tests.rs +93 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/activities.rs +878 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +61 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +59 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +58 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +50 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +60 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +54 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +788 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +53 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/patches.rs +113 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/replay.rs +223 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/resets.rs +93 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/signals.rs +167 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +99 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/timers.rs +131 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +75 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests.rs +597 -0
- data/bridge/sdk-core/tests/load_tests.rs +191 -0
- data/bridge/sdk-core/tests/main.rs +113 -0
- data/bridge/sdk-core/tests/runner.rs +93 -0
- data/bridge/src/connection.rs +186 -0
- data/bridge/src/lib.rs +239 -0
- data/bridge/src/runtime.rs +54 -0
- data/bridge/src/worker.rs +124 -0
- data/ext/Rakefile +9 -0
- data/lib/bridge.so +0 -0
- data/lib/gen/dependencies/gogoproto/gogo_pb.rb +14 -0
- data/lib/gen/temporal/api/batch/v1/message_pb.rb +50 -0
- data/lib/gen/temporal/api/command/v1/message_pb.rb +174 -0
- data/lib/gen/temporal/api/common/v1/message_pb.rb +69 -0
- data/lib/gen/temporal/api/enums/v1/batch_operation_pb.rb +33 -0
- data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +39 -0
- data/lib/gen/temporal/api/enums/v1/common_pb.rb +42 -0
- data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +68 -0
- data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +77 -0
- data/lib/gen/temporal/api/enums/v1/interaction_type_pb.rb +25 -0
- data/lib/gen/temporal/api/enums/v1/namespace_pb.rb +37 -0
- data/lib/gen/temporal/api/enums/v1/query_pb.rb +31 -0
- data/lib/gen/temporal/api/enums/v1/reset_pb.rb +24 -0
- data/lib/gen/temporal/api/enums/v1/schedule_pb.rb +28 -0
- data/lib/gen/temporal/api/enums/v1/task_queue_pb.rb +30 -0
- data/lib/gen/temporal/api/enums/v1/update_pb.rb +23 -0
- data/lib/gen/temporal/api/enums/v1/workflow_pb.rb +89 -0
- data/lib/gen/temporal/api/errordetails/v1/message_pb.rb +84 -0
- data/lib/gen/temporal/api/failure/v1/message_pb.rb +83 -0
- data/lib/gen/temporal/api/filter/v1/message_pb.rb +40 -0
- data/lib/gen/temporal/api/history/v1/message_pb.rb +490 -0
- data/lib/gen/temporal/api/interaction/v1/message_pb.rb +49 -0
- data/lib/gen/temporal/api/namespace/v1/message_pb.rb +63 -0
- data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +85 -0
- data/lib/gen/temporal/api/operatorservice/v1/service_pb.rb +20 -0
- data/lib/gen/temporal/api/query/v1/message_pb.rb +38 -0
- data/lib/gen/temporal/api/replication/v1/message_pb.rb +37 -0
- data/lib/gen/temporal/api/schedule/v1/message_pb.rb +149 -0
- data/lib/gen/temporal/api/taskqueue/v1/message_pb.rb +73 -0
- data/lib/gen/temporal/api/version/v1/message_pb.rb +41 -0
- data/lib/gen/temporal/api/workflow/v1/message_pb.rb +111 -0
- data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +788 -0
- data/lib/gen/temporal/api/workflowservice/v1/service_pb.rb +20 -0
- data/lib/gen/temporal/sdk/core/activity_result/activity_result_pb.rb +58 -0
- data/lib/gen/temporal/sdk/core/activity_task/activity_task_pb.rb +57 -0
- data/lib/gen/temporal/sdk/core/bridge/bridge_pb.rb +222 -0
- data/lib/gen/temporal/sdk/core/child_workflow/child_workflow_pb.rb +57 -0
- data/lib/gen/temporal/sdk/core/common/common_pb.rb +22 -0
- data/lib/gen/temporal/sdk/core/core_interface_pb.rb +34 -0
- data/lib/gen/temporal/sdk/core/external_data/external_data_pb.rb +27 -0
- data/lib/gen/temporal/sdk/core/workflow_activation/workflow_activation_pb.rb +165 -0
- data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +196 -0
- data/lib/gen/temporal/sdk/core/workflow_completion/workflow_completion_pb.rb +34 -0
- data/lib/temporalio/activity/context.rb +97 -0
- data/lib/temporalio/activity/info.rb +67 -0
- data/lib/temporalio/activity.rb +85 -0
- data/lib/temporalio/bridge/error.rb +8 -0
- data/lib/temporalio/bridge.rb +14 -0
- data/lib/temporalio/client/implementation.rb +340 -0
- data/lib/temporalio/client/workflow_handle.rb +243 -0
- data/lib/temporalio/client.rb +131 -0
- data/lib/temporalio/connection.rb +751 -0
- data/lib/temporalio/data_converter.rb +191 -0
- data/lib/temporalio/error/failure.rb +194 -0
- data/lib/temporalio/error/workflow_failure.rb +19 -0
- data/lib/temporalio/errors.rb +40 -0
- data/lib/temporalio/failure_converter/base.rb +26 -0
- data/lib/temporalio/failure_converter/basic.rb +319 -0
- data/lib/temporalio/failure_converter.rb +7 -0
- data/lib/temporalio/interceptor/chain.rb +28 -0
- data/lib/temporalio/interceptor/client.rb +123 -0
- data/lib/temporalio/payload_codec/base.rb +32 -0
- data/lib/temporalio/payload_converter/base.rb +24 -0
- data/lib/temporalio/payload_converter/bytes.rb +27 -0
- data/lib/temporalio/payload_converter/composite.rb +49 -0
- data/lib/temporalio/payload_converter/encoding_base.rb +35 -0
- data/lib/temporalio/payload_converter/json.rb +26 -0
- data/lib/temporalio/payload_converter/nil.rb +26 -0
- data/lib/temporalio/payload_converter.rb +14 -0
- data/lib/temporalio/retry_policy.rb +82 -0
- data/lib/temporalio/retry_state.rb +35 -0
- data/lib/temporalio/runtime.rb +25 -0
- data/lib/temporalio/timeout_type.rb +29 -0
- data/lib/temporalio/version.rb +3 -0
- data/lib/temporalio/worker/activity_runner.rb +92 -0
- data/lib/temporalio/worker/activity_worker.rb +138 -0
- data/lib/temporalio/worker/reactor.rb +46 -0
- data/lib/temporalio/worker/runner.rb +63 -0
- data/lib/temporalio/worker/sync_worker.rb +88 -0
- data/lib/temporalio/worker/thread_pool_executor.rb +51 -0
- data/lib/temporalio/worker.rb +198 -0
- data/lib/temporalio/workflow/execution_info.rb +54 -0
- data/lib/temporalio/workflow/execution_status.rb +36 -0
- data/lib/temporalio/workflow/id_reuse_policy.rb +36 -0
- data/lib/temporalio/workflow/query_reject_condition.rb +33 -0
- data/lib/temporalio.rb +12 -1
- data/lib/thermite_patch.rb +23 -0
- data/temporalio.gemspec +45 -0
- metadata +566 -9
- data/lib/temporal/version.rb +0 -3
- data/lib/temporal.rb +0 -4
- data/temporal.gemspec +0 -20
@@ -0,0 +1,428 @@
|
|
1
|
+
use crate::telemetry::TelemetryInstance;
|
2
|
+
use opentelemetry::{
|
3
|
+
metrics::{noop::NoopMeterProvider, Counter, Histogram, Meter, MeterProvider},
|
4
|
+
sdk::{
|
5
|
+
export::metrics::AggregatorSelector,
|
6
|
+
metrics::{
|
7
|
+
aggregators::{histogram, last_value, sum, Aggregator},
|
8
|
+
sdk_api::{Descriptor, InstrumentKind},
|
9
|
+
},
|
10
|
+
},
|
11
|
+
Context, KeyValue,
|
12
|
+
};
|
13
|
+
use std::{sync::Arc, time::Duration};
|
14
|
+
use temporal_sdk_core_api::telemetry::CoreTelemetry;
|
15
|
+
|
16
|
+
/// Used to track context associated with metrics, and record/update them
|
17
|
+
///
|
18
|
+
/// Possible improvement: make generic over some type tag so that methods are only exposed if the
|
19
|
+
/// appropriate k/vs have already been set.
|
20
|
+
#[derive(Clone)]
|
21
|
+
pub(crate) struct MetricsContext {
|
22
|
+
ctx: Context,
|
23
|
+
kvs: Arc<Vec<KeyValue>>,
|
24
|
+
instruments: Arc<Instruments>,
|
25
|
+
}
|
26
|
+
|
27
|
+
struct Instruments {
|
28
|
+
wf_completed_counter: Counter<u64>,
|
29
|
+
wf_canceled_counter: Counter<u64>,
|
30
|
+
wf_failed_counter: Counter<u64>,
|
31
|
+
wf_cont_counter: Counter<u64>,
|
32
|
+
wf_e2e_latency: Histogram<u64>,
|
33
|
+
wf_task_queue_poll_empty_counter: Counter<u64>,
|
34
|
+
wf_task_queue_poll_succeed_counter: Counter<u64>,
|
35
|
+
wf_task_execution_failure_counter: Counter<u64>,
|
36
|
+
wf_task_sched_to_start_latency: Histogram<u64>,
|
37
|
+
wf_task_replay_latency: Histogram<u64>,
|
38
|
+
wf_task_execution_latency: Histogram<u64>,
|
39
|
+
act_poll_no_task: Counter<u64>,
|
40
|
+
act_task_received_counter: Counter<u64>,
|
41
|
+
act_execution_failed: Counter<u64>,
|
42
|
+
act_sched_to_start_latency: Histogram<u64>,
|
43
|
+
act_exec_latency: Histogram<u64>,
|
44
|
+
worker_registered: Counter<u64>,
|
45
|
+
num_pollers: Histogram<u64>,
|
46
|
+
task_slots_available: Histogram<u64>,
|
47
|
+
sticky_cache_hit: Counter<u64>,
|
48
|
+
sticky_cache_miss: Counter<u64>,
|
49
|
+
sticky_cache_size: Histogram<u64>,
|
50
|
+
}
|
51
|
+
|
52
|
+
impl MetricsContext {
|
53
|
+
pub(crate) fn no_op() -> Self {
|
54
|
+
Self {
|
55
|
+
ctx: Default::default(),
|
56
|
+
kvs: Default::default(),
|
57
|
+
instruments: Arc::new(Instruments::new_explicit(
|
58
|
+
&NoopMeterProvider::new().meter("fakemeter"),
|
59
|
+
"fakemetrics",
|
60
|
+
)),
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
pub(crate) fn top_level(namespace: String, telemetry: &TelemetryInstance) -> Self {
|
65
|
+
let kvs = vec![KeyValue::new(KEY_NAMESPACE, namespace)];
|
66
|
+
Self {
|
67
|
+
ctx: Context::current(),
|
68
|
+
kvs: Arc::new(kvs),
|
69
|
+
instruments: Arc::new(Instruments::new(telemetry)),
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
pub(crate) fn with_task_q(mut self, tq: String) -> Self {
|
74
|
+
Arc::make_mut(&mut self.kvs).push(task_queue(tq));
|
75
|
+
self
|
76
|
+
}
|
77
|
+
|
78
|
+
/// Extend an existing metrics context with new attributes
|
79
|
+
pub(crate) fn with_new_attrs(&self, new_kvs: impl IntoIterator<Item = KeyValue>) -> Self {
|
80
|
+
let mut kvs = self.kvs.clone();
|
81
|
+
Arc::make_mut(&mut kvs).extend(new_kvs);
|
82
|
+
Self {
|
83
|
+
ctx: Context::current(),
|
84
|
+
kvs,
|
85
|
+
instruments: self.instruments.clone(),
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
/// A workflow task queue poll succeeded
|
90
|
+
pub(crate) fn wf_tq_poll_ok(&self) {
|
91
|
+
self.instruments
|
92
|
+
.wf_task_queue_poll_succeed_counter
|
93
|
+
.add(&self.ctx, 1, &self.kvs);
|
94
|
+
}
|
95
|
+
|
96
|
+
/// A workflow task queue poll timed out / had empty response
|
97
|
+
pub(crate) fn wf_tq_poll_empty(&self) {
|
98
|
+
self.instruments
|
99
|
+
.wf_task_queue_poll_empty_counter
|
100
|
+
.add(&self.ctx, 1, &self.kvs);
|
101
|
+
}
|
102
|
+
|
103
|
+
/// A workflow task execution failed
|
104
|
+
pub(crate) fn wf_task_failed(&self) {
|
105
|
+
self.instruments
|
106
|
+
.wf_task_execution_failure_counter
|
107
|
+
.add(&self.ctx, 1, &self.kvs);
|
108
|
+
}
|
109
|
+
|
110
|
+
/// A workflow completed successfully
|
111
|
+
pub(crate) fn wf_completed(&self) {
|
112
|
+
self.instruments
|
113
|
+
.wf_completed_counter
|
114
|
+
.add(&self.ctx, 1, &self.kvs);
|
115
|
+
}
|
116
|
+
|
117
|
+
/// A workflow ended cancelled
|
118
|
+
pub(crate) fn wf_canceled(&self) {
|
119
|
+
self.instruments
|
120
|
+
.wf_canceled_counter
|
121
|
+
.add(&self.ctx, 1, &self.kvs);
|
122
|
+
}
|
123
|
+
|
124
|
+
/// A workflow ended failed
|
125
|
+
pub(crate) fn wf_failed(&self) {
|
126
|
+
self.instruments
|
127
|
+
.wf_failed_counter
|
128
|
+
.add(&self.ctx, 1, &self.kvs);
|
129
|
+
}
|
130
|
+
|
131
|
+
/// A workflow continued as new
|
132
|
+
pub(crate) fn wf_continued_as_new(&self) {
|
133
|
+
self.instruments
|
134
|
+
.wf_cont_counter
|
135
|
+
.add(&self.ctx, 1, &self.kvs);
|
136
|
+
}
|
137
|
+
|
138
|
+
/// Record workflow total execution time in milliseconds
|
139
|
+
pub(crate) fn wf_e2e_latency(&self, dur: Duration) {
|
140
|
+
self.instruments
|
141
|
+
.wf_e2e_latency
|
142
|
+
.record(&self.ctx, dur.as_millis() as u64, &self.kvs);
|
143
|
+
}
|
144
|
+
|
145
|
+
/// Record workflow task schedule to start time in millis
|
146
|
+
pub(crate) fn wf_task_sched_to_start_latency(&self, dur: Duration) {
|
147
|
+
self.instruments.wf_task_sched_to_start_latency.record(
|
148
|
+
&self.ctx,
|
149
|
+
dur.as_millis() as u64,
|
150
|
+
&self.kvs,
|
151
|
+
);
|
152
|
+
}
|
153
|
+
|
154
|
+
/// Record workflow task execution time in milliseconds
|
155
|
+
pub(crate) fn wf_task_latency(&self, dur: Duration) {
|
156
|
+
self.instruments.wf_task_execution_latency.record(
|
157
|
+
&self.ctx,
|
158
|
+
dur.as_millis() as u64,
|
159
|
+
&self.kvs,
|
160
|
+
);
|
161
|
+
}
|
162
|
+
|
163
|
+
/// Record time it takes to catch up on replaying a WFT
|
164
|
+
pub(crate) fn wf_task_replay_latency(&self, dur: Duration) {
|
165
|
+
self.instruments.wf_task_replay_latency.record(
|
166
|
+
&self.ctx,
|
167
|
+
dur.as_millis() as u64,
|
168
|
+
&self.kvs,
|
169
|
+
);
|
170
|
+
}
|
171
|
+
|
172
|
+
/// An activity long poll timed out
|
173
|
+
pub(crate) fn act_poll_timeout(&self) {
|
174
|
+
self.instruments
|
175
|
+
.act_poll_no_task
|
176
|
+
.add(&self.ctx, 1, &self.kvs);
|
177
|
+
}
|
178
|
+
|
179
|
+
/// A count of activity tasks received
|
180
|
+
pub(crate) fn act_task_received(&self) {
|
181
|
+
self.instruments
|
182
|
+
.act_task_received_counter
|
183
|
+
.add(&self.ctx, 1, &self.kvs);
|
184
|
+
}
|
185
|
+
|
186
|
+
/// An activity execution failed
|
187
|
+
pub(crate) fn act_execution_failed(&self) {
|
188
|
+
self.instruments
|
189
|
+
.act_execution_failed
|
190
|
+
.add(&self.ctx, 1, &self.kvs);
|
191
|
+
}
|
192
|
+
|
193
|
+
/// Record activity task schedule to start time in millis
|
194
|
+
pub(crate) fn act_sched_to_start_latency(&self, dur: Duration) {
|
195
|
+
self.instruments.act_sched_to_start_latency.record(
|
196
|
+
&self.ctx,
|
197
|
+
dur.as_millis() as u64,
|
198
|
+
&self.kvs,
|
199
|
+
);
|
200
|
+
}
|
201
|
+
|
202
|
+
/// Record time it took to complete activity execution, from the time core generated the
|
203
|
+
/// activity task, to the time lang responded with a completion (failure or success).
|
204
|
+
pub(crate) fn act_execution_latency(&self, dur: Duration) {
|
205
|
+
self.instruments
|
206
|
+
.act_exec_latency
|
207
|
+
.record(&self.ctx, dur.as_millis() as u64, &self.kvs);
|
208
|
+
}
|
209
|
+
|
210
|
+
/// A worker was registered
|
211
|
+
pub(crate) fn worker_registered(&self) {
|
212
|
+
self.instruments
|
213
|
+
.worker_registered
|
214
|
+
.add(&self.ctx, 1, &self.kvs);
|
215
|
+
}
|
216
|
+
|
217
|
+
/// Record current number of available task slots. Context should have worker type set.
|
218
|
+
pub(crate) fn available_task_slots(&self, num: usize) {
|
219
|
+
self.instruments
|
220
|
+
.task_slots_available
|
221
|
+
.record(&self.ctx, num as u64, &self.kvs)
|
222
|
+
}
|
223
|
+
|
224
|
+
/// Record current number of pollers. Context should include poller type / task queue tag.
|
225
|
+
pub(crate) fn record_num_pollers(&self, num: usize) {
|
226
|
+
self.instruments
|
227
|
+
.num_pollers
|
228
|
+
.record(&self.ctx, num as u64, &self.kvs);
|
229
|
+
}
|
230
|
+
|
231
|
+
/// A workflow task found a cached workflow to run against
|
232
|
+
pub(crate) fn sticky_cache_hit(&self) {
|
233
|
+
self.instruments
|
234
|
+
.sticky_cache_hit
|
235
|
+
.add(&self.ctx, 1, &self.kvs);
|
236
|
+
}
|
237
|
+
|
238
|
+
/// A workflow task did not find a cached workflow
|
239
|
+
pub(crate) fn sticky_cache_miss(&self) {
|
240
|
+
self.instruments
|
241
|
+
.sticky_cache_miss
|
242
|
+
.add(&self.ctx, 1, &self.kvs);
|
243
|
+
}
|
244
|
+
|
245
|
+
/// Record current cache size (in number of wfs, not bytes)
|
246
|
+
pub(crate) fn cache_size(&self, size: u64) {
|
247
|
+
self.instruments
|
248
|
+
.sticky_cache_size
|
249
|
+
.record(&self.ctx, size, &self.kvs);
|
250
|
+
}
|
251
|
+
}
|
252
|
+
|
253
|
+
impl Instruments {
|
254
|
+
fn new(telem: &TelemetryInstance) -> Self {
|
255
|
+
let no_op_meter: Meter;
|
256
|
+
let meter = if let Some(meter) = telem.get_metric_meter() {
|
257
|
+
meter
|
258
|
+
} else {
|
259
|
+
no_op_meter = NoopMeterProvider::default().meter("no_op");
|
260
|
+
&no_op_meter
|
261
|
+
};
|
262
|
+
Self::new_explicit(meter, telem.metric_prefix)
|
263
|
+
}
|
264
|
+
|
265
|
+
fn new_explicit(meter: &Meter, metric_prefix: &'static str) -> Self {
|
266
|
+
let ctr = |name: &'static str| -> Counter<u64> {
|
267
|
+
meter.u64_counter(metric_prefix.to_string() + name).init()
|
268
|
+
};
|
269
|
+
let hst = |name: &'static str| -> Histogram<u64> {
|
270
|
+
meter.u64_histogram(metric_prefix.to_string() + name).init()
|
271
|
+
};
|
272
|
+
Self {
|
273
|
+
wf_completed_counter: ctr("workflow_completed"),
|
274
|
+
wf_canceled_counter: ctr("workflow_canceled"),
|
275
|
+
wf_failed_counter: ctr("workflow_failed"),
|
276
|
+
wf_cont_counter: ctr("workflow_continue_as_new"),
|
277
|
+
wf_e2e_latency: hst(WF_E2E_LATENCY_NAME),
|
278
|
+
wf_task_queue_poll_empty_counter: ctr("workflow_task_queue_poll_empty"),
|
279
|
+
wf_task_queue_poll_succeed_counter: ctr("workflow_task_queue_poll_succeed"),
|
280
|
+
wf_task_execution_failure_counter: ctr("workflow_task_queue_poll_failed"),
|
281
|
+
wf_task_sched_to_start_latency: hst(WF_TASK_SCHED_TO_START_LATENCY_NAME),
|
282
|
+
wf_task_replay_latency: hst(WF_TASK_REPLAY_LATENCY_NAME),
|
283
|
+
wf_task_execution_latency: hst(WF_TASK_EXECUTION_LATENCY_NAME),
|
284
|
+
act_poll_no_task: ctr("activity_poll_no_task"),
|
285
|
+
act_task_received_counter: ctr("activity_task_received"),
|
286
|
+
act_execution_failed: ctr("activity_execution_failed"),
|
287
|
+
act_sched_to_start_latency: hst(ACT_SCHED_TO_START_LATENCY_NAME),
|
288
|
+
act_exec_latency: hst(ACT_EXEC_LATENCY_NAME),
|
289
|
+
// name kept as worker start for compat with old sdk / what users expect
|
290
|
+
worker_registered: ctr("worker_start"),
|
291
|
+
num_pollers: hst(NUM_POLLERS_NAME),
|
292
|
+
task_slots_available: hst(TASK_SLOTS_AVAILABLE_NAME),
|
293
|
+
sticky_cache_hit: ctr("sticky_cache_hit"),
|
294
|
+
sticky_cache_miss: ctr("sticky_cache_miss"),
|
295
|
+
sticky_cache_size: hst(STICKY_CACHE_SIZE_NAME),
|
296
|
+
}
|
297
|
+
}
|
298
|
+
}
|
299
|
+
|
300
|
+
const KEY_NAMESPACE: &str = "namespace";
|
301
|
+
const KEY_WF_TYPE: &str = "workflow_type";
|
302
|
+
const KEY_TASK_QUEUE: &str = "task_queue";
|
303
|
+
const KEY_ACT_TYPE: &str = "activity_type";
|
304
|
+
const KEY_POLLER_TYPE: &str = "poller_type";
|
305
|
+
const KEY_WORKER_TYPE: &str = "worker_type";
|
306
|
+
const KEY_EAGER: &str = "eager";
|
307
|
+
|
308
|
+
pub(crate) fn workflow_poller() -> KeyValue {
|
309
|
+
KeyValue::new(KEY_POLLER_TYPE, "workflow_task")
|
310
|
+
}
|
311
|
+
pub(crate) fn workflow_sticky_poller() -> KeyValue {
|
312
|
+
KeyValue::new(KEY_POLLER_TYPE, "sticky_workflow_task")
|
313
|
+
}
|
314
|
+
pub(crate) fn activity_poller() -> KeyValue {
|
315
|
+
KeyValue::new(KEY_POLLER_TYPE, "activity_task")
|
316
|
+
}
|
317
|
+
pub(crate) fn task_queue(tq: String) -> KeyValue {
|
318
|
+
KeyValue::new(KEY_TASK_QUEUE, tq)
|
319
|
+
}
|
320
|
+
pub(crate) fn activity_type(ty: String) -> KeyValue {
|
321
|
+
KeyValue::new(KEY_ACT_TYPE, ty)
|
322
|
+
}
|
323
|
+
pub(crate) fn workflow_type(ty: String) -> KeyValue {
|
324
|
+
KeyValue::new(KEY_WF_TYPE, ty)
|
325
|
+
}
|
326
|
+
pub(crate) fn workflow_worker_type() -> KeyValue {
|
327
|
+
KeyValue::new(KEY_WORKER_TYPE, "WorkflowWorker")
|
328
|
+
}
|
329
|
+
pub(crate) fn activity_worker_type() -> KeyValue {
|
330
|
+
KeyValue::new(KEY_WORKER_TYPE, "ActivityWorker")
|
331
|
+
}
|
332
|
+
pub(crate) fn local_activity_worker_type() -> KeyValue {
|
333
|
+
KeyValue::new(KEY_WORKER_TYPE, "LocalActivityWorker")
|
334
|
+
}
|
335
|
+
pub(crate) fn eager(is_eager: bool) -> KeyValue {
|
336
|
+
KeyValue::new(KEY_EAGER, is_eager)
|
337
|
+
}
|
338
|
+
|
339
|
+
const WF_E2E_LATENCY_NAME: &str = "workflow_endtoend_latency";
|
340
|
+
const WF_TASK_SCHED_TO_START_LATENCY_NAME: &str = "workflow_task_schedule_to_start_latency";
|
341
|
+
const WF_TASK_REPLAY_LATENCY_NAME: &str = "workflow_task_replay_latency";
|
342
|
+
const WF_TASK_EXECUTION_LATENCY_NAME: &str = "workflow_task_execution_latency";
|
343
|
+
const ACT_SCHED_TO_START_LATENCY_NAME: &str = "activity_schedule_to_start_latency";
|
344
|
+
const ACT_EXEC_LATENCY_NAME: &str = "activity_execution_latency";
|
345
|
+
const NUM_POLLERS_NAME: &str = "num_pollers";
|
346
|
+
const TASK_SLOTS_AVAILABLE_NAME: &str = "worker_task_slots_available";
|
347
|
+
const STICKY_CACHE_SIZE_NAME: &str = "sticky_cache_size";
|
348
|
+
|
349
|
+
/// Artisanal, handcrafted latency buckets for workflow e2e latency which should expose a useful
|
350
|
+
/// set of buckets for < 1 day runtime workflows. Beyond that, this metric probably isn't very
|
351
|
+
/// helpful
|
352
|
+
static WF_LATENCY_MS_BUCKETS: &[f64] = &[
|
353
|
+
100.,
|
354
|
+
500.,
|
355
|
+
1000.,
|
356
|
+
1500.,
|
357
|
+
2000.,
|
358
|
+
5000.,
|
359
|
+
10_000.,
|
360
|
+
30_000.,
|
361
|
+
60_000.,
|
362
|
+
120_000.,
|
363
|
+
300_000.,
|
364
|
+
600_000.,
|
365
|
+
1_800_000., // 30 min
|
366
|
+
3_600_000., // 1 hr
|
367
|
+
30_600_000., // 10 hrs
|
368
|
+
8.64e7, // 24 hrs
|
369
|
+
];
|
370
|
+
|
371
|
+
/// Task latencies are expected to be fast, no longer than a second which was generally the deadlock
|
372
|
+
/// timeout in old SDKs. Here it's a bit different since a WFT may represent multiple activations.
|
373
|
+
static WF_TASK_MS_BUCKETS: &[f64] = &[1., 10., 20., 50., 100., 200., 500., 1000.];
|
374
|
+
|
375
|
+
/// Activity are generally expected to take at least a little time, and sometimes quite a while,
|
376
|
+
/// since they're doing side-effecty things, etc.
|
377
|
+
static ACT_EXE_MS_BUCKETS: &[f64] = &[50., 100., 500., 1000., 5000., 10_000., 60_000.];
|
378
|
+
|
379
|
+
/// Schedule-to-start latency buckets for both WFT and AT
|
380
|
+
static TASK_SCHED_TO_START_MS_BUCKETS: &[f64] =
|
381
|
+
&[100., 500., 1000., 5000., 10_000., 100_000., 1_000_000.];
|
382
|
+
|
383
|
+
/// Default buckets. Should never really be used as they will be meaningless for many things, but
|
384
|
+
/// broadly it's trying to represent latencies in millis.
|
385
|
+
pub(super) static DEFAULT_MS_BUCKETS: &[f64] = &[50., 100., 500., 1000., 2500., 10_000.];
|
386
|
+
|
387
|
+
/// Chooses appropriate aggregators for our metrics
|
388
|
+
#[derive(Debug, Clone)]
|
389
|
+
pub struct SDKAggSelector {
|
390
|
+
pub metric_prefix: &'static str,
|
391
|
+
}
|
392
|
+
|
393
|
+
impl AggregatorSelector for SDKAggSelector {
|
394
|
+
fn aggregator_for(&self, descriptor: &Descriptor) -> Option<Arc<dyn Aggregator + Send + Sync>> {
|
395
|
+
// Gauges are always last value
|
396
|
+
if *descriptor.instrument_kind() == InstrumentKind::GaugeObserver {
|
397
|
+
return Some(Arc::new(last_value()));
|
398
|
+
}
|
399
|
+
|
400
|
+
if *descriptor.instrument_kind() == InstrumentKind::Histogram {
|
401
|
+
let dname = descriptor
|
402
|
+
.name()
|
403
|
+
.strip_prefix(self.metric_prefix)
|
404
|
+
.unwrap_or_else(|| descriptor.name());
|
405
|
+
// Some recorders are just gauges
|
406
|
+
match dname {
|
407
|
+
STICKY_CACHE_SIZE_NAME | NUM_POLLERS_NAME | TASK_SLOTS_AVAILABLE_NAME => {
|
408
|
+
return Some(Arc::new(last_value()))
|
409
|
+
}
|
410
|
+
_ => (),
|
411
|
+
}
|
412
|
+
|
413
|
+
// Other recorders will select their appropriate buckets
|
414
|
+
let buckets = match dname {
|
415
|
+
WF_E2E_LATENCY_NAME => WF_LATENCY_MS_BUCKETS,
|
416
|
+
WF_TASK_EXECUTION_LATENCY_NAME | WF_TASK_REPLAY_LATENCY_NAME => WF_TASK_MS_BUCKETS,
|
417
|
+
WF_TASK_SCHED_TO_START_LATENCY_NAME | ACT_SCHED_TO_START_LATENCY_NAME => {
|
418
|
+
TASK_SCHED_TO_START_MS_BUCKETS
|
419
|
+
}
|
420
|
+
ACT_EXEC_LATENCY_NAME => ACT_EXE_MS_BUCKETS,
|
421
|
+
_ => DEFAULT_MS_BUCKETS,
|
422
|
+
};
|
423
|
+
return Some(Arc::new(histogram(buckets)));
|
424
|
+
}
|
425
|
+
|
426
|
+
Some(Arc::new(sum()))
|
427
|
+
}
|
428
|
+
}
|