From dd301cd5318988d06b0eb12a8035d5f1ebf441e1 Mon Sep 17 00:00:00 2001 From: Chad Retz Date: Thu, 28 Sep 2023 11:52:53 -0500 Subject: [PATCH] PR-suggested fixes --- temporalio/bridge/src/metric.rs | 12 ++++++------ temporalio/bridge/src/runtime.rs | 2 +- temporalio/runtime.py | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/temporalio/bridge/src/metric.rs b/temporalio/bridge/src/metric.rs index 4ac39b30..0c16aeef 100644 --- a/temporalio/bridge/src/metric.rs +++ b/temporalio/bridge/src/metric.rs @@ -257,7 +257,7 @@ fn convert_metric_event<'p>( }, }, ) - .unwrap(), + .expect("Unable to create buffered metric"), ); populate_into.set(Arc::new(buffered_ref)).unwrap(); None @@ -275,11 +275,11 @@ fn convert_metric_event<'p>( .clone() .as_any() .downcast::() - .unwrap() + .expect("Unable to downcast to expected buffered metric attributes") .0 .as_ref(py) .copy() - .unwrap() + .expect("Failed to copy metric attribute dictionary") .into(), None => PyDict::new(py).into(), }; @@ -292,12 +292,12 @@ fn convert_metric_event<'p>( metrics::MetricValue::Float(v) => new_attrs.set_item(kv.key, v), metrics::MetricValue::Bool(v) => new_attrs.set_item(kv.key, v), } - .unwrap(); + .expect("Unable to set metric key/value on dictionary"); } // Put on lazy ref populate_into .set(Arc::new(BufferedMetricAttributes(new_attrs_ref))) - .unwrap(); + .expect("Unable to set buffered metric attributes on reference"); None } // Convert to Python metric event @@ -316,7 +316,7 @@ fn convert_metric_event<'p>( .clone() .as_any() .downcast::() - .unwrap() + .expect("Unable to downcast to expected buffered metric attributes") .0 .clone(), }), diff --git a/temporalio/bridge/src/runtime.rs b/temporalio/bridge/src/runtime.rs index 6956d357..dff05921 100644 --- a/temporalio/bridge/src/runtime.rs +++ b/temporalio/bridge/src/runtime.rs @@ -134,7 +134,7 @@ impl RuntimeRef { self.runtime .metrics_call_buffer .as_ref() - .unwrap() + .expect("Attempting to retrieve buffered metrics without buffer") .retrieve(), ) } diff --git a/temporalio/runtime.py b/temporalio/runtime.py index ba3345d3..aba5ac79 100644 --- a/temporalio/runtime.py +++ b/temporalio/runtime.py @@ -197,7 +197,8 @@ def __init__(self, buffer_size: int) -> None: and is drained regularly. See :py:class:`MetricBuffer` warning. Args: - buffer_size: Size of the buffer. Set this to a large value. + buffer_size: Size of the buffer. Set this to a large value. A value + in the tens of thousands or higher is plenty reasonable. """ self._buffer_size = buffer_size self._runtime: Optional[Runtime] = None