Skip to content

Commit ed10733

Browse files
authored
Merge pull request #40 from ingenerator/1.x-bug-log-real-memory-usage
Fix request memory logging to use the 'real' system memory used
2 parents c987540 + b100476 commit ed10733

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
### Unreleased
22

3+
### v1.14.1 (2021-11-22)
4+
5+
* [BUG] Request memory usage logs introduced in 1.14 should have been reporting the "real" memory usage
6+
e.g. `memory_get_peak_usage(TRUE)` rather than the less reliable emalloc based allocations php returns by
7+
default.
8+
39
### v1.14.0 (2021-11-19)
410

511
* StackdriverApplicationLogger: limit length of user-agent string in request logs to a maximum of 500 bytes.

src/Logging/StackdriverApplicationLogger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public function logRequest(?array $server, ?float $request_start_time = NULL): v
380380
self::PROP_INGEN_TYPE => 'rqst',
381381
'httpRequest' => $meta['context']['httpRequest'] ?? [],
382382
'context' => [
383-
'mem_mb' => sprintf('%.2f',\memory_get_peak_usage() / 1_000_000),
383+
'mem_mb' => sprintf('%.2f',\memory_get_peak_usage(TRUE) / 1_000_000),
384384
],
385385
],
386386
$meta,

test/unit/Logging/StackdriverApplicationLoggerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,9 +602,9 @@ public function test_its_request_logger_logs_null_latency_if_no_start_time()
602602
public function test_its_request_logger_logs_peak_memory_usage_in_mb()
603603
{
604604
$logger = $this->newSubject();
605-
$peak_before = \memory_get_peak_usage();
605+
$peak_before = \memory_get_peak_usage(TRUE);
606606
$logger->logRequest([]);
607-
$peak_after = \memory_get_peak_usage();
607+
$peak_after = \memory_get_peak_usage(TRUE);
608608
$entry = $this->assertLoggedOneLine();
609609
$this->assertIsString(
610610
$entry['context']['mem_mb'],

0 commit comments

Comments
 (0)