From 0ce094b9a30fa6f1b48db56bee18c7e260722869 Mon Sep 17 00:00:00 2001 From: Fabricio Voznika Date: Fri, 21 Apr 2023 15:53:44 -0700 Subject: [PATCH] Report number of trace sessions created metric PiperOrigin-RevId: 526157216 --- pkg/sentry/seccheck/BUILD | 1 + pkg/sentry/seccheck/config.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/pkg/sentry/seccheck/BUILD b/pkg/sentry/seccheck/BUILD index 8c66bf19c..c772c4b0c 100644 --- a/pkg/sentry/seccheck/BUILD +++ b/pkg/sentry/seccheck/BUILD @@ -35,6 +35,7 @@ go_library( "//pkg/fd", "//pkg/gohacks", "//pkg/log", + "//pkg/metric", "//pkg/sentry/arch", "//pkg/sentry/kernel/time", "//pkg/sentry/seccheck/points:points_go_proto", diff --git a/pkg/sentry/seccheck/config.go b/pkg/sentry/seccheck/config.go index 4e688f4e1..56c071edf 100644 --- a/pkg/sentry/seccheck/config.go +++ b/pkg/sentry/seccheck/config.go @@ -21,6 +21,7 @@ import ( "gvisor.dev/gvisor/pkg/fd" "gvisor.dev/gvisor/pkg/log" + "gvisor.dev/gvisor/pkg/metric" ) // DefaultSessionName is the name of the only session that can exist in the @@ -32,6 +33,8 @@ var ( sessions = make(map[string]*State) ) +var sessionCounter = metric.MustCreateNewUint64Metric("/trace/sessions_created", false /* sync */, "Counts the number of trace sessions created.") + // SessionConfig describes a new session configuration. A session consists of a // set of points to be enabled and sinks where the points are sent to. type SessionConfig struct { @@ -136,6 +139,7 @@ func Create(conf *SessionConfig, force bool) error { } sessions[conf.Name] = state + sessionCounter.Increment() return nil }