config

package
v2.12.0-dev.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 27 Imported by: 0

README

internal/config

This package is the single source of truth for initializing, reading, and updating tracer configuration.

Migration guidelines

When migrating a configuration value from another package (e.g. ddtrace/tracer):

  • Define the field on Config: add a private field on internal/config.Config.
  • Initialize it in loadConfig(): read from the config provider, which iterates over the following sources, in order, returning the default if no valid value found: local declarative config file, OTEL env vars, env vars, managed declarative config file
  • Expose an accessor: add a getter (and a setter if the value is updated at runtime).
  • Report telemetry in setters: setters should call configtelemetry.Report(...) with the correct origin.
  • Add the cross-product gate: every setter must call c.checkProductConflict(...) as its first action after acquiring the lock (see below).
  • Update callers: replace reads/writes on local "config" structs with calls to the singleton (internal/config.Get()).
  • Delete old state: remove the migrated field from any legacy config structs once no longer referenced.
  • Update tests: tests should call the singleton setter/getter (or set env vars) rather than mutating legacy fields.

Sample migration PR: https://github.com/DataDog/dd-trace-go/pull/4214

Cross-product gate

Every Set* method accepts an optional trailing ...Product parameter. When a product (tracer, profiler, etc.) sets a field via its programmatic API, it passes its Product identity:

c.internalConfig.SetServiceName(name, internalconfig.OriginCode, internalconfig.ProductTracer)

The gate enforces first-in-wins: if a different product already claimed the field via programmatic API, the call is silently rejected and a warning is logged. This prevents conflicting overrides like tracer.WithService("A") + profiler.WithService("B").

Key rules:

  • Env vars, defaults, and RC always pass through — the gate only activates for OriginCode.
  • Tests and integrations omit the product — they call SetServiceName(name, origin) without a product, bypassing the gate entirely.
  • Same product can call a setter multiple times — repeated calls from the same product just update the value.

Hot paths & performance guidelines

Some configuration accessors may be called in hot paths (e.g., span start/finish, partial flush logic). If benchmarks regress, ensure getters are efficient and do not:

  • Copy whole maps/slices on every call: prefer single-key lookup helpers like ServiceMapping/HasFeature over returning a map copy.
  • Take multiple lock/unlock pairs to read related fields: prefer a combined getter under one RLock, like PartialFlushEnabled().
  • Rethink defer in per-span/tight-loop getters: avoid defer in getters that are executed extremely frequently.
Cache config reads before loops (especially retry loops)

If you’re reading a config value inside any loop, prefer caching it once into a local variable before the loop:

  • Why: avoids repeated RLock/RUnlock overhead per iteration and keeps loop bounds/logging consistent if the value ever becomes dynamically updatable.
  • Example: cache SendRetries() and RetryInterval() once per flush send, and use the cached values inside the loop.
sendRetries := cfg.SendRetries()
retryInterval := cfg.RetryInterval()
for attempt := 0; attempt <= sendRetries; attempt++ {
	// ...
	time.Sleep(retryInterval)
}
Snapshot many-field hot paths under one lock

When a hot path reads ~3+ Config fields, define a snapshot struct + method in snapshots.go and have the caller read from the local copy.

  • Why: at high concurrency the bottleneck isn't blocking — readers don't block each other — but cache-line contention on sync.RWMutex's reader counter. Folding N RLock pairs into 1 collapses N atomic ops on a shared cache line into 1.
  • Convention: one bespoke struct per caller (e.g, a calling function StartSpan gets a snapshot API called SpanStartSnapshot).
  • Prior art: SpanStartSnapshot for tracer.StartSpan (13 → 1 RLock acquisitions, ~60% speedup on BenchmarkStartSpanConcurrent-8).

Documentation

Index

Constants

View Source
const (
	OriginCode       = telemetry.OriginCode
	OriginCalculated = telemetry.OriginCalculated
	OriginDefault    = telemetry.OriginDefault
)

Re-exported origin constants for common configuration sources

View Source
const (
	// DefaultRateLimit specifies the default rate limit per second for traces.
	// TODO: Maybe delete this. We will have defaults in supported_configuration.json anyway.
	DefaultRateLimit = 100.0

	// DefaultMaxTagsHeaderLen is the default value for DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH.
	DefaultMaxTagsHeaderLen = 512

	// MaxPropagatedTagsLength is the upper bound on DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH.
	MaxPropagatedTagsLength = 512
	// TraceMaxSize is the maximum number of spans we keep in memory for a
	// single trace. This is to avoid memory leaks. If more spans than this
	// are added to a trace, then the trace is dropped and the spans are
	// discarded. Adding additional spans after a trace is dropped does
	// nothing.
	TraceMaxSize = int(1e5)

	// Datadog trace protocol versions (agent wire format).
	TraceProtocolV04              = 0.4 // default
	TraceProtocolV1               = 1.0
	TraceProtocolVersionStringV04 = "0.4"
	TraceProtocolVersionStringV1  = "1.0"

	// Agent URL schemes supported by DD_TRACE_AGENT_URL.
	URLSchemeUnix  = "unix"
	URLSchemeHTTP  = "http"
	URLSchemeHTTPS = "https"

	DefaultStatsdPort = "8125"

	// Trace API paths appended to the agent URL for each protocol.
	TracesPathV04 = "/v0.4/traces"
	TracesPathV1  = "/v1.0/traces"

	// OTLPContentTypeHeader is the Content-Type header value required for HTTP protobuf payloads.
	OTLPContentTypeHeader = "application/x-protobuf"

	// OTLPMetricsFlushInterval is the default cadence for flushing and exporting span metrics.
	OTLPMetricsFlushInterval = 10 * time.Second
)

Variables

View Source
var DefaultSocketDSDPath = "/var/run/datadog/dsd.socket"

DefaultSocketDSDPath is the UDS socket path probed during DogStatsD auto-discovery. Exported as a var only for test overrides.

Functions

func RecordProductStart

func RecordProductStart(product Product)

RecordProductStart reports telemetry when the env has changed since the last recorded call by any product. Call near the top of a product's Start function.

Known limitation: it can't distinguish a customer-driven env change from dd-trace-go's own bootstrap mutations, so diffs are an upper bound on real cross-product blast radius.

func SetUseFreshConfig

func SetUseFreshConfig(use bool)

func TraceProtocolVersionString added in v2.10.0

func TraceProtocolVersionString(v float64) string

TraceProtocolVersionString is the inverse of resolveTraceProtocol: it renders a protocol float64 back into the wire-version string reported to config telemetry, so DD_TRACE_AGENT_PROTOCOL_VERSION is always reported with a consistent type regardless of which source set it.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config represents global configuration properties. Config instances should be obtained via Get() which always returns a non-nil value. Methods on Config assume a non-nil receiver and will panic if called on nil. Hot paths that read many fields within a single function should use a snapshot (see snapshots.go) to avoid per-field RLock contention on the reader counter.

func CreateNew added in v2.6.0

func CreateNew() *Config

CreateNew returns a new global configuration instance. This function should be used when we need to create a new configuration instance. It build a new configuration instance and override the existing one loosing any programmatic configuration that would have been applied to the existing instance.

It shouldn't be used to get the global configuration instance to manipulate it but should be used when there is a need to reset the global configuration instance.

This is useful when we need to create a new configuration instance when a new product is initialized. Each product should have its own configuration instance and apply its own programmatic configuration to it.

If a customer starts multiple tracer with different programmatic configuration only the latest one will be used and available globally.

func Get

func Get() *Config

Get returns the global configuration singleton. This function is thread-safe and can be called from multiple goroutines concurrently. The configuration is lazily initialized on first access using sync.Once, ensuring loadConfig() is called exactly once even under concurrent access.

func (*Config) APIKey added in v2.9.0

func (c *Config) APIKey() string

APIKey returns the configured Datadog API key (DD_API_KEY).

func (*Config) AgentTimeout added in v2.10.0

func (c *Config) AgentTimeout() time.Duration

AgentTimeout returns the HTTP client timeout used for requests to the Datadog Agent.

func (*Config) AgentURL added in v2.8.0

func (c *Config) AgentURL() *url.URL

AgentURL returns the URL to use for HTTP requests to the agent. For unix-scheme URLs this rewrites to the http://UDS_... form; otherwise it returns a copy of the configured URL.

func (*Config) AppKey

func (c *Config) AppKey() string

func (*Config) ApplyAgentReportedStatsdPort added in v2.10.0

func (c *Config) ApplyAgentReportedStatsdPort(port int)

ApplyAgentReportedStatsdPort applies a port from the agent /info response. For user-configured addresses use SetDogstatsdAddr instead. No-op when the user already provided an explicit address or the current address is a unix socket.

func (*Config) CIVisibilityAgentless added in v2.10.0

func (c *Config) CIVisibilityAgentless() bool

CIVisibilityAgentless returns the raw DD_CIVISIBILITY_AGENTLESS_ENABLED value. Only valid inside a CIVisibilityEnabled() block; prefer CIVisibilityAgentlessActive() elsewhere.

func (*Config) CIVisibilityAgentlessActive added in v2.10.0

func (c *Config) CIVisibilityAgentlessActive() bool

CIVisibilityAgentlessActive reports whether agentless CI Visibility mode is in effect. Agentless is only meaningful when CI Visibility itself is enabled.

func (*Config) CIVisibilityAgentlessURL

func (c *Config) CIVisibilityAgentlessURL() string

func (*Config) CIVisibilityEnabled added in v2.6.0

func (c *Config) CIVisibilityEnabled() bool

func (*Config) CIVisibilityNoopTracer added in v2.10.0

func (c *Config) CIVisibilityNoopTracer() bool

func (*Config) DataStreamsMonitoringEnabled added in v2.6.0

func (c *Config) DataStreamsMonitoringEnabled() bool

func (*Config) Debug

func (c *Config) Debug() bool

func (*Config) DebugAbandonedSpans added in v2.6.0

func (c *Config) DebugAbandonedSpans() bool

func (*Config) DebugStack added in v2.6.0

func (c *Config) DebugStack() bool

func (*Config) DogstatsdAddr added in v2.10.0

func (c *Config) DogstatsdAddr() string

func (*Config) DynamicInstrumentationEnabled added in v2.10.0

func (c *Config) DynamicInstrumentationEnabled() bool

func (*Config) DynamicInstrumentationEnabledConfig added in v2.10.0

func (c *Config) DynamicInstrumentationEnabledConfig() *DynamicConfig[bool]

DynamicInstrumentationEnabledConfig returns the DynamicConfig for the dynamic instrumentation enabled flag. Products use this to apply RC updates and inspect the baseline for local-explicit gating.

func (*Config) Env added in v2.6.0

func (c *Config) Env() string

func (*Config) ExperimentalFeaturesEnabled added in v2.10.0

func (c *Config) ExperimentalFeaturesEnabled() bool

func (*Config) ExperimentalFlaggingProviderEnabled

func (c *Config) ExperimentalFlaggingProviderEnabled() (enabled, explicit bool)

ExperimentalFlaggingProviderEnabled returns DD_EXPERIMENTAL_FLAGGING_PROVIDER_ENABLED and whether it was explicitly set, distinguishing an opted-in legacy customer from one who never set it.

func (*Config) FeatureFlags added in v2.6.0

func (c *Config) FeatureFlags() map[string]struct{}

func (*Config) FeatureFlagsAgentlessBaseURL

func (c *Config) FeatureFlagsAgentlessBaseURL() string

FeatureFlagsAgentlessBaseURL returns DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_BASE_URL. SENSITIVE: may embed credentials; callers must never log this value.

func (*Config) FeatureFlagsAgentlessPollInterval

func (c *Config) FeatureFlagsAgentlessPollInterval() time.Duration

FeatureFlagsAgentlessPollInterval returns DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_POLL_INTERVAL_SECONDS, or the default when the configured value was out of range. The value is always positive, so callers need not guard a ticker against it.

func (*Config) FeatureFlagsAgentlessRequestTimeout

func (c *Config) FeatureFlagsAgentlessRequestTimeout() time.Duration

FeatureFlagsAgentlessRequestTimeout returns DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_REQUEST_TIMEOUT_SECONDS, or the default when the configured value was out of range. The value is always positive, so it is safe to hand to http.Client, which treats a non-positive Timeout as no timeout.

func (*Config) FeatureFlagsConfigurationSource

func (c *Config) FeatureFlagsConfigurationSource() (source string, explicit bool)

FeatureFlagsConfigurationSource returns DD_FEATURE_FLAGS_CONFIGURATION_SOURCE and whether it was explicitly configured, regardless of whether the value itself is blank.

func (*Config) FeatureFlagsEnabled

func (c *Config) FeatureFlagsEnabled() (enabled, explicit bool)

FeatureFlagsEnabled returns DD_FEATURE_FLAGS_ENABLED and whether it was explicitly set. enabled is only meaningful when explicit is true.

func (*Config) FlaggingProviderInitTimeout

func (c *Config) FlaggingProviderInitTimeout() time.Duration

FlaggingProviderInitTimeout returns DD_EXPERIMENTAL_FLAGGING_PROVIDER_INITIALIZATION_TIMEOUT_MS.

func (*Config) GlobalSampleRate added in v2.6.0

func (c *Config) GlobalSampleRate() float64

func (*Config) GlobalSampleRateConfig added in v2.8.0

func (c *Config) GlobalSampleRateConfig() *DynamicConfig[float64]

GlobalSampleRateConfig returns the DynamicConfig for the global sample rate. Products use this to apply RC updates and read telemetry snapshots.

func (*Config) GlobalTags added in v2.10.0

func (c *Config) GlobalTags() map[string]any

GlobalTags returns a copy of the global tags applied to all spans. If no global tags are set, returns nil.

func (*Config) GlobalTagsConfig added in v2.10.0

func (c *Config) GlobalTagsConfig() *DynamicConfig[map[string]any]

GlobalTagsConfig returns the DynamicConfig for global tags, used by the tracer's Remote Config handler to apply tracing_tags updates and resets.

func (*Config) HasFeature added in v2.6.0

func (c *Config) HasFeature(feat string) bool

HasFeature performs a single feature flag lookup without copying the underlying map. This is better than FeatureFlags() for hot paths (e.g., span creation) to avoid per-call allocations.

func (*Config) HeaderAsTags added in v2.10.0

func (c *Config) HeaderAsTags() []string

func (*Config) HeaderAsTagsConfig added in v2.10.0

func (c *Config) HeaderAsTagsConfig() *DynamicConfig[[]string]

HeaderAsTagsConfig returns the DynamicConfig for header-as-tags. Used by the tracer's RC handler to invoke HandleRC on remote-config updates.

func (*Config) Hostname added in v2.6.0

func (c *Config) Hostname() string

func (*Config) HostnameLookupError added in v2.6.0

func (c *Config) HostnameLookupError() error

func (*Config) InternalMetricsEnabled added in v2.10.0

func (c *Config) InternalMetricsEnabled() bool

func (*Config) IsLambdaFunction added in v2.6.0

func (c *Config) IsLambdaFunction() bool

func (*Config) LLMObsAgentlessEnabled

func (c *Config) LLMObsAgentlessEnabled() *bool

LLMObsAgentlessEnabled returns DD_LLMOBS_AGENTLESS_ENABLED. It returns nil when unset, allowing callers to distinguish an explicit false from unset.

func (*Config) LLMObsEnabled

func (c *Config) LLMObsEnabled() bool

LLMObsEnabled returns DD_LLMOBS_ENABLED.

func (*Config) LLMObsMLApp

func (c *Config) LLMObsMLApp() string

LLMObsMLApp returns DD_LLMOBS_ML_APP.

func (*Config) LLMObsProjectName

func (c *Config) LLMObsProjectName() string

LLMObsProjectName returns DD_LLMOBS_PROJECT_NAME.

func (*Config) LogDirectory added in v2.6.0

func (c *Config) LogDirectory() string

func (*Config) LogStartup added in v2.6.0

func (c *Config) LogStartup() bool

func (*Config) LogToStdout added in v2.6.0

func (c *Config) LogToStdout() bool

func (*Config) LogsOTelEnabled added in v2.7.0

func (c *Config) LogsOTelEnabled() bool

func (*Config) MaxTagsHeaderLen added in v2.9.0

func (c *Config) MaxTagsHeaderLen() int

MaxTagsHeaderLen returns the configured cap on the x-datadog-tags header value (DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH). A non-positive value disables tags propagation.

func (*Config) OTLPEndpoint

func (c *Config) OTLPEndpoint() string

func (*Config) OTLPExportMetricsMode added in v2.10.0

func (c *Config) OTLPExportMetricsMode() bool

func (*Config) OTLPExportMode added in v2.8.0

func (c *Config) OTLPExportMode() bool

func (*Config) OTLPHeaders added in v2.8.0

func (c *Config) OTLPHeaders() map[string]string

OTLPHeaders returns a copy of the OTLP headers map. If no headers are set, returns nil. Safe to return the full map because it is not called in hot paths.

func (*Config) OTLPMetricsFlushInterval

func (c *Config) OTLPMetricsFlushInterval() time.Duration

func (*Config) OTLPMetricsHeaders

func (c *Config) OTLPMetricsHeaders() map[string]string

OTLPMetricsHeaders returns a copy of the resolved OTLP metrics headers map.

func (*Config) OTLPMetricsProtocol

func (c *Config) OTLPMetricsProtocol() string

OTLPMetricsProtocol returns the OTLP export protocol for metrics ("http/json" or "http/protobuf").

func (*Config) OTLPMetricsURL

func (c *Config) OTLPMetricsURL() string

func (*Config) OTLPSpanMetricsEnabled added in v2.10.0

func (c *Config) OTLPSpanMetricsEnabled() bool

OTLPSpanMetricsEnabled reports whether span metrics export is active; auto-enables when OTEL_TRACES_EXPORTER=otlp and DD_METRICS_OTEL_ENABLED=true.

func (*Config) OTLPTraceURL added in v2.8.0

func (c *Config) OTLPTraceURL() string

func (*Config) OTelSemanticsEnabled

func (c *Config) OTelSemanticsEnabled() bool

func (*Config) PartialFlushEnabled added in v2.6.0

func (c *Config) PartialFlushEnabled() (enabled bool, minSpans int)

PartialFlushEnabled returns the partial flushing configuration under a single read lock.

func (*Config) PeerServiceDefaultsEnabled added in v2.8.0

func (c *Config) PeerServiceDefaultsEnabled() bool

func (*Config) PeerServiceMapping added in v2.8.0

func (c *Config) PeerServiceMapping(from string) (to string, ok bool)

PeerServiceMapping performs a single mapping lookup without copying the underlying map. This is better than PeerServiceMappings() for hot paths to avoid per-call allocations.

func (*Config) PeerServiceMappings added in v2.8.0

func (c *Config) PeerServiceMappings() map[string]string

PeerServiceMappings returns a copy of the peer service mappings map. If no mappings are set, returns nil. Not intended for hot paths — use PeerServiceMapping for single-key lookups to avoid per-call allocations.

func (*Config) ProfilerEndpoints added in v2.6.0

func (c *Config) ProfilerEndpoints() bool

func (*Config) ProfilerHotspotsEnabled added in v2.6.0

func (c *Config) ProfilerHotspotsEnabled() bool

func (*Config) PropagationBehaviorExtract

func (c *Config) PropagationBehaviorExtract() string

func (*Config) PropagationExtractFirst

func (c *Config) PropagationExtractFirst() bool

func (*Config) PropagationStyleExtract

func (c *Config) PropagationStyleExtract() string

func (*Config) PropagationStyleInject

func (c *Config) PropagationStyleInject() string

func (*Config) RawAgentURL added in v2.8.0

func (c *Config) RawAgentURL() *url.URL

RawAgentURL returns a copy of the configured trace agent URL before any transport-level rewriting (e.g. unix → http://UDS_...). Use AgentURL() for the URL suitable for HTTP requests.

func (*Config) ReportEffectiveStatsComputation added in v2.10.0

func (c *Config) ReportEffectiveStatsComputation(enabled bool) bool

ReportEffectiveStatsComputation records whether client-side stats are actually being computed — which can differ from the configured DD_TRACE_STATS_COMPUTATION_ENABLED when an agent-capability workaround forces them on — for DD_TRACE_STATS_COMPUTATION_ENABLED config telemetry. Like ReportEffectiveTraceProtocol it reports only on change, so periodic re-evaluation cannot inflate config-telemetry seqIDs. It does NOT modify the value returned by StatsComputationEnabled. Returns true if this call changed the recorded value.

func (*Config) ReportEffectiveTraceProtocol added in v2.10.0

func (c *Config) ReportEffectiveTraceProtocol(v float64) bool

ReportEffectiveTraceProtocol records the wire protocol version actually in use (the requested protocol, downgraded when the agent lacks support) for DD_TRACE_AGENT_PROTOCOL_VERSION config telemetry. It reports only when the value changes from the last report, so periodic re-evaluation (e.g. on an agent-info poll) cannot inflate config-telemetry seqIDs. It does NOT modify the value returned by RequestedTraceProtocol. Returns true if this call changed the recorded value.

func (*Config) ReportHostname added in v2.6.0

func (c *Config) ReportHostname() bool

func (*Config) RequestedTraceProtocol added in v2.10.0

func (c *Config) RequestedTraceProtocol() float64

RequestedTraceProtocol returns the Datadog trace protocol version to use for /vX/traces (TraceProtocolV04 or TraceProtocolV1). It reflects what has been asked for, by the user or by a derived override; it carries no information about whether the trace-agent actually supports that protocol. Callers that need the protocol in effect on the wire must combine this with agent capability. It is independent of stats computation: both native Client-Side Stats and OTLP span metrics are signalled out-of-band (the Datadog-Client-Computed-Stats header and the separate /v0.6/stats endpoint) and are handled identically by the Agent on either protocol.

func (*Config) RetryInterval added in v2.6.0

func (c *Config) RetryInterval() time.Duration

func (*Config) RuntimeMetricsEnabled added in v2.6.0

func (c *Config) RuntimeMetricsEnabled() bool

func (*Config) RuntimeMetricsOtelEnabled added in v2.10.0

func (c *Config) RuntimeMetricsOtelEnabled() bool

func (*Config) RuntimeMetricsV2Enabled added in v2.6.0

func (c *Config) RuntimeMetricsV2Enabled() bool

func (*Config) SendRetries added in v2.10.0

func (c *Config) SendRetries() int

SendRetries returns the configured retry count for payload sends.

func (*Config) ServiceMapping added in v2.6.0

func (c *Config) ServiceMapping(from string) (to string, ok bool)

ServiceMapping performs a single mapping lookup without copying the underlying map. This is better than ServiceMappings() for hot paths (e.g., span creation) to avoid per-call allocations.

func (*Config) ServiceMappings added in v2.6.0

func (c *Config) ServiceMappings() map[string]string

ServiceMappings returns a copy of the service mappings map. If no service mappings are set, returns nil.

func (*Config) ServiceName added in v2.6.0

func (c *Config) ServiceName() string

func (*Config) SetAgentTimeout added in v2.10.0

func (c *Config) SetAgentTimeout(timeout time.Duration, origin telemetry.Origin, product ...Product)

SetAgentTimeout sets the HTTP client timeout used for requests to the Datadog Agent.

func (*Config) SetAgentURL added in v2.8.0

func (c *Config) SetAgentURL(u *url.URL, origin telemetry.Origin, product ...Product)

func (*Config) SetCIVisibilityEnabled added in v2.6.0

func (c *Config) SetCIVisibilityEnabled(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetDataStreamsMonitoringEnabled added in v2.6.0

func (c *Config) SetDataStreamsMonitoringEnabled(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetDebug

func (c *Config) SetDebug(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetDebugAbandonedSpans added in v2.6.0

func (c *Config) SetDebugAbandonedSpans(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetDebugStack added in v2.6.0

func (c *Config) SetDebugStack(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetDogstatsdAddr added in v2.10.0

func (c *Config) SetDogstatsdAddr(addr string, origin telemetry.Origin, product ...Product)

SetDogstatsdAddr records a user-configured DogStatsD address and marks it explicit so agent-reported ports cannot overwrite it. Call this only from user-facing paths (options, env vars). For agent-reported updates use ApplyAgentReportedStatsdPort.

func (*Config) SetDynamicInstrumentationEnabled added in v2.10.0

func (c *Config) SetDynamicInstrumentationEnabled(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetEnv added in v2.6.0

func (c *Config) SetEnv(env string, origin telemetry.Origin, product ...Product)

func (*Config) SetFeatureFlags added in v2.6.0

func (c *Config) SetFeatureFlags(features []string, origin telemetry.Origin, product ...Product)

SetFeatureFlags adds to the feature flag set. No cross-product gate because this is additive, not a replacement.

func (*Config) SetGlobalSampleRate added in v2.6.0

func (c *Config) SetGlobalSampleRate(rate float64, origin telemetry.Origin, product ...Product)

func (*Config) SetGlobalTag added in v2.10.0

func (c *Config) SetGlobalTag(key string, value any, origin telemetry.Origin, product ...Product)

SetGlobalTag adds or overwrites a single global tag. Like SetServiceMapping it is additive, so it carries no cross-product gate. The read-modify-write of the startup baseline is guarded by c.mu.

func (*Config) SetHeaderAsTags added in v2.10.0

func (c *Config) SetHeaderAsTags(headerAsTags []string, origin telemetry.Origin, product ...Product)

func (*Config) SetHostname added in v2.6.0

func (c *Config) SetHostname(hostname string, origin telemetry.Origin, product ...Product)

func (*Config) SetIsLambdaFunction added in v2.6.0

func (c *Config) SetIsLambdaFunction(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetLLMObsAgentlessEnabled

func (c *Config) SetLLMObsAgentlessEnabled(v *bool, origin telemetry.Origin, product ...Product)

SetLLMObsAgentlessEnabled sets DD_LLMOBS_AGENTLESS_ENABLED. A nil value indicates the setting is unset (tri-state).

func (*Config) SetLLMObsEnabled

func (c *Config) SetLLMObsEnabled(enabled bool, origin telemetry.Origin, product ...Product)

SetLLMObsEnabled sets DD_LLMOBS_ENABLED.

func (*Config) SetLLMObsMLApp

func (c *Config) SetLLMObsMLApp(mlApp string, origin telemetry.Origin, product ...Product)

SetLLMObsMLApp sets DD_LLMOBS_ML_APP.

func (*Config) SetLLMObsProjectName

func (c *Config) SetLLMObsProjectName(name string, origin telemetry.Origin, product ...Product)

SetLLMObsProjectName sets DD_LLMOBS_PROJECT_NAME.

func (*Config) SetLogDirectory added in v2.6.0

func (c *Config) SetLogDirectory(directory string, origin telemetry.Origin, product ...Product)

func (*Config) SetLogStartup added in v2.6.0

func (c *Config) SetLogStartup(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetLogToStdout added in v2.6.0

func (c *Config) SetLogToStdout(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetLogsOTelEnabled added in v2.7.0

func (c *Config) SetLogsOTelEnabled(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetOTLPExportMetricsMode added in v2.10.0

func (c *Config) SetOTLPExportMetricsMode(v bool, origin telemetry.Origin, product ...Product)

func (*Config) SetOTLPExportMode added in v2.8.0

func (c *Config) SetOTLPExportMode(v bool, origin telemetry.Origin, product ...Product)

func (*Config) SetOTLPSpanMetricsEnabled added in v2.10.0

func (c *Config) SetOTLPSpanMetricsEnabled(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetOTelSemanticsEnabled

func (c *Config) SetOTelSemanticsEnabled(enabled bool, origin telemetry.Origin, product ...Product)

SetOTelSemanticsEnabled sets whether OTLP-exported spans should match the pure OpenTelemetry SDK, and reports the value to configuration telemetry.

func (*Config) SetPartialFlushEnabled added in v2.6.0

func (c *Config) SetPartialFlushEnabled(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetPartialFlushMinSpans added in v2.6.0

func (c *Config) SetPartialFlushMinSpans(minSpans int, origin telemetry.Origin, product ...Product)

func (*Config) SetPeerServiceDefaultsEnabled added in v2.8.0

func (c *Config) SetPeerServiceDefaultsEnabled(enabled bool, origin telemetry.Origin)

func (*Config) SetPeerServiceMapping added in v2.8.0

func (c *Config) SetPeerServiceMapping(from, to string, origin telemetry.Origin)

func (*Config) SetPeerServiceMappings added in v2.8.0

func (c *Config) SetPeerServiceMappings(mappings map[string]string, origin telemetry.Origin)

func (*Config) SetProfilerEndpoints added in v2.6.0

func (c *Config) SetProfilerEndpoints(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetProfilerHotspotsEnabled added in v2.6.0

func (c *Config) SetProfilerHotspotsEnabled(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetRetryInterval added in v2.6.0

func (c *Config) SetRetryInterval(interval time.Duration, origin telemetry.Origin, product ...Product)

func (*Config) SetRuntimeMetricsEnabled added in v2.6.0

func (c *Config) SetRuntimeMetricsEnabled(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetRuntimeMetricsOtelEnabled added in v2.10.0

func (c *Config) SetRuntimeMetricsOtelEnabled(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetRuntimeMetricsV2Enabled added in v2.6.0

func (c *Config) SetRuntimeMetricsV2Enabled(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetSendRetries added in v2.10.0

func (c *Config) SetSendRetries(retries int, origin telemetry.Origin, product ...Product)

SetSendRetries sets the retry count for payload sends.

func (*Config) SetServiceMapping added in v2.6.0

func (c *Config) SetServiceMapping(from, to string, origin telemetry.Origin, product ...Product)

SetServiceMapping adds a single service mapping entry. No cross-product gate because this is additive, not a replacement.

func (*Config) SetServiceName added in v2.6.0

func (c *Config) SetServiceName(name string, origin telemetry.Origin, product ...Product)

func (*Config) SetSite

func (c *Config) SetSite(site string, origin telemetry.Origin, product ...Product)

func (*Config) SetSpanPoolEnabled added in v2.10.0

func (c *Config) SetSpanPoolEnabled(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetSpanSamplingRules

func (c *Config) SetSpanSamplingRules(rules []samplingrules.SamplingRule, origin telemetry.Origin, product ...Product)

func (*Config) SetSpanTimeout added in v2.6.0

func (c *Config) SetSpanTimeout(timeout time.Duration, origin telemetry.Origin, product ...Product)

func (*Config) SetStatsAdditionalTags added in v2.10.0

func (c *Config) SetStatsAdditionalTags(tags []string, origin telemetry.Origin, product ...Product)

func (*Config) SetStatsComputationEnabled added in v2.6.0

func (c *Config) SetStatsComputationEnabled(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetStatsHTTPEndpointCardinalityLimit added in v2.10.0

func (c *Config) SetStatsHTTPEndpointCardinalityLimit(limit int, origin telemetry.Origin, product ...Product)

func (*Config) SetStatsOriginCardinalityLimit added in v2.10.0

func (c *Config) SetStatsOriginCardinalityLimit(limit int, origin telemetry.Origin, product ...Product)

func (*Config) SetStatsPeerTagsCardinalityLimit added in v2.10.0

func (c *Config) SetStatsPeerTagsCardinalityLimit(limit int, origin telemetry.Origin, product ...Product)

func (*Config) SetStatsResourceCardinalityLimit added in v2.10.0

func (c *Config) SetStatsResourceCardinalityLimit(limit int, origin telemetry.Origin, product ...Product)

func (*Config) SetStatsWholeKeyCardinalityLimit added in v2.10.0

func (c *Config) SetStatsWholeKeyCardinalityLimit(limit int, origin telemetry.Origin, product ...Product)

func (*Config) SetTraceProtocol added in v2.8.0

func (c *Config) SetTraceProtocol(v float64, origin telemetry.Origin, product ...Product)

SetTraceProtocol sets the requested trace protocol version. It never expresses an agent-capability downgrade: callers that need to report the wire protocol actually in use should call ReportEffectiveTraceProtocol instead, which does not mutate the requested value.

func (*Config) SetTraceRateLimitPerSecond added in v2.6.0

func (c *Config) SetTraceRateLimitPerSecond(rate float64, origin telemetry.Origin, product ...Product)

func (*Config) SetTraceSamplingRules

func (c *Config) SetTraceSamplingRules(rules []samplingrules.SamplingRule, origin telemetry.Origin, product ...Product)

func (*Config) SetTracingEnabled

func (c *Config) SetTracingEnabled(enabled bool, origin telemetry.Origin, product ...Product)

SetTracingEnabled records a user-configured tracing-enabled value. Call this only from user-facing paths (options, env vars). For agent/RC updates use TracingEnabledConfig().HandleRC(...).

func (*Config) SetUniversalVersion added in v2.10.0

func (c *Config) SetUniversalVersion(enabled bool, origin telemetry.Origin, product ...Product)

func (*Config) SetVersion added in v2.6.0

func (c *Config) SetVersion(version string, origin telemetry.Origin, product ...Product)

func (*Config) Site

func (c *Config) Site() string

func (*Config) SpanAttributeSchemaVersion added in v2.9.0

func (c *Config) SpanAttributeSchemaVersion() int

SpanAttributeSchemaVersion returns the configured DD_TRACE_SPAN_ATTRIBUTE_SCHEMA version. Read on the span-creation hot path; avoids defer to minimise lock cost.

func (*Config) SpanPoolEnabled added in v2.10.0

func (c *Config) SpanPoolEnabled() bool

func (*Config) SpanSamplingRules

func (c *Config) SpanSamplingRules() []samplingrules.SamplingRule

func (*Config) SpanStartSnapshot added in v2.9.0

func (c *Config) SpanStartSnapshot() SpanStartSnapshot

SpanStartSnapshot returns a snapshot of the config fields read by tracer.StartSpan. Service mappings are not included because the lookup key (the resolved span service) isn't known until after this snapshot is read.

func (*Config) SpanTimeout added in v2.6.0

func (c *Config) SpanTimeout() time.Duration

func (*Config) StatsAdditionalTags added in v2.10.0

func (c *Config) StatsAdditionalTags() []string

func (*Config) StatsAdditionalTagsCardinalityLimit added in v2.10.0

func (c *Config) StatsAdditionalTagsCardinalityLimit() int

func (*Config) StatsComputationEnabled added in v2.6.0

func (c *Config) StatsComputationEnabled() bool

func (*Config) StatsHTTPEndpointCardinalityLimit added in v2.10.0

func (c *Config) StatsHTTPEndpointCardinalityLimit() int

func (*Config) StatsOriginCardinalityLimit added in v2.10.0

func (c *Config) StatsOriginCardinalityLimit() int

func (*Config) StatsPeerTagsCardinalityLimit added in v2.10.0

func (c *Config) StatsPeerTagsCardinalityLimit() int

func (*Config) StatsResourceCardinalityLimit added in v2.10.0

func (c *Config) StatsResourceCardinalityLimit() int

func (*Config) StatsWholeKeyCardinalityLimit added in v2.10.0

func (c *Config) StatsWholeKeyCardinalityLimit() int

func (*Config) TraceAnalyticsEnabled added in v2.10.0

func (c *Config) TraceAnalyticsEnabled() bool

func (*Config) TraceID128BitEnabled added in v2.8.0

func (c *Config) TraceID128BitEnabled() bool

func (*Config) TraceRateLimitPerSecond added in v2.6.0

func (c *Config) TraceRateLimitPerSecond() float64

func (*Config) TraceSamplingRules

func (c *Config) TraceSamplingRules() []samplingrules.SamplingRule

func (*Config) TraceSamplingRulesConfig

func (c *Config) TraceSamplingRulesConfig() *DynamicConfig[[]samplingrules.SamplingRule]

TraceSamplingRulesConfig returns the DynamicConfig for trace sampling rules. Used by the tracer's RC handler to apply remote-config updates.

func (*Config) TracingEnabled

func (c *Config) TracingEnabled() bool

func (*Config) TracingEnabledConfig

func (c *Config) TracingEnabledConfig() *DynamicConfig[bool]

TracingEnabledConfig returns the DynamicConfig for the tracing-enabled flag. Use this only for RC updates (HandleRC). For user-configured changes use SetTracingEnabled.

func (*Config) UniversalVersion added in v2.10.0

func (c *Config) UniversalVersion() bool

func (*Config) Version added in v2.6.0

func (c *Config) Version() string

type DynamicConfig added in v2.8.0

type DynamicConfig[T any] struct {
	// contains filtered or unexported fields
}

DynamicConfig is a thread-safe, RC-aware value store for a single configuration field. It tracks both the current value and the startup baseline (for RC reset). Consumers read via Get().

func (*DynamicConfig[T]) Baseline added in v2.10.0

func (dc *DynamicConfig[T]) Baseline() (T, telemetry.Origin)

Baseline returns the startup value and its origin atomically.

func (*DynamicConfig[T]) Get added in v2.8.0

func (dc *DynamicConfig[T]) Get() T

Get returns the current value.

func (*DynamicConfig[T]) HandleRC added in v2.8.0

func (dc *DynamicConfig[T]) HandleRC(val *T) bool

HandleRC processes a remote config update. If val is non-nil, the value is updated; if nil, the field is reset to its startup value. Reports the new value to telemetry when changed and invokes the apply callback (if registered) outside the lock. Returns true if the value was changed.

type Origin added in v2.6.0

type Origin = telemetry.Origin

Origin represents where a configuration value came from. Re-exported so callers don't need to import internal/telemetry.

type Product added in v2.8.0

type Product string

Product identifies which product is setting a config value via programmatic API.

const (
	ProductTracer   Product = "tracer"
	ProductProfiler Product = "profiler"
	ProductAppsec   Product = "appsec"
	ProductLLMObs   Product = "llmobs"
)

type SpanStartSnapshot added in v2.9.0

type SpanStartSnapshot struct {
	ServiceName             string
	Env                     string
	Version                 string
	UniversalVersion        bool
	Hostname                string
	ReportHostname          bool
	DebugStack              bool
	DebugAbandonedSpans     bool
	ProfilerHotspotsEnabled bool
	ProfilerEndpoints       bool
	SpanPoolEnabled         bool
	// The map is the live internal map, shared with the config, not a copy.
	// Callers must not mutate it; use Config.GlobalTags() to get a safe copy.
	GlobalTags map[string]any
}

Directories

Path Synopsis
Package configtelemetry provides the telemetry reporting functions for configuration values.
Package configtelemetry provides the telemetry reporting functions for configuration values.
Package provider resolves configuration values from multiple sources in priority order and reports telemetry for each value found.
Package provider resolves configuration values from multiple sources in priority order and reports telemetry for each value found.

Jump to

Keyboard shortcuts

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