Add extra fields to the application context
What does this MR do?
It extends the existing Gitlab::ApplicationContext
and add two new fields:
-
caller_id
(which can store the controller action if it's a regular Rails request,api/<:version>/<endpoint>
if it's a grape API request or theWorkerClassName
if it's a job being scheduled). Note that the first two still depend on gitlab-com/gl-infra/scalability#68 (closed) to get into the logs. -
subscription_plan
(which can befree
,bronze
,silver
orgold
). If anamespace
is not provided, we fallback to theproject
to try to find the current plan.
These new fields will end-up at Sidekiq logs under a meta.
prefix:
{
"severity":"INFO",
"time":"2020-01-10T20:11:01.035Z",
"class":"ProjectExportWorker",
"args":[
1,
19,
null,
{
}
],
"retry":3,
"queue":"project_export",
"backtrace":5,
"jid":"c11294507b35bcd00c9eecd9",
"created_at":"2020-01-10T20:11:00.903Z",
"meta.user":"root",
"meta.project":"root/asdf",
"meta.root_namespace":"root",
"meta.subscription_plan":"free",
"meta.caller_id":"ProjectExportWorker",
"correlation_id":"gUBSHlFHHL7",
"uber-trace-id":"3a8a4147f7aaeda1:cb8fdc7f81848b94:f24ce07e0ff4f38e:1",
"enqueued_at":"2020-01-10T20:11:01.026Z",
"pid":67596,
"message":"ProjectExportWorker JID-c11294507b35bcd00c9eecd9: start",
"job_status":"start",
"scheduling_latency_s":0.009941
}
gitlab-com/gl-infra/scalability#69 (closed)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -> being added at !22896 (merged) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Oswaldo Ferreira