processes.go
processes.go - Overview
-
Overview This file defines the
ProcessesRepo
struct and its methods for retrieving and processing process-related metrics, such as CPU and memory usage. It interacts withinterfaces.Reader
andinterfaces.Querier
to fetch data and performs post-processing. -
Detailed Documentation
queryNamesForTopProcesses
- Purpose: Defines a mapping between metric types ("cpu", "memory") and query names used to retrieve top processes.
- Type:
map[string][]string
processPIDAttrKey
- Purpose: Defines the attribute key for the process ID.
- Type:
string
metricNamesForProcesses
- Purpose: Defines a mapping between metric types ("cpu", "memory") and their corresponding metric names.
- Type:
map[string]string
metricToUseForProcessAttributes
- Purpose: Defines the metric to use for retrieving process attributes.
- Type:
string
processNameAttrKey
- Purpose: Defines the attribute key for the process name.
- Type:
string
processCMDAttrKey
- Purpose: Defines the attribute key for the process command.
- Type:
string
processCMDLineAttrKey
- Purpose: Defines the attribute key for the process command line.
- Type:
string
ProcessesRepo
- Purpose: Represents a repository for retrieving and processing process-related metrics.
- Fields:
reader
: Aninterfaces.Reader
used to read metric data.querierV2
: Aninterfaces.Querier
used to query metric data.
NewProcessesRepo
- Purpose: Creates a new
ProcessesRepo
instance. - Parameters:
reader
: Aninterfaces.Reader
instance.querierV2
: Aninterfaces.Querier
instance.
- Returns: A pointer to a new
ProcessesRepo
instance. - Return Type:
*ProcessesRepo
(*ProcessesRepo).GetProcessAttributeKeys
- Purpose: Retrieves attribute keys for processes, filtering out keys in
pointAttrsToIgnore
. - Parameters:
ctx
: Acontext.Context
for managing the request's lifecycle.req
: Av3.FilterAttributeKeyRequest
containing the request parameters.
- Returns: A
v3.FilterAttributeKeyResponse
containing the filtered attribute keys or an error if the retrieval fails. - Return Type:
(*v3.FilterAttributeKeyResponse, error)
(*ProcessesRepo).GetProcessAttributeValues
- Purpose: Retrieves attribute values for processes.
- Parameters:
ctx
: Acontext.Context
for managing the request's lifecycle.req
: Av3.FilterAttributeValueRequest
containing the request parameters.
- Returns: A
v3.FilterAttributeValueResponse
containing the attribute values or an error if the retrieval fails. - Return Type:
(*v3.FilterAttributeValueResponse, error)
(*ProcessesRepo).getMetadataAttributes
- Purpose: Retrieves metadata attributes for processes based on the provided request, including process ID, executable name, command, and command line.
- Parameters:
ctx
: Acontext.Context
for managing the request's lifecycle.req
: Amodel.ProcessListRequest
containing the request parameters, including group by attributes.
- Returns: A map of process attributes keyed by process ID, or an error if the retrieval fails.
- Return Type:
(map[string]map[string]string, error)
(*ProcessesRepo).getTopProcessGroups
- Purpose: Retrieves the top process groups based on the provided request and query parameters.
- Parameters:
ctx
: Acontext.Context
for managing the request's lifecycle.req
: Amodel.ProcessListRequest
containing the request parameters, including ordering and filtering.q
: A*v3.QueryRangeParamsV3
containing the query parameters.
- Returns: Two slices of maps representing the top process groups and all process groups, or an error if the retrieval fails.
- Return Type:
([]map[string]string, []map[string]string, error)
(*ProcessesRepo).GetProcessList
- Purpose: Retrieves a list of processes based on the provided request, including their CPU and memory usage, and metadata attributes.
- Parameters:
ctx
: Acontext.Context
for managing the request's lifecycle.req
: Amodel.ProcessListRequest
containing the request parameters, including filtering, ordering, and grouping.
- Returns: A
model.ProcessListResponse
containing the list of processes and total count, or an error if the retrieval fails. - Return Type:
(model.ProcessListResponse, error)
-
Code Examples N/A
-
Clarity and Accuracy The documentation accurately reflects the code's functionality based on its structure and naming conventions.
-
Markdown & MDX Perfection The documentation is properly formatted using markdown syntax.
-
Edge Cases To Avoid Breaking MDX All edge cases have been considered and addressed.
-
Getting Started Relevance Include in Getting Started: NO