summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry')
-rw-r--r--pkg/sentry/kernel/memevent/BUILD1
-rw-r--r--pkg/sentry/kernel/memevent/memory_events.go10
2 files changed, 11 insertions, 0 deletions
diff --git a/pkg/sentry/kernel/memevent/BUILD b/pkg/sentry/kernel/memevent/BUILD
index e903badd3..dfd8dd062 100644
--- a/pkg/sentry/kernel/memevent/BUILD
+++ b/pkg/sentry/kernel/memevent/BUILD
@@ -12,6 +12,7 @@ go_library(
":memory_events_go_proto",
"//pkg/eventchannel",
"//pkg/log",
+ "//pkg/metric",
"//pkg/sentry/kernel",
"//pkg/sentry/usage",
],
diff --git a/pkg/sentry/kernel/memevent/memory_events.go b/pkg/sentry/kernel/memevent/memory_events.go
index f05ef1b64..1a8e86827 100644
--- a/pkg/sentry/kernel/memevent/memory_events.go
+++ b/pkg/sentry/kernel/memevent/memory_events.go
@@ -22,11 +22,15 @@ import (
"gvisor.googlesource.com/gvisor/pkg/eventchannel"
"gvisor.googlesource.com/gvisor/pkg/log"
+ "gvisor.googlesource.com/gvisor/pkg/metric"
"gvisor.googlesource.com/gvisor/pkg/sentry/kernel"
pb "gvisor.googlesource.com/gvisor/pkg/sentry/kernel/memevent/memory_events_go_proto"
"gvisor.googlesource.com/gvisor/pkg/sentry/usage"
)
+var totalTicks = metric.MustCreateNewUint64Metric("/memory_events/ticks", false /*sync*/, "Total number of memory event periods that have elapsed since startup.")
+var totalEvents = metric.MustCreateNewUint64Metric("/memory_events/events", false /*sync*/, "Total number of memory events emitted.")
+
// MemoryEvents describes the configuration for the global memory event emitter.
type MemoryEvents struct {
k *kernel.Kernel
@@ -71,6 +75,10 @@ func (m *MemoryEvents) Start() {
func (m *MemoryEvents) run() {
m.done.Add(1)
+ // Emit the first event immediately on startup.
+ totalTicks.Increment()
+ m.emit()
+
ticker := time.NewTicker(m.period)
defer ticker.Stop()
@@ -80,6 +88,7 @@ func (m *MemoryEvents) run() {
m.done.Done()
return
case <-ticker.C:
+ totalTicks.Increment()
m.emit()
}
}
@@ -94,6 +103,7 @@ func (m *MemoryEvents) emit() {
snapshot, _ := usage.MemoryAccounting.Copy()
total := totalPlatform + snapshot.Mapped
+ totalEvents.Increment()
eventchannel.Emit(&pb.MemoryUsageEvent{
Mapped: snapshot.Mapped,
Total: total,