util

package
v0.0.0-...-b2fc123 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 28 Imported by: 72

Documentation

Overview

Package util provides various functions

Index

Constants

View Source
const (
	// IntSize is the size of an int in bytes.
	IntSize = strconv.IntSize / 8
	// StringSize is the size of a string structure in bytes.
	StringSize = unsafe.Sizeof("")
	// StringSliceSize is the size of the string slice in bytes (not counting the size of the strings themselves).
	StringSliceSize = unsafe.Sizeof([]string{})

	// BytesKindTelemetryKey is the tag key used to identify the kind of telemetry value.
	BytesKindTelemetryKey = "bytes_kind"
	// BytesKindStruct is the tag value used to mark bytes as struct.
	BytesKindStruct = "struct"
	// BytesKindData is the tag value used to mark bytes as data. Those are likely to be interned strings.
	BytesKindData = "data"
)

Variables

View Source
var SortUniqInPlace = sort.UniqInPlace

SortUniqInPlace alias

Functions

func CopyDir

func CopyDir(src, dst string) error

CopyDir copies directory recursively

func CopyFile

func CopyFile(src, dst string) error

CopyFile atomically copies file path `src“ to file path `dst`.

func CopyFileAll

func CopyFileAll(src, dst string) error

CopyFileAll calls CopyFile, but will create necessary directories for `dst`.

func DataSizeOfStringSlice

func DataSizeOfStringSlice(v []string) int

DataSizeOfStringSlice returns the size of the content of the string slice in bytes.

func EnsureParentDirsExist

func EnsureParentDirsExist(p string) error

EnsureParentDirsExist makes a path immediately available for writing by creating the necessary parent directories.

func Fqdn

func Fqdn(hostname string) string

Fqdn returns the FQDN for the host if any (this uses a DNS forward and reverse round trip).

func GetGlobalEnvTags

func GetGlobalEnvTags(config model.Reader) map[string][]string

GetGlobalEnvTags is similar to GetStaticTags, but returning a map[string][]string containing <key>:<value> pairs for all global environment tags on the cluster agent. This includes: DD_TAGS, DD_EXTRA_TAGS, DD_CLUSTER_CHECKS_EXTRA_TAGS, and DD_ORCHESTRATOR_EXPLORER_EXTRA_TAGS

func GetGoRoutinesDump

func GetGoRoutinesDump() (string, error)

GetGoRoutinesDump returns the stack trace of every Go routine of a running Agent.

func GetJSONSerializableMap

func GetJSONSerializableMap(m interface{}) interface{}

GetJSONSerializableMap returns a JSON serializable map from a raw map

func GetStaticTags

func GetStaticTags(ctx context.Context) map[string][]string

GetStaticTags is similar to GetStaticTagsSlice, but returning a map[string][]string containing <key>:<value> pairs for tags. Tags not matching this pattern are omitted.

func GetStaticTagsSlice

func GetStaticTagsSlice(ctx context.Context) []string

GetStaticTagsSlice gets the "static tags" for this agent. These are tags that are attached directly to everything the agent produces, but _not_ included in host tags. In environments with no host metadata (such as where the hostname is empty), tags that would otherwise be included in host metadata are generated by this function.

func HTTPHeaders

func HTTPHeaders() map[string]string

HTTPHeaders returns a http headers including various basic information (User-Agent, Content-Type...).

func SetupCoreDump added in v0.9.0

func SetupCoreDump(cfg model.Reader) error

SetupCoreDump enables core dumps and sets the core dump size limit based on configuration

func SizeOfStringSlice

func SizeOfStringSlice(s []string) int

SizeOfStringSlice returns the size of the string slice in bytes (not counting the size of the strings themselves).

Types

type HasSizeInBytes

type HasSizeInBytes interface {
	// SizeInBytes Return the size of the object in bytes (not including the size of its content)
	SizeInBytes() int

	// DataSizeInBytes Return the size of content of the object in bytes
	DataSizeInBytes() int
}

HasSizeInBytes is an interface that can be implemented by any object that has a size in bytes

type ProcessFileStats

type ProcessFileStats struct {
	AgentOpenFiles uint64 `json:"agent_open_files"`
	OsFileLimit    uint64 `json:"os_file_limit"`
}

ProcessFileStats is used to retrieve stats from gopsutil/v3/process -- these stats are used for troubleshooting purposes

func GetProcessFileStats

func GetProcessFileStats() (*ProcessFileStats, error)

GetProcessFileStats returns the number of file handles the Agent process has open

type Stat

type Stat struct {
	Val int64
	Ts  time.Time
}

Stat type includes a statted value and its timestamp.

type Stats

type Stats struct {
	Aggregated chan Stat
	// contains filtered or unexported fields
}

Stats type structure enabling statting facilities.

func NewStats

func NewStats(sz uint32) (*Stats, error)

NewStats constructor for Stats

func (*Stats) Process

func (s *Stats) Process()

Process call to start processing statistics

func (*Stats) StatEvent

func (s *Stats) StatEvent(v int64)

StatEvent aggregates an event with value v

func (*Stats) Stop

func (s *Stats) Stop()

Stop call to stop processing statistics. Once stopped, Stats cannot be restarted.

func (*Stats) Update

func (s *Stats) Update(expStat *expvar.Int)

Update update the expvar parameter with the last aggregated value

Directories

Path Synopsis
Package queue implements a generic queue.
Package queue implements a generic queue.
Package archive provides functions to archive and unarchive files.
Package archive provides functions to archive and unarchive files.
Package atomicstats provides support for "stats" structs containing atomic values.
Package atomicstats provides support for "stats" structs containing atomic values.
backoff module
buf module
cache module
Package cachedfetch provides a read-through cache for fetched values.
Package cachedfetch provides a read-through cache for fetched values.
cgroups module
Package cli provides helper functions around command line interface
Package cli provides helper functions around command line interface
Package cloudproviders provides utilities to detect the cloud provider.
Package cloudproviders provides utilities to detect the cloud provider.
alibaba
Package alibaba provides utilities to detect the Alibaba cloud provider.
Package alibaba provides utilities to detect the Alibaba cloud provider.
azure
Package azure provides utilities to detect Azure cloud provider.
Package azure provides utilities to detect Azure cloud provider.
gce
Package gce provides utilities to detect gce cloud provider.
Package gce provides utilities to detect gce cloud provider.
ibm
Package ibm provides utilities to detect ibm cloud provider.
Package ibm provides utilities to detect ibm cloud provider.
kubernetes
Package kubernetes provides utilities to detect cloud provider from kubernetes.
Package kubernetes provides utilities to detect cloud provider from kubernetes.
oracle
Package oracle provides utilities to detect oracle cloud provider.
Package oracle provides utilities to detect oracle cloud provider.
tencent
Package tencent provides utilities to detect tencent cloud provider.
Package tencent provides utilities to detect tencent cloud provider.
Package clusteragent provides clients for the APIs exposed by the Cluster Agent and the Cluster Check Runners.
Package clusteragent provides clients for the APIs exposed by the Cluster Agent and the Cluster Check Runners.
common module
compression module
Package containers implements the functionality needed to fetch metrics from the different runtimes supported (Docker, containerd, etc.).
Package containers implements the functionality needed to fetch metrics from the different runtimes supported (Docker, containerd, etc.).
cri
metadata
Package containers provides metadata for containers.
Package containers provides metadata for containers.
metrics
Package metrics registers all the different collectors for container-related metrics.
Package metrics registers all the different collectors for container-related metrics.
metrics/containerd
Package containerd implements the containerd metrics collector
Package containerd implements the containerd metrics collector
metrics/cri
Package cri implements the CRI metrics collector.
Package cri implements the CRI metrics collector.
metrics/docker
Package docker implements the Docker metrics collector.
Package docker implements the Docker metrics collector.
metrics/ecsfargate
Package ecsfargate implements the ECS Fargate metrics collector.
Package ecsfargate implements the ECS Fargate metrics collector.
metrics/kubelet
Package kubelet implements the Kubelet metrics collector.
Package kubelet implements the Kubelet metrics collector.
metrics/provider
Package provider defines the Provider interface which allows to get metrics collectors for the different container runtimes supported (Docker, containerd, etc.).
Package provider defines the Provider interface which allows to get metrics collectors for the different container runtimes supported (Docker, containerd, etc.).
metrics/system
Package system implements the system metrics collector, which is based on Linux cgroups.
Package system implements the system metrics collector, which is based on Linux cgroups.
image Module
Package crashreport provides shared helpers for recording crash detection state
Package crashreport provides shared helpers for recording crash detection state
Package crio provides a crio client.
Package crio provides a crio client.
defaultpaths module
Package dmi provides helper functions to interact with DMI
Package dmi provides helper functions to interact with DMI
Package ec2 provides information when running in ec2
Package ec2 provides information when running in ec2
ecs
Package ecs provides metadata collection when the Agent runs on the ECS platform
Package ecs provides metadata collection when the Agent runs on the ECS platform
common
Package common provides common functionality for the different ECS clients.
Package common provides common functionality for the different ECS clients.
metadata
Package metadata provides clients for Metadata APIs exposed by the ECS agent.
Package metadata provides clients for Metadata APIs exposed by the ECS agent.
metadata/testutil
Package testutil implements a fake ECS client to be used in tests.
Package testutil implements a fake ECS client to be used in tests.
executable module
Package fargate implements functions to interact with fargate
Package fargate implements functions to interact with fargate
filesystem module
flavor module
Package funcs provides utilities for functions, such as caching and memoization.
Package funcs provides utilities for functions, such as caching and memoization.
fxutil module
go_routines module
grpc module
Package hostname provides utilities to detect the hostname of the host.
Package hostname provides utilities to detect the hostname of the host.
validate Module
http module
Package input implements helper functions to communicate with the user via CLI
Package input implements helper functions to communicate with the user via CLI
Package installinfo offers helpers to interact with the 'install_info' file.
Package installinfo offers helpers to interact with the 'install_info' file.
Package intern lets you make smaller comparable values by boxing a larger comparable value (such as a 16 byte string header) down into a globally unique 8 byte pointer.
Package intern lets you make smaller comparable values by boxing a larger comparable value (such as a 16 byte string header) down into a globally unique 8 byte pointer.
json module
Package jsonquery interacts with jq queries
Package jsonquery interacts with jq queries
Package kernel is utilities for the Linux kernel
Package kernel is utilities for the Linux kernel
Package ktime holds time related files
Package ktime holds time related files
Package kubelet provides utilities to interact with kubelet.
Package kubelet provides utilities to interact with kubelet.
Package kubernetes provides several helpers to interact with a Kubernetes cluster.
Package kubernetes provides several helpers to interact with a Kubernetes cluster.
apiserver
Package apiserver provides an API client for the Kubernetes API server.
Package apiserver provides an API client for the Kubernetes API server.
apiserver/controllers
Package controllers is responsible for running the Kubernetes controllers needed by the Datadog Cluster Agent
Package controllers is responsible for running the Kubernetes controllers needed by the Datadog Cluster Agent
apiserver/leaderelection
Package leaderelection provides functions related with the leader election mechanism offered in Kubernetes.
Package leaderelection provides functions related with the leader election mechanism offered in Kubernetes.
apiserver/leaderelection/metrics
Package metrics provides telemetry to know who's the leader in Kubernetes objects that implement the leader/follower pattern.
Package metrics provides telemetry to know who's the leader in Kubernetes objects that implement the leader/follower pattern.
clustername
Package clustername provides helpers to get a Kubernetes cluster name.
Package clustername provides helpers to get a Kubernetes cluster name.
hostinfo
Package hostinfo provides functions to get annotations, labels, etc.
Package hostinfo provides functions to get annotations, labels, etc.
kubelet
Package kubelet provides a client for the Kubelet API.
Package kubelet provides a client for the Kubelet API.
log module
setup Module
Package lsof provides a way to list open files for a given process
Package lsof provides a way to list open files for a given process
optional module
Package pdhutil provides the Windows PDH API
Package pdhutil provides the Windows PDH API
Package podman implements a client for the Podman DB (BoltDB).
Package podman implements a client for the Podman DB (BoltDB).
pointer module
Package port provides utilities around host port information.
Package port provides utilities around host port information.
portlist
Package portlist contains code that checks what ports are open and listening on the current machine.
Package portlist contains code that checks what ports are open and listening on the current machine.
Package profiling interacts with internal profiling
Package profiling interacts with internal profiling
Package prometheus provides utility functions to deal with prometheus endpoints
Package prometheus provides utility functions to deal with prometheus endpoints
Package retry implements a configurable retry mechanism that can be embedded in any class needing a retry-on-error system.
Package retry implements a configurable retry mechanism that can be embedded in any class needing a retry-on-error system.
Package safeelf provides safe (from panics) wrappers around ELF parsing
Package safeelf provides safe (from panics) wrappers around ELF parsing
scrubber module
sort module
startstop module
statstracker module
Package strings contains utilities for working with strings in Go
Package strings contains utilities for working with strings in Go
Package subscriptions provides support for managing subscriptions between components.
Package subscriptions provides support for managing subscriptions between components.
Package sync is utilities for synchronization
Package sync is utilities for synchronization
system module
socket Module
tagger module
testutil module
Package tmplvar provides functions to interact with template variables
Package tmplvar provides functions to interact with template variables
Package trie provides a SuffixTrie data structure that can be used to index data by suffixes of strings.
Package trie provides a SuffixTrie data structure that can be used to index data by suffixes of strings.
Package trivy implement a simple overlayfs like filesystem to be able to scan through layered filesystems.
Package trivy implement a simple overlayfs like filesystem to be able to scan through layered filesystems.
uuid module
winutil module
workqueue
telemetry
Package telemetry is a utility package that provides helper methods for creating and registering metrics for kubernetes workqueue.
Package telemetry is a utility package that provides helper methods for creating and registering metrics for kubernetes workqueue.
Package xc provides a function to get system clock frequency
Package xc provides a function to get system clock frequency

Jump to

Keyboard shortcuts

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