Skip to content

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 the WorkerClassName 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 be free, bronze, silver or gold). If a namespace is not provided, we fallback to the project 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

Availability and Testing

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

Merge request reports