Documentation
¶
Overview ¶
Package confmaputils provides shared utilities for manipulating OpenTelemetry collector confmaps (map[string]any) and building standard Datadog component configs.
Index ¶
- Constants
- func ComponentName(fullName string) string
- func Ensure[T any](c ConfMap, path string) (T, error)
- func FilterProcessorConfig() map[string]any
- func Get[T any](c ConfMap, path string) (T, bool)
- func IsComponentType(name, componentType string) bool
- func PrometheusReceiverConfig(jobName, target string) map[string]any
- func Set[T any](c ConfMap, path string, value T) error
- func SetDefault[T any](c ConfMap, path string, value T) (bool, error)
- type ConfMap
Constants ¶
const AutoConfiguredSuffix = "dd-autoconfigured"
AutoConfiguredSuffix is the OTEL component name suffix used for all components that are automatically injected by Datadog tooling (as opposed to components explicitly declared by the user).
Variables ¶
This section is empty.
Functions ¶
func ComponentName ¶
ComponentName returns the type portion of a full OTEL component name. OTEL components follow the convention "type" or "type/id". Examples: "otlp_http/prod" → "otlp_http", "prometheus" → "prometheus".
func Ensure ¶
Ensure retrieves a value of type T from the ConfMap at the given path. If the path does not exist, it creates it with the zero value of T. For map types, creates an empty map rather than nil. Returns an error if an intermediate path element exists but is not a map.
func FilterProcessorConfig ¶
FilterProcessorConfig returns the configuration for a filter processor that drops internal Prometheus scrape metrics from being exported.
func Get ¶
Get retrieves a value of type T from the ConfMap at the given "::" separated path. Returns the value and true if found and of the correct type, zero value and false otherwise. Does not modify the map.
func IsComponentType ¶
IsComponentType reports whether name belongs to the given componentType. It matches both the bare type ("prometheus") and any named instance ("prometheus/foo").
func PrometheusReceiverConfig ¶
PrometheusReceiverConfig returns a Prometheus receiver configuration that scrapes the given target with the given job name. Both the otelcol converter ("datadog-agent", "0.0.0.0:8888") and the host profiler ("host-profiler-internal", "127.0.0.1:8889") use this same structure.
func Set ¶
Set sets a value of type T in the ConfMap at the given "::" separated path. Creates intermediate maps as needed. Returns an error if an intermediate path element exists but is not a map.
func SetDefault ¶
SetDefault sets a default value if the key does not exist at the given path. If the key exists with a different value, the existing value is preserved (user override wins). Returns (true, nil) if the default is active (newly set or already matching), (false, nil) if a user override was preserved, or an error if path traversal fails.