@temporalio/core-bridge 1.11.6 → 1.11.8
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.
- package/Cargo.lock +902 -468
- package/package.json +3 -3
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/sdk-core/.cargo/config.toml +5 -0
- package/sdk-core/.github/workflows/per-pr.yml +59 -5
- package/sdk-core/Cargo.toml +3 -2
- package/sdk-core/client/Cargo.toml +3 -3
- package/sdk-core/client/src/lib.rs +154 -161
- package/sdk-core/client/src/metrics.rs +15 -8
- package/sdk-core/client/src/proxy.rs +1 -1
- package/sdk-core/client/src/raw.rs +176 -33
- package/sdk-core/client/src/retry.rs +102 -465
- package/sdk-core/client/src/worker_registry/mod.rs +2 -2
- package/sdk-core/client/src/workflow_handle/mod.rs +19 -1
- package/sdk-core/core/Cargo.toml +12 -14
- package/sdk-core/core/benches/workflow_replay.rs +1 -1
- package/sdk-core/core/src/abstractions.rs +2 -2
- package/sdk-core/core/src/core_tests/activity_tasks.rs +99 -46
- package/sdk-core/core/src/core_tests/child_workflows.rs +68 -9
- package/sdk-core/core/src/core_tests/determinism.rs +2 -2
- package/sdk-core/core/src/core_tests/local_activities.rs +20 -33
- package/sdk-core/core/src/core_tests/mod.rs +7 -8
- package/sdk-core/core/src/core_tests/queries.rs +79 -79
- package/sdk-core/core/src/core_tests/replay_flag.rs +5 -5
- package/sdk-core/core/src/core_tests/updates.rs +6 -6
- package/sdk-core/core/src/core_tests/workers.rs +19 -22
- package/sdk-core/core/src/core_tests/workflow_cancels.rs +3 -3
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +154 -106
- package/sdk-core/core/src/ephemeral_server/mod.rs +66 -10
- package/sdk-core/core/src/internal_flags.rs +103 -12
- package/sdk-core/core/src/lib.rs +21 -13
- package/sdk-core/core/src/pollers/mod.rs +200 -6
- package/sdk-core/core/src/pollers/poll_buffer.rs +32 -8
- package/sdk-core/core/src/protosext/mod.rs +7 -7
- package/sdk-core/core/src/protosext/protocol_messages.rs +2 -2
- package/sdk-core/core/src/replay/mod.rs +8 -9
- package/sdk-core/core/src/retry_logic.rs +8 -6
- package/sdk-core/core/src/telemetry/log_export.rs +4 -4
- package/sdk-core/core/src/telemetry/metrics.rs +111 -25
- package/sdk-core/core/src/telemetry/mod.rs +11 -4
- package/sdk-core/core/src/telemetry/otel.rs +108 -144
- package/sdk-core/core/src/telemetry/prometheus_server.rs +1 -4
- package/sdk-core/core/src/test_help/mod.rs +27 -21
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +7 -5
- package/sdk-core/core/src/worker/activities/local_activities.rs +9 -9
- package/sdk-core/core/src/worker/activities.rs +34 -46
- package/sdk-core/core/src/worker/client/mocks.rs +24 -2
- package/sdk-core/core/src/worker/client.rs +169 -33
- package/sdk-core/core/src/worker/mod.rs +132 -56
- package/sdk-core/core/src/worker/nexus.rs +410 -0
- package/sdk-core/core/src/worker/tuner/resource_based.rs +27 -5
- package/sdk-core/core/src/worker/tuner.rs +29 -2
- package/sdk-core/core/src/worker/workflow/driven_workflow.rs +8 -3
- package/sdk-core/core/src/worker/workflow/history_update.rs +5 -8
- package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +83 -87
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +38 -38
- package/sdk-core/core/src/worker/workflow/machines/cancel_nexus_op_state_machine.rs +117 -0
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +8 -18
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +114 -108
- package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +16 -31
- package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +7 -14
- package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +8 -15
- package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +34 -75
- package/sdk-core/core/src/worker/workflow/machines/mod.rs +26 -48
- package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +10 -17
- package/sdk-core/core/src/worker/workflow/machines/nexus_operation_state_machine.rs +543 -0
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +22 -31
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +53 -51
- package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +40 -45
- package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +2 -2
- package/sdk-core/core/src/worker/workflow/machines/update_state_machine.rs +8 -10
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +24 -30
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +182 -116
- package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +4 -8
- package/sdk-core/core/src/worker/workflow/managed_run.rs +75 -45
- package/sdk-core/core/src/worker/workflow/mod.rs +104 -55
- package/sdk-core/core/src/worker/workflow/run_cache.rs +23 -4
- package/sdk-core/core/src/worker/workflow/wft_extraction.rs +4 -4
- package/sdk-core/core/src/worker/workflow/wft_poller.rs +3 -3
- package/sdk-core/core/src/worker/workflow/workflow_stream.rs +32 -13
- package/sdk-core/core-api/Cargo.toml +2 -3
- package/sdk-core/core-api/src/errors.rs +22 -20
- package/sdk-core/core-api/src/lib.rs +24 -5
- package/sdk-core/core-api/src/telemetry/metrics.rs +27 -1
- package/sdk-core/core-api/src/telemetry.rs +37 -3
- package/sdk-core/core-api/src/worker.rs +36 -3
- package/sdk-core/docker/docker-compose-ci.yaml +25 -0
- package/sdk-core/etc/otel-collector-ci.yaml +36 -0
- package/sdk-core/etc/otel-collector-config.yaml +3 -3
- package/sdk-core/etc/prometheus.yaml +1 -1
- package/sdk-core/fsm/Cargo.toml +1 -1
- package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +1 -1
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +3 -4
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
- package/sdk-core/fsm/rustfsm_trait/Cargo.toml +1 -1
- package/sdk-core/sdk/Cargo.toml +1 -2
- package/sdk-core/sdk/src/activity_context.rs +1 -1
- package/sdk-core/sdk/src/interceptors.rs +1 -1
- package/sdk-core/sdk/src/lib.rs +126 -54
- package/sdk-core/sdk/src/workflow_context/options.rs +184 -74
- package/sdk-core/sdk/src/workflow_context.rs +193 -79
- package/sdk-core/sdk/src/workflow_future.rs +151 -131
- package/sdk-core/sdk-core-protos/Cargo.toml +3 -4
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/VERSION +1 -1
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/account/v1/message.proto +46 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/request_response.proto +254 -5
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/service.proto +108 -2
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/identity/v1/message.proto +94 -15
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/namespace/v1/message.proto +102 -4
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/nexus/v1/message.proto +84 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/operation/v1/message.proto +25 -10
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/region/v1/message.proto +14 -1
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/resource/v1/message.proto +25 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/sink/v1/message.proto +41 -0
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/temporal/api/cloud/usage/v1/message.proto +59 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/create-release.yml +135 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/push-to-buf.yml +20 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-delete-release.yml +13 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-publish-release.yml +13 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/trigger-api-go-update.yml +13 -21
- package/sdk-core/sdk-core-protos/protos/api_upstream/Makefile +2 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/buf.yaml +1 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +3386 -1047
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +3529 -1144
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/batch/v1/message.proto +39 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/command/v1/message.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +39 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/deployment/v1/message.proto +252 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +1 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/common.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/deployment.proto +96 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/event_type.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/nexus.proto +42 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/reset.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/workflow.proto +43 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/errordetails/v1/message.proto +13 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/failure/v1/message.proto +14 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +70 -12
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +12 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/query/v1/message.proto +9 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +46 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +206 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +482 -97
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +230 -43
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/core_interface.proto +6 -0
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/nexus/nexus.proto +71 -0
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +46 -2
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +55 -9
- package/sdk-core/sdk-core-protos/src/history_builder.rs +5 -5
- package/sdk-core/sdk-core-protos/src/history_info.rs +5 -6
- package/sdk-core/sdk-core-protos/src/lib.rs +414 -34
- package/sdk-core/sdk-core-protos/src/task_token.rs +1 -1
- package/sdk-core/test-utils/Cargo.toml +3 -11
- package/sdk-core/test-utils/src/canned_histories.rs +1 -1
- package/sdk-core/test-utils/src/lib.rs +159 -85
- package/sdk-core/tests/fuzzy_workflow.rs +3 -3
- package/sdk-core/tests/heavy_tests.rs +3 -3
- package/sdk-core/tests/integ_tests/client_tests.rs +171 -20
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +45 -39
- package/sdk-core/tests/integ_tests/heartbeat_tests.rs +7 -6
- package/sdk-core/tests/integ_tests/metrics_tests.rs +492 -35
- package/sdk-core/tests/integ_tests/polling_tests.rs +7 -5
- package/sdk-core/tests/integ_tests/queries_tests.rs +14 -17
- package/sdk-core/tests/integ_tests/update_tests.rs +47 -44
- package/sdk-core/tests/integ_tests/visibility_tests.rs +4 -3
- package/sdk-core/tests/integ_tests/worker_tests.rs +5 -5
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +15 -13
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +28 -14
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +7 -1
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +57 -4
- package/sdk-core/tests/integ_tests/workflow_tests/eager.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +24 -18
- package/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +506 -0
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/priority.rs +104 -0
- package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +34 -31
- package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -1
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +10 -7
- package/sdk-core/tests/integ_tests/workflow_tests.rs +152 -116
- package/sdk-core/tests/main.rs +36 -6
- package/sdk-core/tests/runner.rs +30 -9
- package/src/conversions/slot_supplier_bridge.rs +4 -0
- package/src/conversions.rs +1 -0
- package/src/worker.rs +5 -7
- package/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +0 -78
|
@@ -169,8 +169,8 @@ mod tests {
|
|
|
169
169
|
maximum_attempts: 10,
|
|
170
170
|
non_retryable_error_types: vec!["no retry".to_string()],
|
|
171
171
|
};
|
|
172
|
-
assert!(
|
|
173
|
-
.should_retry(
|
|
172
|
+
assert!(
|
|
173
|
+
rp.should_retry(
|
|
174
174
|
1,
|
|
175
175
|
Some(&ApplicationFailureInfo {
|
|
176
176
|
r#type: "no retry".to_string(),
|
|
@@ -178,7 +178,8 @@ mod tests {
|
|
|
178
178
|
..Default::default()
|
|
179
179
|
})
|
|
180
180
|
)
|
|
181
|
-
.is_none()
|
|
181
|
+
.is_none()
|
|
182
|
+
);
|
|
182
183
|
}
|
|
183
184
|
|
|
184
185
|
#[test]
|
|
@@ -190,8 +191,8 @@ mod tests {
|
|
|
190
191
|
maximum_attempts: 10,
|
|
191
192
|
non_retryable_error_types: vec![],
|
|
192
193
|
};
|
|
193
|
-
assert!(
|
|
194
|
-
.should_retry(
|
|
194
|
+
assert!(
|
|
195
|
+
rp.should_retry(
|
|
195
196
|
1,
|
|
196
197
|
Some(&ApplicationFailureInfo {
|
|
197
198
|
r#type: "".to_string(),
|
|
@@ -199,7 +200,8 @@ mod tests {
|
|
|
199
200
|
..Default::default()
|
|
200
201
|
})
|
|
201
202
|
)
|
|
202
|
-
.is_none()
|
|
203
|
+
.is_none()
|
|
204
|
+
);
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
#[test]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
use futures_channel::mpsc::{
|
|
1
|
+
use futures_channel::mpsc::{Receiver, Sender, channel};
|
|
2
2
|
use parking_lot::Mutex;
|
|
3
|
-
use ringbuf::{consumer::Consumer, producer::Producer, traits::Split
|
|
3
|
+
use ringbuf::{HeapRb, consumer::Consumer, producer::Producer, traits::Split};
|
|
4
4
|
use std::{collections::HashMap, fmt, sync::Arc, time::SystemTime};
|
|
5
5
|
use temporal_sdk_core_api::telemetry::{CoreLog, CoreLogConsumer};
|
|
6
6
|
use tracing_subscriber::Layer;
|
|
@@ -168,7 +168,7 @@ impl fmt::Debug for CoreLogStreamConsumer {
|
|
|
168
168
|
|
|
169
169
|
struct JsonVisitor<'a>(&'a mut HashMap<String, serde_json::Value>);
|
|
170
170
|
|
|
171
|
-
impl
|
|
171
|
+
impl tracing::field::Visit for JsonVisitor<'_> {
|
|
172
172
|
fn record_f64(&mut self, field: &tracing::field::Field, value: f64) {
|
|
173
173
|
self.0
|
|
174
174
|
.insert(field.name().to_string(), serde_json::json!(value));
|
|
@@ -216,7 +216,7 @@ impl<'a> tracing::field::Visit for JsonVisitor<'a> {
|
|
|
216
216
|
#[cfg(test)]
|
|
217
217
|
mod tests {
|
|
218
218
|
use crate::{
|
|
219
|
-
telemetry::{
|
|
219
|
+
telemetry::{CoreLogStreamConsumer, construct_filter_string},
|
|
220
220
|
telemetry_init,
|
|
221
221
|
};
|
|
222
222
|
use futures_util::stream::StreamExt;
|
|
@@ -48,6 +48,11 @@ struct Instruments {
|
|
|
48
48
|
la_exec_latency: Arc<dyn HistogramDuration>,
|
|
49
49
|
la_exec_succeeded_latency: Arc<dyn HistogramDuration>,
|
|
50
50
|
la_total: Arc<dyn Counter>,
|
|
51
|
+
nexus_poll_no_task: Arc<dyn Counter>,
|
|
52
|
+
nexus_task_schedule_to_start_latency: Arc<dyn HistogramDuration>,
|
|
53
|
+
nexus_task_e2e_latency: Arc<dyn HistogramDuration>,
|
|
54
|
+
nexus_task_execution_latency: Arc<dyn HistogramDuration>,
|
|
55
|
+
nexus_task_execution_failed: Arc<dyn Counter>,
|
|
51
56
|
worker_registered: Arc<dyn Counter>,
|
|
52
57
|
num_pollers: Arc<dyn Gauge>,
|
|
53
58
|
task_slots_available: Arc<dyn Gauge>,
|
|
@@ -55,7 +60,7 @@ struct Instruments {
|
|
|
55
60
|
sticky_cache_hit: Arc<dyn Counter>,
|
|
56
61
|
sticky_cache_miss: Arc<dyn Counter>,
|
|
57
62
|
sticky_cache_size: Arc<dyn Gauge>,
|
|
58
|
-
|
|
63
|
+
sticky_cache_forced_evictions: Arc<dyn Counter>,
|
|
59
64
|
}
|
|
60
65
|
|
|
61
66
|
impl MetricsContext {
|
|
@@ -225,6 +230,39 @@ impl MetricsContext {
|
|
|
225
230
|
self.instruments.la_total.add(1, &self.kvs);
|
|
226
231
|
}
|
|
227
232
|
|
|
233
|
+
/// A nexus long poll timed out
|
|
234
|
+
pub(crate) fn nexus_poll_timeout(&self) {
|
|
235
|
+
self.instruments.nexus_poll_no_task.add(1, &self.kvs);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/// Record nexus task schedule to start time
|
|
239
|
+
pub(crate) fn nexus_task_sched_to_start_latency(&self, dur: Duration) {
|
|
240
|
+
self.instruments
|
|
241
|
+
.nexus_task_schedule_to_start_latency
|
|
242
|
+
.record(dur, &self.kvs);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/// Record nexus task end-to-end time
|
|
246
|
+
pub(crate) fn nexus_task_e2e_latency(&self, dur: Duration) {
|
|
247
|
+
self.instruments
|
|
248
|
+
.nexus_task_e2e_latency
|
|
249
|
+
.record(dur, &self.kvs);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/// Record nexus task execution time
|
|
253
|
+
pub(crate) fn nexus_task_execution_latency(&self, dur: Duration) {
|
|
254
|
+
self.instruments
|
|
255
|
+
.nexus_task_execution_latency
|
|
256
|
+
.record(dur, &self.kvs);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/// Record a nexus task execution failure
|
|
260
|
+
pub(crate) fn nexus_task_execution_failed(&self) {
|
|
261
|
+
self.instruments
|
|
262
|
+
.nexus_task_execution_failed
|
|
263
|
+
.add(1, &self.kvs);
|
|
264
|
+
}
|
|
265
|
+
|
|
228
266
|
/// A worker was registered
|
|
229
267
|
pub(crate) fn worker_registered(&self) {
|
|
230
268
|
self.instruments.worker_registered.add(1, &self.kvs);
|
|
@@ -263,8 +301,10 @@ impl MetricsContext {
|
|
|
263
301
|
}
|
|
264
302
|
|
|
265
303
|
/// Count a workflow being evicted from the cache
|
|
266
|
-
pub(crate) fn
|
|
267
|
-
self.instruments
|
|
304
|
+
pub(crate) fn forced_cache_eviction(&self) {
|
|
305
|
+
self.instruments
|
|
306
|
+
.sticky_cache_forced_evictions
|
|
307
|
+
.add(1, &self.kvs);
|
|
268
308
|
}
|
|
269
309
|
}
|
|
270
310
|
|
|
@@ -292,7 +332,7 @@ impl Instruments {
|
|
|
292
332
|
unit: "".into(),
|
|
293
333
|
}),
|
|
294
334
|
wf_e2e_latency: meter.histogram_duration(MetricParameters {
|
|
295
|
-
name:
|
|
335
|
+
name: WORKFLOW_E2E_LATENCY_HISTOGRAM_NAME.into(),
|
|
296
336
|
unit: "duration".into(),
|
|
297
337
|
description: "Histogram of total workflow execution latencies".into(),
|
|
298
338
|
}),
|
|
@@ -312,17 +352,17 @@ impl Instruments {
|
|
|
312
352
|
unit: "".into(),
|
|
313
353
|
}),
|
|
314
354
|
wf_task_sched_to_start_latency: meter.histogram_duration(MetricParameters {
|
|
315
|
-
name:
|
|
355
|
+
name: WORKFLOW_TASK_SCHED_TO_START_LATENCY_HISTOGRAM_NAME.into(),
|
|
316
356
|
unit: "duration".into(),
|
|
317
357
|
description: "Histogram of workflow task schedule-to-start latencies".into(),
|
|
318
358
|
}),
|
|
319
359
|
wf_task_replay_latency: meter.histogram_duration(MetricParameters {
|
|
320
|
-
name:
|
|
360
|
+
name: WORKFLOW_TASK_REPLAY_LATENCY_HISTOGRAM_NAME.into(),
|
|
321
361
|
unit: "duration".into(),
|
|
322
362
|
description: "Histogram of workflow task replay latencies".into(),
|
|
323
363
|
}),
|
|
324
364
|
wf_task_execution_latency: meter.histogram_duration(MetricParameters {
|
|
325
|
-
name:
|
|
365
|
+
name: WORKFLOW_TASK_EXECUTION_LATENCY_HISTOGRAM_NAME.into(),
|
|
326
366
|
unit: "duration".into(),
|
|
327
367
|
description: "Histogram of workflow task execution (not replay) latencies".into(),
|
|
328
368
|
}),
|
|
@@ -342,12 +382,12 @@ impl Instruments {
|
|
|
342
382
|
unit: "".into(),
|
|
343
383
|
}),
|
|
344
384
|
act_sched_to_start_latency: meter.histogram_duration(MetricParameters {
|
|
345
|
-
name:
|
|
385
|
+
name: ACTIVITY_SCHED_TO_START_LATENCY_HISTOGRAM_NAME.into(),
|
|
346
386
|
unit: "duration".into(),
|
|
347
387
|
description: "Histogram of activity schedule-to-start latencies".into(),
|
|
348
388
|
}),
|
|
349
389
|
act_exec_latency: meter.histogram_duration(MetricParameters {
|
|
350
|
-
name:
|
|
390
|
+
name: ACTIVITY_EXEC_LATENCY_HISTOGRAM_NAME.into(),
|
|
351
391
|
unit: "duration".into(),
|
|
352
392
|
description: "Histogram of activity execution latencies".into(),
|
|
353
393
|
}),
|
|
@@ -384,6 +424,31 @@ impl Instruments {
|
|
|
384
424
|
description: "Count of local activities executed".into(),
|
|
385
425
|
unit: "".into(),
|
|
386
426
|
}),
|
|
427
|
+
nexus_poll_no_task: meter.counter(MetricParameters {
|
|
428
|
+
name: "nexus_poll_no_task".into(),
|
|
429
|
+
description: "Count of nexus task queue poll timeouts (no new task)".into(),
|
|
430
|
+
unit: "".into(),
|
|
431
|
+
}),
|
|
432
|
+
nexus_task_schedule_to_start_latency: meter.histogram_duration(MetricParameters {
|
|
433
|
+
name: "nexus_task_schedule_to_start_latency".into(),
|
|
434
|
+
unit: "duration".into(),
|
|
435
|
+
description: "Histogram of nexus task schedule-to-start latencies".into(),
|
|
436
|
+
}),
|
|
437
|
+
nexus_task_e2e_latency: meter.histogram_duration(MetricParameters {
|
|
438
|
+
name: "nexus_task_endtoend_latency".into(),
|
|
439
|
+
unit: "duration".into(),
|
|
440
|
+
description: "Histogram of nexus task end-to-end latencies".into(),
|
|
441
|
+
}),
|
|
442
|
+
nexus_task_execution_latency: meter.histogram_duration(MetricParameters {
|
|
443
|
+
name: "nexus_task_execution_latency".into(),
|
|
444
|
+
unit: "duration".into(),
|
|
445
|
+
description: "Histogram of nexus task execution latencies".into(),
|
|
446
|
+
}),
|
|
447
|
+
nexus_task_execution_failed: meter.counter(MetricParameters {
|
|
448
|
+
name: "nexus_task_execution_failed".into(),
|
|
449
|
+
description: "Count of nexus task execution failures".into(),
|
|
450
|
+
unit: "".into(),
|
|
451
|
+
}),
|
|
387
452
|
// name kept as worker start for compat with old sdk / what users expect
|
|
388
453
|
worker_registered: meter.counter(MetricParameters {
|
|
389
454
|
name: "worker_start".into(),
|
|
@@ -423,7 +488,7 @@ impl Instruments {
|
|
|
423
488
|
description: "Current number of cached workflows".into(),
|
|
424
489
|
unit: "".into(),
|
|
425
490
|
}),
|
|
426
|
-
|
|
491
|
+
sticky_cache_forced_evictions: meter.counter(MetricParameters {
|
|
427
492
|
name: "sticky_cache_total_forced_eviction".into(),
|
|
428
493
|
description: "Count of evictions of cached workflows".into(),
|
|
429
494
|
unit: "".into(),
|
|
@@ -450,6 +515,9 @@ pub(crate) fn workflow_sticky_poller() -> MetricKeyValue {
|
|
|
450
515
|
pub(crate) fn activity_poller() -> MetricKeyValue {
|
|
451
516
|
MetricKeyValue::new(KEY_POLLER_TYPE, "activity_task")
|
|
452
517
|
}
|
|
518
|
+
pub(crate) fn nexus_poller() -> MetricKeyValue {
|
|
519
|
+
MetricKeyValue::new(KEY_POLLER_TYPE, "nexus_task")
|
|
520
|
+
}
|
|
453
521
|
pub(crate) fn task_queue(tq: String) -> MetricKeyValue {
|
|
454
522
|
MetricKeyValue::new(KEY_TASK_QUEUE, tq)
|
|
455
523
|
}
|
|
@@ -468,18 +536,27 @@ pub(crate) fn activity_worker_type() -> MetricKeyValue {
|
|
|
468
536
|
pub(crate) fn local_activity_worker_type() -> MetricKeyValue {
|
|
469
537
|
MetricKeyValue::new(KEY_WORKER_TYPE, "LocalActivityWorker")
|
|
470
538
|
}
|
|
539
|
+
pub(crate) fn nexus_worker_type() -> MetricKeyValue {
|
|
540
|
+
MetricKeyValue::new(KEY_WORKER_TYPE, "NexusWorker")
|
|
541
|
+
}
|
|
471
542
|
pub(crate) fn eager(is_eager: bool) -> MetricKeyValue {
|
|
472
543
|
MetricKeyValue::new(KEY_EAGER, is_eager)
|
|
473
544
|
}
|
|
474
545
|
pub(crate) enum FailureReason {
|
|
475
546
|
Nondeterminism,
|
|
476
547
|
Workflow,
|
|
548
|
+
Timeout,
|
|
549
|
+
NexusOperation(String),
|
|
550
|
+
NexusHandlerError(String),
|
|
477
551
|
}
|
|
478
552
|
impl Display for FailureReason {
|
|
479
553
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
480
554
|
let str = match self {
|
|
481
|
-
FailureReason::Nondeterminism => "NonDeterminismError",
|
|
482
|
-
FailureReason::Workflow => "WorkflowError",
|
|
555
|
+
FailureReason::Nondeterminism => "NonDeterminismError".to_owned(),
|
|
556
|
+
FailureReason::Workflow => "WorkflowError".to_owned(),
|
|
557
|
+
FailureReason::Timeout => "timeout".to_owned(),
|
|
558
|
+
FailureReason::NexusOperation(op) => format!("operation_{}", op),
|
|
559
|
+
FailureReason::NexusHandlerError(op) => format!("handler_error_{}", op),
|
|
483
560
|
};
|
|
484
561
|
write!(f, "{}", str)
|
|
485
562
|
}
|
|
@@ -496,13 +573,20 @@ pub(crate) fn failure_reason(reason: FailureReason) -> MetricKeyValue {
|
|
|
496
573
|
MetricKeyValue::new(KEY_TASK_FAILURE_TYPE, reason.to_string())
|
|
497
574
|
}
|
|
498
575
|
|
|
499
|
-
|
|
500
|
-
pub
|
|
576
|
+
/// The string name (which may be prefixed) for this metric
|
|
577
|
+
pub const WORKFLOW_E2E_LATENCY_HISTOGRAM_NAME: &str = "workflow_endtoend_latency";
|
|
578
|
+
/// The string name (which may be prefixed) for this metric
|
|
579
|
+
pub const WORKFLOW_TASK_SCHED_TO_START_LATENCY_HISTOGRAM_NAME: &str =
|
|
501
580
|
"workflow_task_schedule_to_start_latency";
|
|
502
|
-
|
|
503
|
-
pub
|
|
504
|
-
|
|
505
|
-
pub
|
|
581
|
+
/// The string name (which may be prefixed) for this metric
|
|
582
|
+
pub const WORKFLOW_TASK_REPLAY_LATENCY_HISTOGRAM_NAME: &str = "workflow_task_replay_latency";
|
|
583
|
+
/// The string name (which may be prefixed) for this metric
|
|
584
|
+
pub const WORKFLOW_TASK_EXECUTION_LATENCY_HISTOGRAM_NAME: &str = "workflow_task_execution_latency";
|
|
585
|
+
/// The string name (which may be prefixed) for this metric
|
|
586
|
+
pub const ACTIVITY_SCHED_TO_START_LATENCY_HISTOGRAM_NAME: &str =
|
|
587
|
+
"activity_schedule_to_start_latency";
|
|
588
|
+
/// The string name (which may be prefixed) for this metric
|
|
589
|
+
pub const ACTIVITY_EXEC_LATENCY_HISTOGRAM_NAME: &str = "activity_execution_latency";
|
|
506
590
|
pub(super) const NUM_POLLERS_NAME: &str = "num_pollers";
|
|
507
591
|
pub(super) const TASK_SLOTS_AVAILABLE_NAME: &str = "worker_task_slots_available";
|
|
508
592
|
pub(super) const TASK_SLOTS_USED_NAME: &str = "worker_task_slots_used";
|
|
@@ -533,7 +617,7 @@ macro_rules! define_latency_buckets {
|
|
|
533
617
|
|
|
534
618
|
define_latency_buckets!(
|
|
535
619
|
(
|
|
536
|
-
|
|
620
|
+
WORKFLOW_E2E_LATENCY_HISTOGRAM_NAME,
|
|
537
621
|
WF_LATENCY_MS_BUCKETS,
|
|
538
622
|
WF_LATENCY_S_BUCKETS,
|
|
539
623
|
[
|
|
@@ -556,19 +640,21 @@ define_latency_buckets!(
|
|
|
556
640
|
]
|
|
557
641
|
),
|
|
558
642
|
(
|
|
559
|
-
|
|
643
|
+
WORKFLOW_TASK_EXECUTION_LATENCY_HISTOGRAM_NAME
|
|
644
|
+
| WORKFLOW_TASK_REPLAY_LATENCY_HISTOGRAM_NAME,
|
|
560
645
|
WF_TASK_MS_BUCKETS,
|
|
561
646
|
WF_TASK_S_BUCKETS,
|
|
562
647
|
[1., 10., 20., 50., 100., 200., 500., 1000.]
|
|
563
648
|
),
|
|
564
649
|
(
|
|
565
|
-
|
|
650
|
+
ACTIVITY_EXEC_LATENCY_HISTOGRAM_NAME,
|
|
566
651
|
ACT_EXE_MS_BUCKETS,
|
|
567
652
|
ACT_EXE_S_BUCKETS,
|
|
568
653
|
[50., 100., 500., 1000., 5000., 10_000., 60_000.]
|
|
569
654
|
),
|
|
570
655
|
(
|
|
571
|
-
|
|
656
|
+
WORKFLOW_TASK_SCHED_TO_START_LATENCY_HISTOGRAM_NAME
|
|
657
|
+
| ACTIVITY_SCHED_TO_START_LATENCY_HISTOGRAM_NAME,
|
|
572
658
|
TASK_SCHED_TO_START_MS_BUCKETS,
|
|
573
659
|
TASK_SCHED_TO_START_S_BUCKETS,
|
|
574
660
|
[100., 500., 1000., 5000., 10_000., 100_000., 1_000_000.]
|
|
@@ -818,8 +904,8 @@ mod tests {
|
|
|
818
904
|
use super::*;
|
|
819
905
|
use std::any::Any;
|
|
820
906
|
use temporal_sdk_core_api::telemetry::{
|
|
821
|
-
metrics::{BufferInstrumentRef, CustomMetricAttributes},
|
|
822
907
|
METRIC_PREFIX,
|
|
908
|
+
metrics::{BufferInstrumentRef, CustomMetricAttributes},
|
|
823
909
|
};
|
|
824
910
|
use tracing::subscriber::NoSubscriber;
|
|
825
911
|
|
|
@@ -858,7 +944,7 @@ mod tests {
|
|
|
858
944
|
true,
|
|
859
945
|
);
|
|
860
946
|
let mc = MetricsContext::top_level("foo".to_string(), "q".to_string(), &telem_instance);
|
|
861
|
-
mc.
|
|
947
|
+
mc.forced_cache_eviction();
|
|
862
948
|
let events = call_buffer.retrieve();
|
|
863
949
|
let a1 = assert_matches!(
|
|
864
950
|
&events[0],
|
|
@@ -875,7 +961,7 @@ mod tests {
|
|
|
875
961
|
a1.set(Arc::new(DummyCustomAttrs(1))).unwrap();
|
|
876
962
|
// Verify all metrics are created. This number will need to get updated any time a metric
|
|
877
963
|
// is added.
|
|
878
|
-
let num_metrics =
|
|
964
|
+
let num_metrics = 35;
|
|
879
965
|
#[allow(clippy::needless_range_loop)] // Sorry clippy, this reads easier.
|
|
880
966
|
for metric_num in 1..=num_metrics {
|
|
881
967
|
let hole = assert_matches!(&events[metric_num],
|
|
@@ -9,7 +9,12 @@ mod otel;
|
|
|
9
9
|
mod prometheus_server;
|
|
10
10
|
|
|
11
11
|
#[cfg(feature = "otel")]
|
|
12
|
-
pub use metrics::{
|
|
12
|
+
pub use metrics::{
|
|
13
|
+
ACTIVITY_EXEC_LATENCY_HISTOGRAM_NAME, ACTIVITY_SCHED_TO_START_LATENCY_HISTOGRAM_NAME,
|
|
14
|
+
MetricsCallBuffer, WORKFLOW_E2E_LATENCY_HISTOGRAM_NAME,
|
|
15
|
+
WORKFLOW_TASK_EXECUTION_LATENCY_HISTOGRAM_NAME, WORKFLOW_TASK_REPLAY_LATENCY_HISTOGRAM_NAME,
|
|
16
|
+
WORKFLOW_TASK_SCHED_TO_START_LATENCY_HISTOGRAM_NAME, default_buckets_for,
|
|
17
|
+
};
|
|
13
18
|
#[cfg(feature = "otel")]
|
|
14
19
|
pub use otel::{build_otlp_metric_exporter, start_prometheus_metric_exporter};
|
|
15
20
|
|
|
@@ -23,16 +28,16 @@ use std::{
|
|
|
23
28
|
collections::VecDeque,
|
|
24
29
|
env,
|
|
25
30
|
sync::{
|
|
26
|
-
atomic::{AtomicBool, Ordering},
|
|
27
31
|
Arc,
|
|
32
|
+
atomic::{AtomicBool, Ordering},
|
|
28
33
|
},
|
|
29
34
|
};
|
|
30
35
|
use temporal_sdk_core_api::telemetry::{
|
|
31
|
-
metrics::{CoreMeter, MetricKeyValue, NewAttributes, TemporalMeter},
|
|
32
36
|
CoreLog, CoreTelemetry, Logger, TelemetryOptions,
|
|
37
|
+
metrics::{CoreMeter, MetricKeyValue, NewAttributes, TemporalMeter},
|
|
33
38
|
};
|
|
34
39
|
use tracing::{Level, Subscriber};
|
|
35
|
-
use tracing_subscriber::{
|
|
40
|
+
use tracing_subscriber::{EnvFilter, Layer, layer::SubscriberExt};
|
|
36
41
|
|
|
37
42
|
const TELEM_SERVICE_NAME: &str = "temporal-core-sdk";
|
|
38
43
|
|
|
@@ -271,11 +276,13 @@ where
|
|
|
271
276
|
}
|
|
272
277
|
}
|
|
273
278
|
|
|
279
|
+
/// Helpers for test initialization
|
|
274
280
|
#[cfg(test)]
|
|
275
281
|
pub mod test_initters {
|
|
276
282
|
use super::*;
|
|
277
283
|
use temporal_sdk_core_api::telemetry::TelemetryOptionsBuilder;
|
|
278
284
|
|
|
285
|
+
/// Turn on logging to the console
|
|
279
286
|
#[allow(dead_code)] // Not always used, called to enable for debugging when needed
|
|
280
287
|
pub fn test_telem_console() {
|
|
281
288
|
telemetry_init_global(
|