Module: Labkit::Fields
- Defined in:
- lib/labkit/fields.rb
Overview
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.
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
...
Labkit (Go): gitlab.com/gitlab-org/labkit/-/tree/master/fields?ref_type=heads
For Engineers Looking to add fields:
These fields are derived from the Go Labkit variant. Please ensure that you’ve made the respective changes in that repository prior to including the fields in this package.
Please see the handbook page for more information handbook.gitlab.com/handbook/engineering/architecture/design-documents/observability_field_standardisation/
Defined Under Namespace
Modules: Deprecated
Constant Summary collapse
- CORRELATION_ID =
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"- GL_USER_ID =
GitLabUserID - an integer field that captures the user’s numeric ID for logging purposes.
"gl_user_id"- GL_USER_NAME =
GitLabUserName - a string field that captures the user’s username for logging purposes.
"gl_user_name"- ERROR_TYPE =
ErrorType - a string field that should contain the error type or classification (e.g., “NoMethodError”, “ValidationError”).
"error_type"- ERROR_MESSAGE =
ErrorMessage - a string field that should contain the detailed error message (e.g., “undefined method ‘boom!’ for nil”).
"error_message"- HTTP_STATUS_CODE =
HTTPStatusCode - an integer field that captures the HTTP status code of requests for logging purposes.
"status"- HTTP_METHOD =
HTTPMethod - a string field that captures the HTTP method (e.g., “GET”, “POST”) of a request for logging purposes.
"method"- HTTP_URL =
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. “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.
"url"- DURATION_S =
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"- REMOTE_IP =
RemoteIP - a string field that captures the remote IP address of a request for logging purposes.
"remote_ip"- TCP_ADDRESS =
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"
Class Method Summary collapse
-
.constant_name_for(field_value) ⇒ String?
Get the constant name for a field value.
Class Method Details
.constant_name_for(field_value) ⇒ String?
Get the constant name for a field value
95 96 97 98 99 100 101 |
# File 'lib/labkit/fields.rb', line 95 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 |