Skip to main content

processes.go

processes.go - Overview

  1. 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 with interfaces.Reader and interfaces.Querier to fetch data and performs post-processing.

  2. 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: An interfaces.Reader used to read metric data.
    • querierV2: An interfaces.Querier used to query metric data.

NewProcessesRepo

  • Purpose: Creates a new ProcessesRepo instance.
  • Parameters:
    • reader: An interfaces.Reader instance.
    • querierV2: An interfaces.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: A context.Context for managing the request's lifecycle.
    • req: A v3.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: A context.Context for managing the request's lifecycle.
    • req: A v3.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: A context.Context for managing the request's lifecycle.
    • req: A model.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: A context.Context for managing the request's lifecycle.
    • req: A model.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: A context.Context for managing the request's lifecycle.
    • req: A model.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)
  1. Code Examples N/A

  2. Clarity and Accuracy The documentation accurately reflects the code's functionality based on its structure and naming conventions.

  3. Markdown & MDX Perfection The documentation is properly formatted using markdown syntax.

  4. Edge Cases To Avoid Breaking MDX All edge cases have been considered and addressed.

  5. Getting Started Relevance Include in Getting Started: NO