Module: Labkit::Fields

Defined in:
lib/labkit/fields.rb

Defined Under Namespace

Modules: Deprecated

Constant Summary collapse

CORRELATION_ID =

Unique identifier for correlating requests across services. Should be present in all log line emissions.

"correlation_id"
GL_USER_ID =

GitLab user numeric ID.

"gl_user_id"
GL_USER_NAME =

GitLab username.

"gl_user_name"
DUO_WORKFLOW_DEFINITION =

Duo Workflow definition identifier (e.g. “analytics_agent/v1”). Identifies which Duo Workflow agent originated a request, enabling per-agent filtering in Kibana and Grafana.

"duo_workflow_definition"
ERROR_TYPE =

Error type or classification (e.g. “NoMethodError”, “ValidationError”).

"error_type"
ERROR_MESSAGE =

Detailed error message (e.g. “undefined method ‘boom!’ for nil”).

"error_message"
HTTP_STATUS_CODE =

HTTP response status code.

"status"
HTTP_METHOD =

HTTP method (e.g. “GET”, “POST”).

"method"
HTTP_URL =

URL of an HTTP request containing only scheme, host, and path. Query strings and fragments must be omitted to avoid logging sensitive information.

"url"
DURATION_S =

Duration of any operation in seconds. Not limited to HTTP requests; can be used for database queries, background jobs, external API calls. Uses float64 for sub-second precision (e.g. 0.032 for 32ms).

"duration_s"
REMOTE_IP =

Remote IP address of a request.

"remote_ip"
TCP_ADDRESS =

TCP address a service is listening on, in “host:port” format (e.g. “0.0.0.0:8080”).

"tcp_address"
HTTP_URI =

Request URI including path and query string with sensitive parameters masked (e.g. “?password=FILTERED”).

"uri"
HTTP_HOST =

HTTP Host header of a request (e.g. “api.gitlab.com”).

"host"
HTTP_PROTO =

HTTP protocol version (e.g. “HTTP/1.1”, “HTTP/2.0”).

"proto"
REMOTE_ADDR =

Raw remote socket address in “host:port” format (e.g. “10.0.0.1:54321”). Use remote_ip when only the IP is needed.

"remote_addr"
HTTP_REFERRER =

HTTP Referer header with sensitive query parameters masked.

"referrer"
HTTP_USER_AGENT =

HTTP User-Agent header.

"user_agent"
WRITTEN_BYTES =

Number of bytes written to the HTTP response body.

"written_bytes"
CONTENT_TYPE =

Content-Type of an HTTP response (e.g. “application/json”).

"content_type"
TTFB_S =

Time to first byte of an HTTP response in seconds. Measures duration from request receipt to first response byte written.

"ttfb_s"

Class Method Summary collapse

Class Method Details

.constant_name_for(field_value) ⇒ String?

Get the constant name for a field value

Parameters:

  • field_value (String)

    The field value (e.g., “gl_user_id”)

Returns:

  • (String, nil)

    The constant name (e.g., “GL_USER_ID”) or nil if not found



86
87
88
89
90
91
92
# File 'lib/labkit/fields.rb', line 86

def self.constant_name_for(field_value)
  constants(false).find do |const_name|
    next if const_name == :Deprecated

    const_get(const_name) == field_value
  end&.to_s
end