gitlab-labkit 1.11.0 → 1.12.0
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 +4 -4
- data/lib/labkit/fields.rb +18 -0
- data/lib/labkit/user_experience_sli/experience.rb +11 -12
- data/lib/labkit/user_experience_sli/null.rb +4 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e99cf18b21d9da22b488d0dd0031fc9030aeded745239b4e72e8d3f7c1c36555
|
|
4
|
+
data.tar.gz: 664ba45d3535d3310431eece7890c58ddfa9cd8a9dfa3c235b66fd20b2b5480e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f7959c2eb8f54ee928a7841c2b8de8011c1e2a481c3c6aaf8e94b53a7ca186e8c28ad192a641c4c8ffac5bd8fd39a2c7c6afad324dfae77531b00e3089de3dc0
|
|
7
|
+
data.tar.gz: 05d07f6b1dffe39907c372ca0cb1c638cbc3898f39faf33f82ef5e042c9ea916a94d297963706e0010bc30dc14df2ebf2a1d89a342866630753af233f52934d1
|
data/lib/labkit/fields.rb
CHANGED
|
@@ -102,6 +102,22 @@ module Labkit
|
|
|
102
102
|
# Name of the service or component emitting the log event.
|
|
103
103
|
SERVICE_NAME = "service_name"
|
|
104
104
|
|
|
105
|
+
# GitLab organization numeric ID.
|
|
106
|
+
GL_ORGANIZATION_ID = "gl_organization_id"
|
|
107
|
+
|
|
108
|
+
# GitLab project path.
|
|
109
|
+
GL_PROJECT_PATH = "gl_project_path"
|
|
110
|
+
|
|
111
|
+
# The endpoint_id of the current endpoint to be passed as caller_id when
|
|
112
|
+
# calling another service.
|
|
113
|
+
ENDPOINT_ID = "endpoint_id"
|
|
114
|
+
|
|
115
|
+
# The ID of the caller of the current service.
|
|
116
|
+
CALLER_ID = "caller_id"
|
|
117
|
+
|
|
118
|
+
# The endpoint_id of the original caller at the root of the call chain.
|
|
119
|
+
ROOT_CALLER_ID = "root_caller_id"
|
|
120
|
+
|
|
105
121
|
# Get the constant name for a field value
|
|
106
122
|
# @param field_value [String] The field value (e.g., "gl_user_id")
|
|
107
123
|
# @return [String, nil] The constant name (e.g., "GL_USER_ID") or nil if not found
|
|
@@ -135,6 +151,8 @@ module Labkit
|
|
|
135
151
|
Fields::LOG_MESSAGE => %w[msg custom_message extra.message fields.message graphql.message reason color_message exception.gitaly],
|
|
136
152
|
Fields::CLASS_NAME => %w[class author_class exception.class extra.class extra.class_name],
|
|
137
153
|
Fields::SERVICE_NAME => %w[service grpc.service_name auth_service type component subcomponent],
|
|
154
|
+
Fields::GL_ORGANIZATION_ID => %w[organization_id],
|
|
155
|
+
Fields::GL_PROJECT_PATH => %w[project_path full_path root_pipeline_project_path requested_project_path auth_project_path extra.gl_project_path],
|
|
138
156
|
}.freeze
|
|
139
157
|
|
|
140
158
|
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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
|
14
|
+
return yield(self) if block_given?
|
|
15
|
+
|
|
15
16
|
self
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def resume(**_extra)
|
|
19
|
-
yield
|
|
20
|
+
return yield(self) if block_given?
|
|
21
|
+
|
|
20
22
|
self
|
|
21
23
|
end
|
|
22
24
|
|