Module: Datadog::Tracing::ClientIp
- Defined in:
- lib/datadog/tracing/client_ip.rb
Overview
Common functions for supporting the ‘http.client_ip` span attribute.
Class Method Summary collapse
- .extract_client_ip(headers, remote_ip) ⇒ Object
-
.set_client_ip_tag(span, headers: nil, remote_ip: nil) ⇒ Object
Sets the ‘http.client_ip` tag on the given span.
-
.set_client_ip_tag!(span, headers: nil, remote_ip: nil) ⇒ Object
Forcefully sets the ‘http.client_ip` tag on the given span.
Class Method Details
.extract_client_ip(headers, remote_ip) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/datadog/tracing/client_ip.rb', line 40 def extract_client_ip(headers, remote_ip) if headers && configuration.header_name return Datadog::Core::Utils::Network.stripped_ip_from_request_headers( headers, ip_headers_to_check: Array(configuration.header_name) ) end ip_from_headers = Datadog::Core::Utils::Network.stripped_ip_from_request_headers(headers) if headers ip_from_headers || Datadog::Core::Utils::Network.stripped_ip(remote_ip) end |
.set_client_ip_tag(span, headers: nil, remote_ip: nil) ⇒ Object
Sets the ‘http.client_ip` tag on the given span.
This function respects the user’s settings: if they disable the client IP tagging,
or provide a different IP header name.
21 22 23 24 25 |
# File 'lib/datadog/tracing/client_ip.rb', line 21 def set_client_ip_tag(span, headers: nil, remote_ip: nil) return unless configuration.enabled set_client_ip_tag!(span, headers: headers, remote_ip: remote_ip) end |
.set_client_ip_tag!(span, headers: nil, remote_ip: nil) ⇒ Object
Forcefully sets the ‘http.client_ip` tag on the given span.
This function ignores the user’s ‘enabled` setting.
34 35 36 37 38 |
# File 'lib/datadog/tracing/client_ip.rb', line 34 def set_client_ip_tag!(span, headers: nil, remote_ip: nil) ip = extract_client_ip(headers, remote_ip) span.set_tag(Tracing::Metadata::Ext::HTTP::TAG_CLIENT_IP, ip) if ip end |