Fix the application worker structured payload

🌲 Context

In a sidekiq worker, we can use #structured_payload to automatically add more information to a given structured log.

The issue, is that we have 'class' => self.class. For sidekiq jobs, this is going through a .to_json call.

This will build a structure like this one:

{
  "class": {
    "class_attributes": {
      "deduplication_strategy": "none",
      "deduplication_options": {},
      "feature_category": "container_registry",
      "urgency": "low",
      "resource_boundary": "unknown",
      "idempotent": true
    }
  }
}

When using this structure to log a message, the message can be dropped: (from the documentation):

Unless a field type is explicitly mapped, Elasticsearch will infer the type from the first instance of that field value it sees. Subsequent instances of that field value with different types will either fail to be indexed, or in some cases (scalar/object conflict), the whole log line will be dropped.

🔬 What does this MR do?

  • Explicitly call self.class.name in the #structured_payload function
  • Update the related spec

Screenshots (strongly suggested)

n / a

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 David Fernandez

Merge request reports

Loading