Skip to content

Commit 34012a6

Browse files
authored
Add non PID specific total memory metric. (#230)
* Add non PID specific total memory metric. * Add non PID specific memory utilization metric.
1 parent dd45d26 commit 34012a6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

newrelic/samplers/memory_usage.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,16 @@
2525
PID = os.getpid()
2626

2727

28-
@data_source_generator(name='Memory Usage')
28+
@data_source_generator(name="Memory Usage")
2929
def memory_usage_data_source():
30-
yield ('Memory/Physical/%d' % (PID), physical_memory_used())
31-
yield ('Memory/Physical/Utilization/%d' % (PID), physical_memory_used()/total_physical_memory())
30+
yield ("Memory/Physical", physical_memory_used())
31+
yield ("Memory/Physical/%d" % (PID), physical_memory_used())
32+
33+
yield (
34+
"Memory/Physical/Utilization",
35+
physical_memory_used() / total_physical_memory(),
36+
)
37+
yield (
38+
"Memory/Physical/Utilization/%d" % (PID),
39+
physical_memory_used() / total_physical_memory(),
40+
)

tests/agent_unittests/test_sampler_metrics.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ def test_cpu_metrics_collection(cpu_data_source):
151151

152152

153153
EXPECTED_MEMORY_METRICS = (
154+
"Memory/Physical",
154155
"Memory/Physical/%d" % PID,
156+
"Memory/Physical/Utilization",
155157
"Memory/Physical/Utilization/%d" % PID,
156158
)
157159

0 commit comments

Comments
 (0)