confmaputils

package module
v0.82.0-devel Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package confmaputils provides shared utilities for manipulating OpenTelemetry collector confmaps (map[string]any) and building standard Datadog component configs.

Index

Constants

View Source
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

func ComponentName(fullName string) string

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

func Ensure[T any](c ConfMap, path string) (T, error)

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

func FilterProcessorConfig() map[string]any

FilterProcessorConfig returns the configuration for a filter processor that drops internal Prometheus scrape metrics from being exported.

func Get

func Get[T any](c ConfMap, path string) (T, bool)

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

func IsComponentType(name, componentType string) bool

IsComponentType reports whether name belongs to the given componentType. It matches both the bare type ("prometheus") and any named instance ("prometheus/foo").

func PrometheusReceiverConfig

func PrometheusReceiverConfig(jobName, target string) map[string]any

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

func Set[T any](c ConfMap, path string, value T) error

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

func SetDefault[T any](c ConfMap, path string, value T) (bool, error)

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.

Types

type ConfMap

type ConfMap = map[string]any

ConfMap is an alias for the map type used throughout OTel confmap manipulation.

Jump to

Keyboard shortcuts

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