utils

package
v0.0.0-...-2750233 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package utils are utilities for system-probe

Index

Constants

View Source
const (
	// CompactOutput indicates that the output should be compact (no indentation).
	CompactOutput = false
	// PrettyPrint indicates that the output should be pretty-printed (with indentation).
	PrettyPrint = true
)
View Source
const DefaultMaxConcurrentRequests = 2

DefaultMaxConcurrentRequests determines the maximum number of requests in-flight for a given handler We choose 2 because one is for regular agent checks and another one is for manual troubleshooting

View Source
const (
	// PrettyPrintQueryParam is the query parameter used to request pretty-printed JSON output
	PrettyPrintQueryParam = "pretty_print"
)

Variables

This section is empty.

Functions

func GetClientID

func GetClientID(req *http.Request) string

GetClientID gets client provided in the http request, defaulting to -1

func WithConcurrencyLimit

func WithConcurrencyLimit(limit int, original func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)

WithConcurrencyLimit enforces a maximum number of concurrent requests over a certain HTTP handler function

func WriteAsJSON

func WriteAsJSON(w http.ResponseWriter, data interface{}, outputOptions FormatOptions)

WriteAsJSON marshals the give data argument into JSON and writes it to the `http.ResponseWriter`

Types

type FormatOptions

type FormatOptions bool

FormatOptions represents formatting options for WriteAsJson.

func GetPrettyPrintFromQueryParams

func GetPrettyPrintFromQueryParams(req *http.Request) FormatOptions

GetPrettyPrintFromQueryParams returns true if the pretty_print query parameter is set to "true" in the request URL

type MemoryMonitor

type MemoryMonitor = memorymonitor.MemoryController

MemoryMonitor monitors cgroups' memory usage

func NewMemoryMonitor

func NewMemoryMonitor(kind string, containerized bool, pressureLevels map[string]string, thresholds map[string]string) (*MemoryMonitor, error)

NewMemoryMonitor instantiates a new memory monitor

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL