Module: Labkit::Fields::Deprecated
- Defined in:
- lib/labkit/fields.rb
Constant Summary collapse
- MAPPINGS =
This module tracks deprecated field names and maps them to their standard replacements. These mappings are used by the field scanner to identify and track usage of deprecated fields in the codebase.
{ 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 Method Summary collapse
-
.all ⇒ Hash{String => String}
Get all deprecated fields as a lookup hash.
-
.deprecated?(field_name) ⇒ Boolean
Check if a field is deprecated.
-
.standard_field_for(deprecated_field) ⇒ String?
Get the standard field for a deprecated field.
Class Method Details
.all ⇒ Hash{String => String}
Get all deprecated fields as a lookup hash
144 145 146 147 148 |
# File 'lib/labkit/fields.rb', line 144 def all @all ||= MAPPINGS.each_with_object({}) do |(key, values), result| values.each { |v| result[v] = key } end end |
.deprecated?(field_name) ⇒ Boolean
Check if a field is deprecated
154 155 156 |
# File 'lib/labkit/fields.rb', line 154 def deprecated?(field_name) all.key?(field_name.to_s) end |
.standard_field_for(deprecated_field) ⇒ String?
Get the standard field for a deprecated field
162 163 164 |
# File 'lib/labkit/fields.rb', line 162 def standard_field_for(deprecated_field) all[deprecated_field.to_s] end |