utils

package module
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Overview

Package utils offers a number of high level helpers to work with the configuration

Index

Constants

View Source
const (
	// InfraURLPrefix is the default infra URL prefix for datadog
	InfraURLPrefix = "https://app."
)

Variables

This section is empty.

Functions

func AddAgentVersionToDomain

func AddAgentVersionToDomain(DDURL string, app string) (string, error)

AddAgentVersionToDomain prefixes the domain with the agent version: X-Y-Z.domain

func BuildURLWithPrefix added in v0.52.0

func BuildURLWithPrefix(prefix, site string) string

BuildURLWithPrefix will return an HTTP(s) URL for a site given a certain prefix

func ConfFileDirectory

func ConfFileDirectory(c pkgconfigmodel.Reader) string

ConfFileDirectory returns the absolute path to the folder containing the config file used to populate the registry

func GetConfiguredTags

func GetConfiguredTags(c pkgconfigmodel.Reader, includeDogstatsd bool) []string

GetConfiguredTags returns list of tags from a configuration, based on `tags` (DD_TAGS) and `extra_tags“ (DD_EXTRA_TAGS), with `dogstatsd_tags` (DD_DOGSTATSD_TAGS) if includeDogdstatsd is true.

func GetInfraEndpoint

func GetInfraEndpoint(c pkgconfigmodel.Reader) string

GetInfraEndpoint returns the main DD Infra URL defined in config, based on the value of `site` and `dd_url`

func GetMRFEndpoint added in v0.54.0

func GetMRFEndpoint(c pkgconfigmodel.Reader, prefix, ddMRFURLKey string) (string, error)

GetMRFEndpoint returns the MRF DD URL defined in the config, based on `multi_region_failover.site` and the prefix, or ddMRFURLKey

func GetMRFInfraEndpoint added in v0.54.0

func GetMRFInfraEndpoint(c pkgconfigmodel.Reader) (string, error)

GetMRFInfraEndpoint returns the MRF DD Infra URL defined in config, based on the value of `multi_region_failover.site` and `multi_region_failover.dd_url`

func GetMainEndpoint

func GetMainEndpoint(c pkgconfigmodel.Reader, prefix string, ddURLKey string) string

GetMainEndpoint returns the main DD URL defined in the config, based on `site` and the prefix, or ddURLKey

func GetMainEndpointBackwardCompatible

func GetMainEndpointBackwardCompatible(c pkgconfigmodel.Reader, prefix string, ddURLKey string, backwardKey string) string

GetMainEndpointBackwardCompatible implements the logic to extract the DD URL from a config, based on `site`,ddURLKey and a backward compatible key

func GetMultipleEndpoints

func GetMultipleEndpoints(c pkgconfigmodel.Reader) (map[string][]string, error)

GetMultipleEndpoints returns the api keys per domain specified in the main agent config

func GetTraceAgentDefaultEnv

func GetTraceAgentDefaultEnv(c pkgconfigmodel.Reader) string

GetTraceAgentDefaultEnv returns the default env for the trace agent

func IsCheckTelemetryEnabled

func IsCheckTelemetryEnabled(checkName string, cfg pkgconfigmodel.Reader) bool

IsCheckTelemetryEnabled returns if we want telemetry for the given check. Returns true if a * is present in the telemetry.checks list.

func IsTelemetryEnabled

func IsTelemetryEnabled(cfg pkgconfigmodel.Reader) bool

IsTelemetryEnabled returns whether or not telemetry is enabled

func SanitizeAPIKey

func SanitizeAPIKey(key string) string

SanitizeAPIKey strips newlines and other control characters from a given string.

func SetLogLevel added in v0.57.0

func SetLogLevel(level string, config pkgconfigmodel.Writer, source pkgconfigmodel.Source) error

SetLogLevel validates and sets the "log_level" setting in the configuration. The logger will automatically react to this configuration change. It takes a `level` string representing the desired log level and a `source` model.Source indicating where the new level came from (CLI, Remote Config, ...). It returns an error if the log level is invalid

Types

type MetadataAsTags added in v0.58.0

type MetadataAsTags interface {
	// GetPodLabelsAsTags returns pod labels as tags
	GetPodLabelsAsTags() map[string]string
	// GetPodAnnotationsAsTags returns pod annotations as tags
	GetPodAnnotationsAsTags() map[string]string
	// GetNodeLabelsAsTags returns node labels as tags
	GetNodeLabelsAsTags() map[string]string
	// GetNodeAnnotationsAsTags returns node annotations as tags
	GetNodeAnnotationsAsTags() map[string]string
	// GetNamespaceLabelsAsTags returns namespace labels as tags
	GetNamespaceLabelsAsTags() map[string]string
	// GetNamespaceAnnotationsAsTags returns namespace annotations as tags
	GetNamespaceAnnotationsAsTags() map[string]string
	// GetResourcesLabelsAsTags returns resources labels as tags
	GetResourcesLabelsAsTags() map[string]map[string]string
	// GetResourcesAnnotationsAsTags returns resources annotations as tags
	GetResourcesAnnotationsAsTags() map[string]map[string]string
}

MetadataAsTags contains the labels as tags and annotations as tags for each kubernetes resource based on the user configurations of the following options ordered in increasing order of priority:

kubernetes_pod_labels_as_tags kubernetes_pod_annotations_as_tags kubernetes_node_labels_as_tags kubernetes_node_annotations_as_tags kubernetes_namespace_labels_as_tags kubernetes_namespace_annotations_as_tags kubernetes_resources_labels_as_tags kubernetes_resources_anotations_as_tags

In case of conflict, higher priority configuration value takes precedences For example, if kubernetes_pod_labels_as_tags = {`l1`: `v1`, `l2`: `v2`} and kubernetes_resources_labels_as_tags = {`pods`: {`l1`: `x`}}, the resulting labels as tags for pods will be {`l1`: `x`, `l2`: `v2`}

func GetMetadataAsTags added in v0.58.0

func GetMetadataAsTags(c pkgconfigmodel.Reader) MetadataAsTags

GetMetadataAsTags returns a merged configuration of all labels and annotations as tags set by the user

type MetadataProviders

type MetadataProviders struct {
	Name     string        `mapstructure:"name"`
	Interval time.Duration `mapstructure:"interval"`
}

MetadataProviders helps unmarshalling `metadata_providers` config param

func GetMetadataProviders

func GetMetadataProviders(c pkgconfigmodel.Reader) ([]MetadataProviders, error)

GetMetadataProviders returns the "metadata_providers" set in the configuration

Jump to

Keyboard shortcuts

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