Skip to content

Commit 996178c

Browse files
authored
Fix pid in memory sampler (#606)
1 parent bde2b52 commit 996178c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

newrelic/samplers/memory_usage.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,18 @@
2121
from newrelic.common.system_info import physical_memory_used, total_physical_memory
2222
from newrelic.samplers.decorators import data_source_generator
2323

24-
PID = os.getpid()
25-
2624

2725
@data_source_generator(name="Memory Usage")
2826
def memory_usage_data_source():
2927
memory = physical_memory_used()
3028
total_memory = total_physical_memory()
29+
pid = os.getpid()
3130

3231
# Calculate memory utilization without 0 division errors
3332
memory_utilization = (memory / total_memory) if total_memory != 0 else 0
3433

3534
yield ("Memory/Physical", memory)
36-
yield ("Memory/Physical/%d" % (PID), memory)
35+
yield ("Memory/Physical/%d" % (pid), memory)
3736

3837
yield ("Memory/Physical/Utilization", memory_utilization)
39-
yield ("Memory/Physical/Utilization/%d" % (PID), memory_utilization)
38+
yield ("Memory/Physical/Utilization/%d" % (pid), memory_utilization)

0 commit comments

Comments
 (0)