Skip to content

Commit 3dfaab2

Browse files
author
Bob Strahan
committed
fix: Round Lambda GB-seconds to 2 decimal places
- Update calculate_lambda_metering function to round gb_seconds output - Convert from raw calculation (e.g., 25.66893196105957) to rounded (25.67) - Improves readability and consistency in cost reporting - Maintains precision while reducing noise in metering data Example output change: Before: gb_seconds: 0.756893196 After: gb_seconds: 0.76 This provides cleaner cost analytics while preserving accuracy for billing.
1 parent 4b26942 commit 3dfaab2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/idp_common_pkg/idp_common/utils/lambda_metering.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,16 @@ def calculate_lambda_metering(
6161
# Convert to GB-seconds (AWS pricing unit)
6262
# AWS charges based on allocated memory, not actual usage
6363
memory_gb = memory_mb / 1024.0
64-
gb_seconds = memory_gb * duration_seconds
64+
gb_seconds_raw = memory_gb * duration_seconds
65+
66+
# Round GB-seconds to 2 decimal places for cleaner output
67+
gb_seconds = round(gb_seconds_raw, 2)
6568

6669
# Log the calculated metrics for visibility
6770
logger.info(f"Lambda metering for {context_name}: "
6871
f"duration={duration_seconds:.3f}s, "
6972
f"memory={memory_mb}MB, "
70-
f"gb_seconds={gb_seconds:.6f}")
73+
f"gb_seconds={gb_seconds}")
7174

7275
# Return metering data in the standard format used by other services
7376
return {

0 commit comments

Comments
 (0)