Documentation
¶
Overview ¶
Package config defines the configuration shared by the Datadog exporter and Datadog connector. It is a fork of github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog/config maintained locally in the Agent repo.
Index ¶
- Constants
- Variables
- func CreateDefaultConfig() component.Config
- func StaticAPIKeyCheck(key string) errordeprecated
- type APIConfig
- type Config
- type ConnectorComponentConfig
- type CumulativeMonotonicSumMode
- type HistogramConfig
- type HistogramMode
- type HostMetadataConfig
- type HostnameSource
- type InitialValueMode
- type LogsConfig
- type MetricsConfig
- type MetricsExporterConfig
- type OrchestratorExplorerConfig
- type SumConfig
- type SummaryConfig
- type SummaryMode
- type TagsConfig
- type TracesConfig
- type TracesConnectorConfig
- type TracesExporterConfig
Constants ¶
const (
// DefaultSite is the default site of the Datadog intake to send data to
DefaultSite = "datadoghq.com"
)
Variables ¶
var ( // ErrUnsetAPIKey is returned when the API key is not set. ErrUnsetAPIKey = errors.New("api.key is not set") // ErrNoMetadata is returned when only_metadata is enabled but host metadata is disabled or hostname_source is not first_resource. ErrNoMetadata = errors.New("only_metadata can't be enabled when host_metadata::enabled = false or host_metadata::hostname_source != first_resource") // ErrEmptyEndpoint is returned when an endpoint is explicitly set to empty. ErrEmptyEndpoint = errors.New("endpoint cannot be empty") )
Functions ¶
func CreateDefaultConfig ¶
CreateDefaultConfig creates the default exporter configuration
func StaticAPIKeyCheck
deprecated
Types ¶
type APIConfig ¶
type APIConfig struct {
// Key is the Datadog API key to associate your Agent's data with your organization.
// Create a new API key here: https://app.datadoghq.com/account/settings
Key configopaque.String `mapstructure:"key"`
// Site is the site of the Datadog intake to send data to.
// The default value is "datadoghq.com".
Site string `mapstructure:"site"`
// FailOnInvalidKey states whether to exit at startup on invalid API key.
// The default value is false.
FailOnInvalidKey bool `mapstructure:"fail_on_invalid_key"`
// contains filtered or unexported fields
}
APIConfig defines the API configuration options
type Config ¶
type Config struct {
confighttp.ClientConfig `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
QueueSettings configoptional.Optional[exporterhelper.QueueBatchConfig] `mapstructure:"sending_queue"`
configretry.BackOffConfig `mapstructure:"retry_on_failure"`
TagsConfig `mapstructure:",squash"`
// API defines the Datadog API configuration.
API APIConfig `mapstructure:"api"`
// Metrics defines the Metrics exporter specific configuration
Metrics MetricsConfig `mapstructure:"metrics"`
// Traces defines the Traces exporter specific configuration
Traces TracesExporterConfig `mapstructure:"traces"`
// Logs defines the Logs exporter specific configuration
Logs LogsConfig `mapstructure:"logs"`
// HostMetadata defines the host metadata specific configuration
HostMetadata HostMetadataConfig `mapstructure:"host_metadata"`
// HostnameDetectionTimeout defines the timeout for hostname detection.
// This is necessary for initializing datadog exporter
// On K8s, it must be set to less than `failureThreshold * periodSeconds` due to
// initialization blocking health_check liveness probes on startup.
// If set to zero duration, there will be no timeout applied.
// Default is 25 seconds.
HostnameDetectionTimeout time.Duration `mapstructure:"hostname_detection_timeout"`
// OnlyMetadata defines whether to only send metadata
// This is useful for agent-collector setups, so that
// metadata about a host is sent to the backend even
// when telemetry data is reported via a different host.
//
// This flag is incompatible with disabling host metadata,
// `use_resource_metadata`, or `host_metadata::hostname_source != first_resource`
OnlyMetadata bool `mapstructure:"only_metadata"`
OrchestratorExplorer OrchestratorExplorerConfig `mapstructure:"orchestrator_explorer"`
// contains filtered or unexported fields
}
Config defines configuration for the Datadog exporter.
func CheckAndCastConfig ¶
CheckAndCastConfig checks a component.Config type and casts it to the Datadog Config struct.
func (*Config) AddWarning ¶
AddWarning adds a warning message to the configuration. This allows external modules to add warnings that will be logged later.
func (*Config) AddWarningf ¶
AddWarningf adds a formatted warning message to the configuration. This allows external modules to add formatted warnings that will be logged later.
func (*Config) GetWarnings ¶
GetWarnings returns a copy of all warnings stored in the configuration. This allows external modules to retrieve and process warnings as needed.
func (*Config) LogWarnings ¶
LogWarnings logs warning messages that were generated on unmarshaling.
type ConnectorComponentConfig ¶
type ConnectorComponentConfig struct {
// Traces defines the Traces specific configuration
Traces TracesConnectorConfig `mapstructure:"traces"`
// contains filtered or unexported fields
}
ConnectorComponentConfig defines the configuration for the Datadog connector component
func (*ConnectorComponentConfig) Validate ¶
func (c *ConnectorComponentConfig) Validate() error
type CumulativeMonotonicSumMode ¶
type CumulativeMonotonicSumMode string
CumulativeMonotonicSumMode is the export mode for OTLP Sum metrics.
const ( // CumulativeMonotonicSumModeToDelta calculates delta for // cumulative monotonic sum metrics in the client side and reports // them as Datadog counts. CumulativeMonotonicSumModeToDelta CumulativeMonotonicSumMode = "to_delta" // CumulativeMonotonicSumModeRawValue reports the raw value for // cumulative monotonic sum metrics as a Datadog gauge. CumulativeMonotonicSumModeRawValue CumulativeMonotonicSumMode = "raw_value" )
func (*CumulativeMonotonicSumMode) UnmarshalText ¶
func (sm *CumulativeMonotonicSumMode) UnmarshalText(in []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
type HistogramConfig ¶
type HistogramConfig struct {
// Mode for exporting histograms. Valid values are 'distributions', 'counters' or 'nobuckets'.
// - 'distributions' sends histograms as Datadog distributions (recommended).
// - 'counters' sends histograms as Datadog counts, one metric per bucket.
// - 'nobuckets' sends no bucket histogram metrics. Aggregation metrics will still be sent
// if `send_aggregation_metrics` is enabled.
//
// The current default is 'distributions'.
Mode HistogramMode `mapstructure:"mode"`
// SendCountSum states if the export should send .sum and .count metrics for histograms.
// The default is false.
//
// Deprecated: [v0.75.0] Use `send_aggregation_metrics` (HistogramConfig.SendAggregations) instead.
SendCountSum bool `mapstructure:"send_count_sum_metrics"`
// SendAggregations states if the exporter should send .sum, .count, .min and .max metrics for histograms.
// The default is false.
SendAggregations bool `mapstructure:"send_aggregation_metrics"`
}
HistogramConfig customizes export of OTLP Histograms.
type HistogramMode ¶
type HistogramMode string
const ( // HistogramModeNoBuckets reports no bucket histogram metrics. .sum and .count metrics will still be sent // if `send_count_sum_metrics` is enabled. HistogramModeNoBuckets HistogramMode = "nobuckets" // HistogramModeCounters reports histograms as Datadog counts, one metric per bucket. HistogramModeCounters HistogramMode = "counters" // HistogramModeDistributions reports histograms as Datadog distributions (recommended). HistogramModeDistributions HistogramMode = "distributions" )
func (*HistogramMode) UnmarshalText ¶
func (hm *HistogramMode) UnmarshalText(in []byte) error
type HostMetadataConfig ¶
type HostMetadataConfig struct {
// Enabled enables the host metadata functionality.
Enabled bool `mapstructure:"enabled"`
// HostnameSource is the source for the hostname of host metadata.
// This hostname is used for identifying the infrastructure list, host map and host tag information related to the host where the Datadog exporter is running.
// Changing this setting will not change the host used to tag your metrics, traces and logs in any way.
// For remote hosts, see https://docs.datadoghq.com/opentelemetry/schema_semantics/host_metadata/.
//
// Valid values are 'first_resource' and 'config_or_system':
// - 'first_resource' picks the host metadata hostname from the resource
// attributes on the first OTLP payload that gets to the exporter.
// If the first payload lacks hostname-like attributes, it will fallback to 'config_or_system'.
// **Do not use this hostname source if receiving data from multiple hosts**.
// - 'config_or_system' picks the host metadata hostname from the 'hostname' setting,
// If this is empty it will use available system APIs and cloud provider endpoints.
//
// The default is 'config_or_system'.
HostnameSource HostnameSource `mapstructure:"hostname_source"`
// Tags is a list of host tags.
// These tags will be attached to telemetry signals that have the host metadata hostname.
// To attach tags to telemetry signals regardless of the host, use a processor instead.
Tags []string `mapstructure:"tags"`
// ReporterPeriod is the period at which the host metadata reporter will run.
ReporterPeriod time.Duration `mapstructure:"reporter_period"`
}
HostMetadataConfig defines the host metadata related configuration. Host metadata is the information used for populating the infrastructure list, the host map and providing host tags functionality.
The exporter will send host metadata for a single host, whose name is chosen according to `host_metadata::hostname_source`.
type HostnameSource ¶
type HostnameSource string
HostnameSource is the source for the hostname of host metadata.
const ( // HostnameSourceFirstResource picks the host metadata hostname from the resource // attributes on the first OTLP payload that gets to the exporter. If it is lacking any // hostname-like attributes, it will fallback to 'config_or_system' behavior (see below). // // Do not use this hostname source if receiving data from multiple hosts. HostnameSourceFirstResource HostnameSource = "first_resource" // HostnameSourceConfigOrSystem picks the host metadata hostname from the 'hostname' setting, // and if this is empty, from available system APIs and cloud provider endpoints. HostnameSourceConfigOrSystem HostnameSource = "config_or_system" )
func (*HostnameSource) UnmarshalText ¶
func (sm *HostnameSource) UnmarshalText(in []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
type InitialValueMode ¶
type InitialValueMode string
InitialValueMode defines what the exporter should do with the initial value of a time series when transforming from cumulative to delta.
const ( // InitialValueModeAuto reports the initial value if its start timestamp // is set and it happens after the process was started. InitialValueModeAuto InitialValueMode = "auto" // InitialValueModeDrop always drops the initial value. InitialValueModeDrop InitialValueMode = "drop" // InitialValueModeKeep always reports the initial value. InitialValueModeKeep InitialValueMode = "keep" )
func (*InitialValueMode) UnmarshalText ¶
func (iv *InitialValueMode) UnmarshalText(in []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
type LogsConfig ¶
type LogsConfig struct {
// TCPAddr.Endpoint is the host of the Datadog intake server to send logs to.
// If unset, the value is obtained from the Site.
confignet.TCPAddrConfig `mapstructure:",squash"`
// UseCompression enables the logs agent to compress logs before sending them.
// Note: this config option does not apply when the `exporter.datadogexporter.UseLogsAgentExporter` feature flag is disabled.
UseCompression bool `mapstructure:"use_compression"`
// CompressionLevel accepts values from 0 (no compression) to 9 (maximum compression but higher resource usage).
// Only takes effect if UseCompression is set to true.
// Note: this config option does not apply when the `exporter.datadogexporter.UseLogsAgentExporter` feature flag is disabled.
CompressionLevel int `mapstructure:"compression_level"`
// BatchWait represents the maximum time the logs agent waits to fill each batch of logs before sending.
// Note: this config option does not apply when the `exporter.datadogexporter.UseLogsAgentExporter` feature flag is disabled.
BatchWait int `mapstructure:"batch_wait"`
}
LogsConfig defines logs exporter specific configuration
type MetricsConfig ¶
type MetricsConfig struct {
// DeltaTTL defines the time that previous points of a cumulative monotonic
// metric are kept in memory to calculate deltas
DeltaTTL int64 `mapstructure:"delta_ttl"`
// TCPAddr.Endpoint is the host of the Datadog intake server to send metrics to.
// If unset, the value is obtained from the Site.
confignet.TCPAddrConfig `mapstructure:",squash"`
ExporterConfig MetricsExporterConfig `mapstructure:",squash"`
// HistConfig defines the export of OTLP Histograms.
HistConfig HistogramConfig `mapstructure:"histograms"`
// SumConfig defines the export of OTLP Sums.
SumConfig SumConfig `mapstructure:"sums"`
// SummaryConfig defines the export for OTLP Summaries.
SummaryConfig SummaryConfig `mapstructure:"summaries"`
}
MetricsConfig defines the metrics exporter specific configuration options
func (MetricsConfig) ToTranslatorOpts ¶
func (mcfg MetricsConfig) ToTranslatorOpts() []otlpmetrics.TranslatorOption
ToTranslatorOpts returns a list of metrics translator options from the metrics config
type MetricsExporterConfig ¶
type MetricsExporterConfig struct {
// ResourceAttributesAsTags, if set to true, will use the exporterhelper feature to transform all
// resource attributes into metric labels, which are then converted into tags
ResourceAttributesAsTags bool `mapstructure:"resource_attributes_as_tags"`
// InstrumentationScopeMetadataAsTags, if set to true, adds the name and version of the
// instrumentation scope that created a metric to the metric tags
InstrumentationScopeMetadataAsTags bool `mapstructure:"instrumentation_scope_metadata_as_tags"`
// contains filtered or unexported fields
}
MetricsExporterConfig provides options for a user to customize the behavior of the metrics exporter
type OrchestratorExplorerConfig ¶
type OrchestratorExplorerConfig struct {
// TCPAddr.Endpoint is the host of the Datadog orchestrator intake server to send data to.
// If unset, the value is obtained from the Site.
confignet.TCPAddrConfig `mapstructure:",squash"`
// Enabled enables the orchestrator explorer.
Enabled bool `mapstructure:"enabled"`
}
OrchestratorExplorerConfig defines configuration for the Datadog orchestrator explorer.
type SumConfig ¶
type SumConfig struct {
// CumulativeMonotonicMode is the mode for exporting OTLP Cumulative Monotonic Sums.
// Valid values are 'to_delta' or 'raw_value'.
// - 'to_delta' calculates delta for cumulative monotonic sums and sends it as a Datadog count.
// - 'raw_value' sends the raw value of cumulative monotonic sums as Datadog gauges.
//
// The default is 'to_delta'.
// See https://docs.datadoghq.com/metrics/otlp/?tab=sum#mapping for details and examples.
CumulativeMonotonicMode CumulativeMonotonicSumMode `mapstructure:"cumulative_monotonic_mode"`
// InitialCumulativeMonotonicMode defines the behavior of the exporter when receiving the first value
// of a cumulative monotonic sum.
InitialCumulativeMonotonicMode InitialValueMode `mapstructure:"initial_cumulative_monotonic_value"`
}
SumConfig customizes export of OTLP Sums.
type SummaryConfig ¶
type SummaryConfig struct {
// Mode is the mode for exporting OTLP Summaries.
// Valid values are 'noquantiles' or 'gauges'.
// - 'noquantiles' sends no `.quantile` metrics. `.sum` and `.count` metrics will still be sent.
// - 'gauges' sends `.quantile` metrics as gauges tagged by the quantile.
//
// The default is 'gauges'.
// See https://docs.datadoghq.com/metrics/otlp/?tab=summary#mapping for details and examples.
Mode SummaryMode `mapstructure:"mode"`
// contains filtered or unexported fields
}
SummaryConfig customizes export of OTLP Summaries.
type SummaryMode ¶
type SummaryMode string
SummaryMode is the export mode for OTLP Summary metrics.
const ( // SummaryModeNoQuantiles sends no `.quantile` metrics. `.sum` and `.count` metrics will still be sent. SummaryModeNoQuantiles SummaryMode = "noquantiles" // SummaryModeGauges sends `.quantile` metrics as gauges tagged by the quantile. SummaryModeGauges SummaryMode = "gauges" )
func (*SummaryMode) UnmarshalText ¶
func (sm *SummaryMode) UnmarshalText(in []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
type TagsConfig ¶
type TagsConfig struct {
// Hostname is the fallback hostname used for payloads without hostname-identifying attributes.
// This option will NOT change the hostname applied to your metrics, traces and logs if they already have hostname-identifying attributes.
// If unset, the hostname will be determined automatically. See https://docs.datadoghq.com/opentelemetry/schema_semantics/hostname/?tab=datadogexporter#fallback-hostname-logic for details.
//
// Prefer using the `datadog.host.name` resource attribute over using this setting.
// See https://docs.datadoghq.com/opentelemetry/schema_semantics/hostname/?tab=datadogexporter#general-hostname-semantic-conventions for details.
Hostname string `mapstructure:"hostname"`
// contains filtered or unexported fields
}
TagsConfig defines the tag-related configuration It is embedded in the configuration
type TracesConfig ¶
type TracesConfig struct {
// ignored resources
// A blacklist of regular expressions can be provided to disable certain traces based on their resource name
// all entries must be surrounded by double quotes and separated by commas.
// ignore_resources: ["(GET|POST) /healthcheck"]
IgnoreResources []string `mapstructure:"ignore_resources"`
// SpanNameRemappings is the map of datadog span names and preferred name to map to. This can be used to
// automatically map Datadog Span Operation Names to an updated value. All entries should be key/value pairs.
// span_name_remappings:
// io.opentelemetry.javaagent.spring.client: spring.client
// instrumentation:express.server: express
// go.opentelemetry.io_contrib_instrumentation_net_http_otelhttp.client: http.client
SpanNameRemappings map[string]string `mapstructure:"span_name_remappings"`
// If set to true the OpenTelemetry span name will used in the Datadog resource name.
// If set to false the resource name will be filled with the instrumentation library name + span kind.
// The default value is `false`.
SpanNameAsResourceName bool `mapstructure:"span_name_as_resource_name"`
// If set to true, enables an additional stats computation check on spans to see they have an eligible `span.kind` (server, consumer, client, producer).
// If enabled, a span with an eligible `span.kind` will have stats computed. If disabled, only top-level and measured spans will have stats computed.
// NOTE: For stats computed from OTel traces, only top-level spans are considered when this option is off.
// If you are sending OTel traces and want stats on non-top-level spans, this flag will need to be enabled.
// If you are sending OTel traces and do not want stats computed by span kind, you need to disable this flag and disable `compute_top_level_by_span_kind`.
ComputeStatsBySpanKind bool `mapstructure:"compute_stats_by_span_kind"`
// If set to true, root spans and spans with a server or consumer `span.kind` will be marked as top-level.
// Additionally, spans with a client or producer `span.kind` will have stats computed.
// Enabling this config option may increase the number of spans that generate trace metrics, and may change which spans appear as top-level in Datadog.
// ComputeTopLevelBySpanKind needs to be enabled in both the Datadog connector and Datadog exporter configs if both components are being used.
// The default value is `false`.
ComputeTopLevelBySpanKind bool `mapstructure:"compute_top_level_by_span_kind"`
// If set to true, enables `peer.service` aggregation in the exporter. If disabled, aggregated trace stats will not include `peer.service` as a dimension.
// For the best experience with `peer.service`, it is recommended to also enable `compute_stats_by_span_kind`.
// If enabling both causes the datadog exporter to consume too many resources, try disabling `compute_stats_by_span_kind` first.
// If the overhead remains high, it will be due to a high cardinality of `peer.service` values from the traces. You may need to check your instrumentation.
//
// Deprecated: Please use PeerTagsAggregation instead
PeerServiceAggregation bool `mapstructure:"peer_service_aggregation"`
// If set to true, enables aggregation of peer related tags (e.g., `peer.service`, `db.instance`, etc.) in the datadog exporter.
// If disabled, aggregated trace stats will not include these tags as dimensions on trace metrics.
// For the best experience with peer tags, Datadog also recommends enabling `compute_stats_by_span_kind`.
// If you are using an OTel tracer, it's best to have both enabled because client/producer spans with relevant peer tags
// may not be marked by the datadog exporter as top-level spans.
// If enabling both causes the datadog exporter to consume too many resources, try disabling `compute_stats_by_span_kind` first.
// A high cardinality of peer tags or APM resources can also contribute to higher CPU and memory consumption.
// You can check for the cardinality of these fields by making trace search queries in the Datadog UI.
// The default list of peer tags can be found in https://github.com/DataDog/datadog-agent/blob/main/pkg/trace/stats/concentrator.go.
PeerTagsAggregation bool `mapstructure:"peer_tags_aggregation"`
// [BETA] Optional list of supplementary peer tags that go beyond the defaults. The Datadog backend validates all tags
// and will drop ones that are unapproved. The default set of peer tags can be found at
// https://github.com/DataDog/datadog-agent/blob/505170c4ac8c3cbff1a61cf5f84b28d835c91058/pkg/trace/stats/concentrator.go#L55.
PeerTags []string `mapstructure:"peer_tags"`
}
TracesConfig defines the traces exporter specific configuration options
func (TracesConfig) Marshal ¶
func (c TracesConfig) Marshal(conf *confmap.Conf) error
Marshal emits only the canonical peer tags aggregation setting.
func (*TracesConfig) Validate ¶
func (c *TracesConfig) Validate() error
type TracesConnectorConfig ¶
type TracesConnectorConfig struct {
// TracesConfig contains the common configuration for all traces.
TracesConfig `mapstructure:",squash"`
// TraceBuffer specifies the number of Datadog Agent TracerPayloads to buffer before dropping.
// The default value is 1000.
TraceBuffer int `mapstructure:"trace_buffer"`
// ResourceAttributesAsContainerTags specifies the list of resource attributes to be used as container tags.
ResourceAttributesAsContainerTags []string `mapstructure:"resource_attributes_as_container_tags"`
// BucketInterval specifies the time interval size of aggregation buckets that aggregate the Datadog trace metrics.
// It is also the time interval that Datadog trace metrics payloads are flushed to the pipeline.
// If you are concerned about the metric volume generated by the Datadog connector and the resulting networking egress, try increasing bucket_interval.
// Default is 10s if unset.
BucketInterval time.Duration `mapstructure:"bucket_interval"`
// IgnoreMissingDatadogFields specifies whether we should recompute DD span fields if the corresponding "datadog."
// namespaced span attributes are missing. If it is false (default), we will use the incoming "datadog." namespaced
// OTLP span attributes to construct the DD span, and if they are missing, we will recompute them from the other
// OTLP semantic convention attributes. If it is true, we will only populate a field if its associated "datadog."
// OTLP span attribute exists, otherwise we will leave it empty.
IgnoreMissingDatadogFields bool `mapstructure:"ignore_missing_datadog_fields"`
// SpanDerivedPrimaryTags is an optional list of attribute keys to attach to the trace metrics
// computed by the connector, so that those metrics can be broken down by the tag's value.
// Each key is resolved off the span first and, if absent there, off the span's resource; keys
// found in neither place are omitted. Unlike peer tags, these are not restricted by span kind.
// Each key must also be configured as a primary tag in your Datadog organization; keys that are
// not registered as primary tags are dropped by the intake and do not appear on the resulting
// span metrics. A high cardinality of values increases the metric volume the connector
// generates, so prefer keys with a small, bounded set of values.
SpanDerivedPrimaryTags []string `mapstructure:"span_derived_primary_tags"`
}
TracesConnectorConfig Traces configuration in DD connector
func (*TracesConnectorConfig) Validate ¶
func (c *TracesConnectorConfig) Validate() error
type TracesExporterConfig ¶
type TracesExporterConfig struct {
// TCPAddr.Endpoint is the host of the Datadog intake server to send traces to.
// If unset, the value is obtained from the Site.
confignet.TCPAddrConfig `mapstructure:",squash"`
// TracesConfig contains the common configuration for all traces.
TracesConfig `mapstructure:",squash"`
// TraceBuffer specifies the number of Datadog Agent TracerPayloads to buffer before dropping.
// The default value is 0, meaning the Datadog Agent TracerPayloads are unbuffered.
TraceBuffer int `mapstructure:"trace_buffer"`
// contains filtered or unexported fields
}
TracesExporterConfig Traces configuration in DD exporter
func (*TracesExporterConfig) GetFlushInterval ¶
func (c *TracesExporterConfig) GetFlushInterval() float64
GetFlushInterval returns the interval in seconds at which the writer flushes traces
func (*TracesExporterConfig) SetFlushInterval ¶
func (c *TracesExporterConfig) SetFlushInterval(interval float64)
SetFlushInterval sets the interval in seconds at which the writer flushes traces
func (*TracesExporterConfig) Validate ¶
func (c *TracesExporterConfig) Validate() error