Documentation
¶
Overview ¶
Package clientip resolves the identity of an HTTP client from transport data.
It owns the default resolution policy — scan the monitored IP headers left to right, prefer the first globally-routable address, fall back to the remote address — and is the only place that policy lives. Integrations that know a trustworthy address pass it across the instrumentation boundary instead.
Index ¶
- func AppendDefaultHeaders(headers []string) []string
- func CustomHeaderConfigured() bool
- func MonitoredHeaders() []string
- func ResetConfig()
- func Resolve(hdrs map[string][]string, hasCanonicalHeaders bool, remoteAddr string) (remoteIP, clientIP netip.Addr)
- func TagsFor(remoteAddr string, clientIP netip.Addr) map[string]string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendDefaultHeaders ¶
AppendDefaultHeaders appends the default IP headers in resolution order.
func CustomHeaderConfigured ¶
func CustomHeaderConfigured() bool
CustomHeaderConfigured reports whether DD_TRACE_CLIENT_IP_HEADER named the header client identity must be taken from.
An integration that determines identity from its own infrastructure has to defer to the default policy when this is true. Naming a header is an explicit statement by the operator about where identity lives — typically because something in front of them, a CDN say, is the only thing that knows the real client — and it outranks an address an integration inferred.
func MonitoredHeaders ¶
func MonitoredHeaders() []string
MonitoredHeaders returns the configured headers in resolution order. Callers must not modify the returned slice.
func ResetConfig ¶
func ResetConfig()
ResetConfig re-reads DD_TRACE_CLIENT_IP_HEADER. The configuration is read once at init; this exists so tests in the packages that consume the policy can exercise both branches, mirroring httptrace.ResetCfg.
func Resolve ¶
func Resolve(hdrs map[string][]string, hasCanonicalHeaders bool, remoteAddr string) (remoteIP, clientIP netip.Addr)
Resolve returns the remote IP and the client IP of a request, applying the default resolution policy over MonitoredHeaders.
An invalid returned address means no identity could be determined from the data given, and produces no span tag.
Types ¶
This section is empty.