Skip to content

Adds logging to custom email verification services

Marc Saleiko requested to merge ms-sd-custom-email-verification-logging into master

What does this MR do and why?

Contributes to Follow-up: Add logging to custom email address ... (#415594 - closed)

This MR adds logging to custom email verification services. It logs errors and state transitions to the application json log.

Screenshots or screen recordings

🚫 backend only

How to set up and validate locally

To see one of these logs in action without the need to fully set up email ingestion or use valid SMTP credentials, you can create a custom email using invalid credentials. Run the following in the rails console:

# Only enable flag for project #7
project = Project.find(7)
Feature.enable(:service_desk_custom_email, project)

current_user = User.first
custom_email = 'support@example.com'

setting = ServiceDeskSetting.find_or_create_by!(project_id: project.id)

params = {
  custom_email: custom_email,
  smtp_address: 'smtp.gmail.com', # we need a valid smtp address
  smtp_port: 587,
  smtp_username: custom_email,
  smtp_password: 'supersecret'
}

# Create custom email using invalid credentials
response = ::ServiceDesk::CustomEmails::CreateService.new(
  project: project,
  current_user: current_user,
  params: params
).execute

# Destroy custom email again, as we only want to see logging for verification
::ServiceDesk::CustomEmails::DestroyService.new(
  project: project,
  current_user: current_user
).execute

# Disable feature again
Feature.disable(:service_desk_custom_email, project)

From the gitlab folder run tail log/application_json.log in the terminal and find the verification entry.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Marc Saleiko

Merge request reports