Skip to content

Commit 2d540e2

Browse files
Alex Wangwangyb-A
authored andcommitted
refactor(insight): remove NaN warning
1 parent 27f7bb0 commit 2d540e2

2 files changed

Lines changed: 5 additions & 16 deletions

File tree

  • packages/aws-durable-execution-sdk-python-insight

packages/aws-durable-execution-sdk-python-insight/src/aws_durable_execution_sdk_python_insight/plugin.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
import datetime
3434
import json
35-
import logging
3635
import math
3736
import sys
3837
import threading
@@ -62,9 +61,6 @@
6261
)
6362

6463

65-
logger = logging.getLogger(__name__)
66-
67-
6864
# Maps the SDK invocation status onto the record status. A durable execution
6965
# suspends (PENDING) while waiting; from the execution's point of view it is
7066
# still in flight, so surface it as RUNNING (mirrors the JS STATUS_MAP).
@@ -118,7 +114,6 @@ def _resolve_sampling_rate(rate: float | None) -> float:
118114
# False, x < NaN -> False) and silently sample OUT every execution,
119115
# disabling all instrumentation. Coerce to full sampling instead, which
120116
# matches the JS plugin's treatment of non-finite/invalid rates.
121-
logger.warning("sampling_rate is NaN; falling back to 1.0 (full sampling)")
122117
return 1.0
123118
if rate < 0 or rate > 1:
124119
return max(0.0, min(1.0, float(rate)))

packages/aws-durable-execution-sdk-python-insight/tests/test_plugin.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from __future__ import annotations
1414

1515
import datetime
16-
import logging
1716
from typing import Any
1817

1918
from aws_durable_execution_sdk_python.lambda_service import (
@@ -204,19 +203,14 @@ def test_resolve_sampling_rate_nan_fails_open_to_one():
204203
assert _resolve_sampling_rate(float("nan")) == 1.0
205204

206205

207-
def test_nan_sampling_rate_emits_instead_of_silently_disabling(caplog):
206+
def test_nan_sampling_rate_emits_instead_of_silently_disabling():
208207
exporter = CaptureExporter()
209-
with caplog.at_level(
210-
logging.WARNING,
211-
logger="aws_durable_execution_sdk_python_insight.plugin",
212-
):
213-
plugin = workflow_insight(
214-
WorkflowInsightConfig(exporters=[exporter], sampling_rate=float("nan"))
215-
)
216-
_run(plugin, ops=[_step("greet")])
208+
plugin = workflow_insight(
209+
WorkflowInsightConfig(exporters=[exporter], sampling_rate=float("nan"))
210+
)
211+
_run(plugin, ops=[_step("greet")])
217212
# A NaN rate must not disable instrumentation: the record is still emitted.
218213
assert len(exporter.records) == 1
219-
assert "sampling_rate is NaN" in caplog.text
220214

221215

222216
def test_content_omit_input_output_without_drop_flags():

0 commit comments

Comments
 (0)