Verified Commit 07c30231 authored by Doug Barrett's avatar Doug Barrett 🔴 Committed by GitLab
Browse files

Merge branch 'labkit-spec/update-fields' into 'master'

feat: update field constants (labkit-spec v1.0)

See merge request !261

Merged-by: default avatarDoug Barrett <dbarrett@gitlab.com>
Approved-by: default avatarMatias Alvarez <malvarez@gitlab.com>
Approved-by: default avatarDoug Barrett <dbarrett@gitlab.com>
Reviewed-by: default avatarGitLab Duo <gitlab-duo@gitlab.com>
Reviewed-by: default avatarMatias Alvarez <malvarez@gitlab.com>
Co-authored-by: Elliot Forbes's avatarElliot Forbes <eforbes@gitlab.com>
parents c72520f2 78de651c
Loading
Loading
Loading
Loading
Loading
+38 −2
Original line number Diff line number Diff line
@@ -80,6 +80,28 @@ module Labkit
    # request receipt to first response byte written.
    TTFB_S = "ttfb_s"

    # GitLab project numeric ID.
    GL_PROJECT_ID = "gl_project_id"

    # GitLab pipeline numeric ID.
    GL_PIPELINE_ID = "gl_pipeline_id"

    # Log event timestamp in ISO 8601 format (e.g. "2026-04-02T12:00:00.000Z").
    TIMESTAMP = "timestamp"

    # Log severity level (e.g. "info", "warn", "error").
    SEVERITY = "severity"

    # Human-readable log message describing the event.
    LOG_MESSAGE = "message"

    # Class name associated with a log event (e.g. exception class or worker
    # class).
    CLASS_NAME = "class_name"

    # Name of the service or component emitting the log event.
    SERVICE_NAME = "service_name"

    # Get the constant name for a field value
    # @param field_value [String] The field value (e.g., "gl_user_id")
    # @return [String, nil] The constant name (e.g., "GL_USER_ID") or nil if not found
@@ -97,8 +119,22 @@ module Labkit
      # to identify and track usage of deprecated fields in the codebase.

      MAPPINGS = {
        Fields::GL_USER_ID => %w[user_id userid],
        Fields::HTTP_STATUS_CODE => %w[status_code extra.status status_text],
        Fields::CORRELATION_ID => %w[tags.correlation_id],
        Fields::GL_USER_ID => %w[user_id userid extra.user_id extra.current_user_id meta.user_id],
        Fields::GL_USER_NAME => %w[username extra.user meta.user],
        Fields::ERROR_MESSAGE => %w[error err error.message exception.message graphql_errors],
        Fields::HTTP_STATUS_CODE => %w[status_code extra.status status_text http_status],
        Fields::HTTP_URL => %w[req_url],
        Fields::DURATION_S => %w[duration duration_ms elapsed_time actual_duration time_ms total_time gitaly.duration],
        Fields::REMOTE_IP => %w[ip source_ip ip_address meta.remote_ip],
        Fields::HTTP_HOST => %w[hostname request_host gitlab_host kubernetes.host],
        Fields::GL_PROJECT_ID => %w[extra.project_id meta.project_id meta.search.project_id job_project_id target_project_id],
        Fields::GL_PIPELINE_ID => %w[extra.pipeline_id meta.pipeline_id root_pipeline_id],
        Fields::TIMESTAMP => %w[start_time],
        Fields::SEVERITY => %w[level],
        Fields::LOG_MESSAGE => %w[msg custom_message extra.message fields.message graphql.message reason color_message exception.gitaly],
        Fields::CLASS_NAME => %w[class author_class exception.class extra.class extra.class_name],
        Fields::SERVICE_NAME => %w[service grpc.service_name auth_service type component subcomponent],
      }.freeze

      class << self