Commit cf82358b authored by Bob Van Landuyt's avatar Bob Van Landuyt 💬
Browse files

Merge branch 'ef-3880-create-fields-package-for-labkit-2' into 'master'

Defines a Fields module within labkit

See merge request !186

Merged-by: Bob Van Landuyt's avatarBob Van Landuyt <bob@gitlab.com>
Approved-by: Bob Van Landuyt's avatarBob Van Landuyt <bob@gitlab.com>
Reviewed-by: Bob Van Landuyt's avatarBob Van Landuyt <bob@gitlab.com>
Co-authored-by: Elliot Forbes's avatare_forbes <eforbes@gitlab.com>
parents 5a3ab934 eac9c21f
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ module Labkit
  autoload :Logging, "labkit/logging"
  autoload :Metrics, "labkit/metrics"
  autoload :Middleware, "labkit/middleware"
  autoload :Fields, "labkit/fields"

  # Publishers to publish notifications whenever a HTTP reqeust is made.
  # A broadcasted notification's payload in topic "request.external_http" includes:

lib/labkit/fields.rb

0 → 100644
+41 −0
Original line number Diff line number Diff line
# frozen_string_literal: true

module Labkit
  ##
  # Fields is intended to be a SSOT for all of the common field names that
  # we emit via any observability we add to our systems.
  #
  # These fields should span multiple services. This is
  #
  # The goal of this package is to reduce the likelihood for typos or
  # subtly different naming conventions. This will help to ensure we
  # are able to marry up logs between different systems as a request
  # is being processed.
  #
  # Usage:
  #   require 'labkit/fields'
  #   ...
  #   data[Labkit::Fields::GL_USER_ID] = user.id
  #   ...
  #
  module Fields
    # correlation_id - string
    #
    # This field is used to correlate
    # the logs emitted by all of our systems.
    #
    # This should be present in all log line
    # emissions.
    CORRELATION_ID = "correlation_id"

    # We'll need to add the rest of the top
    # level fields here:
    # [endpoint_id, duration_s, status_code]

    # gl_user_id - integer
    GL_USER_ID = "gl_user_id"

    # gl_user_name - string
    GL_USER_NAME = "gl_user_name"
  end
end