gitlab-labkit 1.10.0 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce9130ded76934b6e21e82724c7371548b9e790e451179a7e70cd14f545969d7
4
- data.tar.gz: 1463999f63f123911a57a45d6943fb68e25daa07338cc2afd49f9592cb71ffb0
3
+ metadata.gz: e8c136c0ed8617c5023574687e1b1284621726be410583eb7ee17586fe56c20e
4
+ data.tar.gz: f9f496d1b6ea56d986b577052f8f50c7a91f1114307af3bd9856734c482afac1
5
5
  SHA512:
6
- metadata.gz: df940f5abe8e939c2bb84440ed9ad340dc2e4a359dddc330d752f778e1d9c7c5aa2a6d19ee233081a7fc0cfd512e7cf5e54ad44fd419d11b2d0f85030ad6fd56
7
- data.tar.gz: eee7205f950d1c9bf59060d25d0e5e7a196dadc98b521064813014129e022b2e3c9a5adfad68332b4ba1e2b9f75cbe6a6e8625cc228daa9d2976edbc05a31c25
6
+ metadata.gz: caed2e7c544c73856cd6a47a0f63655038f636674cf5070a0cb4b5330c2beda0c07ff0a7352b5d367f293ae818ecf08aa414316485f5cc6a262595c5240f334c
7
+ data.tar.gz: 7c3b49fc037060c21ea36e49e4878f99640e241b5a7358665fddf6bdde354ac26ddda80c87b11f5de183c4a259a9b2d6c8629818a852078393487c1c78ef6ba1
data/lib/labkit/fields.rb CHANGED
@@ -80,6 +80,28 @@ module Labkit
80
80
  # request receipt to first response byte written.
81
81
  TTFB_S = "ttfb_s"
82
82
 
83
+ # GitLab project numeric ID.
84
+ GL_PROJECT_ID = "gl_project_id"
85
+
86
+ # GitLab pipeline numeric ID.
87
+ GL_PIPELINE_ID = "gl_pipeline_id"
88
+
89
+ # Log event timestamp in ISO 8601 format (e.g. "2026-04-02T12:00:00.000Z").
90
+ TIMESTAMP = "timestamp"
91
+
92
+ # Log severity level (e.g. "info", "warn", "error").
93
+ SEVERITY = "severity"
94
+
95
+ # Human-readable log message describing the event.
96
+ LOG_MESSAGE = "message"
97
+
98
+ # Class name associated with a log event (e.g. exception class or worker
99
+ # class).
100
+ CLASS_NAME = "class_name"
101
+
102
+ # Name of the service or component emitting the log event.
103
+ SERVICE_NAME = "service_name"
104
+
83
105
  # Get the constant name for a field value
84
106
  # @param field_value [String] The field value (e.g., "gl_user_id")
85
107
  # @return [String, nil] The constant name (e.g., "GL_USER_ID") or nil if not found
@@ -97,8 +119,22 @@ module Labkit
97
119
  # to identify and track usage of deprecated fields in the codebase.
98
120
 
99
121
  MAPPINGS = {
100
- Fields::GL_USER_ID => %w[user_id userid],
101
- Fields::HTTP_STATUS_CODE => %w[status_code extra.status status_text],
122
+ Fields::CORRELATION_ID => %w[tags.correlation_id],
123
+ Fields::GL_USER_ID => %w[user_id userid extra.user_id extra.current_user_id meta.user_id],
124
+ Fields::GL_USER_NAME => %w[username extra.user meta.user],
125
+ Fields::ERROR_MESSAGE => %w[error err error.message exception.message graphql_errors],
126
+ Fields::HTTP_STATUS_CODE => %w[status_code extra.status status_text http_status],
127
+ Fields::HTTP_URL => %w[req_url],
128
+ Fields::DURATION_S => %w[duration duration_ms elapsed_time actual_duration time_ms total_time gitaly.duration],
129
+ Fields::REMOTE_IP => %w[ip source_ip ip_address meta.remote_ip],
130
+ Fields::HTTP_HOST => %w[hostname request_host gitlab_host kubernetes.host],
131
+ Fields::GL_PROJECT_ID => %w[extra.project_id meta.project_id meta.search.project_id job_project_id target_project_id],
132
+ Fields::GL_PIPELINE_ID => %w[extra.pipeline_id meta.pipeline_id root_pipeline_id],
133
+ Fields::TIMESTAMP => %w[start_time],
134
+ Fields::SEVERITY => %w[level],
135
+ Fields::LOG_MESSAGE => %w[msg custom_message extra.message fields.message graphql.message reason color_message exception.gitaly],
136
+ Fields::CLASS_NAME => %w[class author_class exception.class extra.class extra.class_name],
137
+ Fields::SERVICE_NAME => %w[service grpc.service_name auth_service type component subcomponent],
102
138
  }.freeze
103
139
 
104
140
  class << self
@@ -61,7 +61,8 @@ module Labkit
61
61
  #
62
62
  # @yield [self] When a block is provided, the experience will be completed automatically.
63
63
  # @param extra [Hash] Additional data to include in the log event
64
- # @return [self]
64
+ # @return [self] When no block is given.
65
+ # @return [Object] The result of the block when a block is given.
65
66
  # @raise [UserExperienceError] If the block raises an error.
66
67
  #
67
68
  # Usage:
@@ -104,7 +105,9 @@ module Labkit
104
105
  # Resume the User Experience.
105
106
  #
106
107
  # @yield [self] When a block is provided, the experience will be completed automatically.
107
- # @param extra [Hash] Additional data to include in the log
108
+ # @param extra [Hash] Additional data to include in the log event
109
+ # @return [self] When no block is given.
110
+ # @return [Object] The result of the block when a block is given.
108
111
  def resume(**extra, &)
109
112
  return self unless ensure_started!
110
113
 
@@ -190,16 +193,12 @@ module Labkit
190
193
  end
191
194
 
192
195
  def completable(**extra, &)
193
- begin
194
- yield self
195
- rescue StandardError => e
196
- error!(e)
197
- raise
198
- ensure
199
- complete(**extra)
200
- end
201
-
202
- self
196
+ yield self
197
+ rescue StandardError => e
198
+ error!(e)
199
+ raise
200
+ ensure
201
+ complete(**extra)
203
202
  end
204
203
 
205
204
  def ensure_incomplete!
@@ -11,12 +11,14 @@ module Labkit
11
11
  def id = 'null'
12
12
 
13
13
  def start(**_extra)
14
- yield self if block_given?
14
+ return yield(self) if block_given?
15
+
15
16
  self
16
17
  end
17
18
 
18
19
  def resume(**_extra)
19
- yield self if block_given?
20
+ return yield(self) if block_given?
21
+
20
22
  self
21
23
  end
22
24
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-labkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Newdigate