clientip

package
v2.9.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 7 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendDefaultHeaders

func AppendDefaultHeaders(headers []string) []string

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.

func TagsFor

func TagsFor(remoteAddr string, clientIP netip.Addr) map[string]string

TagsFor returns the Datadog span tags `http.client_ip` containing the client IP and `network.client.ip` containing the parsed remote address. Each tag is present only if the corresponding address is valid; nil is returned when neither is.

Types

This section is empty.

Jump to

Keyboard shortcuts

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