Commit 070bfd6b authored by Elliot Forbes's avatar Elliot Forbes 2️⃣
Browse files

feat(fields): add error, HTTP, duration, remote IP, and TCP address fields

Adds new standardized field constants to align with the Go labkit equivalent:
ERROR_TYPE, ERROR_MESSAGE, HTTP_STATUS_CODE, HTTP_METHOD, HTTP_URL, DURATION_S,
REMOTE_IP, and TCP_ADDRESS.

Co-Authored-By: default avatarClaude Sonnet 4.6 <noreply@anthropic.com>
parent b20d56eb
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -44,10 +44,45 @@ module Labkit
    # captures the user's username for logging purposes.
    GL_USER_NAME = "gl_user_name"

    # ErrorType - a string field that should contain the error type or classification
    # (e.g., "NoMethodError", "ValidationError").
    ERROR_TYPE = "error_type"

    # ErrorMessage - a string field that should contain the detailed error message
    # (e.g., "undefined method `boom!' for nil").
    ERROR_MESSAGE = "error_message"

    # HTTPStatusCode - an integer field that
    # captures the HTTP status code of requests for logging purposes.
    HTTP_STATUS_CODE = "status"

    # HTTPMethod - a string field that captures the HTTP method
    # (e.g., "GET", "POST") of a request for logging purposes.
    HTTP_METHOD = "method"

    # HTTPURL - a string field that captures the URL of an HTTP request
    # (scheme, host, and path only - query strings should be omitted
    # to avoid logging sensitive data) for logging purposes.
    # (e.g. "https://example.com/foo) Query strings and fragments (anchors)
    # must be omitted to avoid logging sensitive information such as tokens
    # or passwords that may appear in query parameters.
    HTTP_URL = "url"

    # DurationS - a float field that captures the duration of any operation
    # in seconds for logging purposes. It is not limited to HTTP requests and
    # can be used for any timed operation (e.g. database queries, background
    # jobs, external API calls).
    DURATION_S = "duration_s"

    # RemoteIP - a string field that captures the remote IP
    # address of a request for logging purposes.
    REMOTE_IP = "remote_ip"

    # TCPAddress - a string field that captures the TCP address a service or
    # component is listening on, in "host:port" format
    # (e.g. "0.0.0.0:8080" or "127.0.0.1:9090").
    TCP_ADDRESS = "tcp_address"

    # New fields being added to this section should have
    # the appropriate doc comments added above. These
    # should clearly indicate what the intended use of the