Skip to content

Commit

Permalink
metrics: Document NewProcessLabels function
Browse files Browse the repository at this point in the history
Hopefully this comment makes it clearer how the labels filtering happens.

Signed-off-by: Anna Kapuscinska <[email protected]>
  • Loading branch information
lambdanis committed Apr 17, 2024
1 parent 1a50ec4 commit 317fb2d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/metrics/filteredlabels.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ type ProcessLabels struct {
binary string
}

// NewProcessLabels creates a new ProcessLabels struct with the global labels
// filter applied. To have a metric respect the labels filter, we have to:
// 1. Define a granular metric with ProcessLabels type parameter (see granularmetric.go).
// 2. When calling WithLabelValues, pass a ProcessLabels struct created with NewProcessLabels.
func NewProcessLabels(namespace, workload, pod, binary string) *ProcessLabels {
if !option.Config.MetricsLabelFilter["namespace"] {
namespace = ""
Expand Down

0 comments on commit 317fb2d

Please sign in to comment.