Module: Traceable

Extended by:
ActiveSupport::Concern
Included in:
ApplicationController, SignIn::ApplicationController
Defined in:
app/controllers/concerns/traceable.rb

Overview

Provides functionality to controllers for tagging them with specific services. This tagging allows monitoring and tracing systems (like Datadog) to identify and group the activities of specific controllers based on the service tags they are associated with.

Examples:

Setting a service tag for a controller

class MyController < ApplicationController
  include Traceable
  service_tag :my_service
end

Instance Method Summary collapse

Instance Method Details

#set_trace_tagsObject

Note:

After all current controllers implement service tagging, this could raise an error instead.

Sets trace tags for the current action. If no service tag is set, do nothing.



34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/concerns/traceable.rb', line 34

def set_trace_tags
  service = self.class.trace_service_tag

  # Not warning for now, re-introduce once we are at 100% of controllers tagged
  # return Rails.logger.warn('Service tag missing', class: self.class.name) if service.blank?

  Datadog::Tracing.active_span&.service = service if service.present?
rescue => e
  Rails.logger.error('Error setting service tag', class: self.class.name, message: e.message)
end