Module: Datadog::Tracing::Contrib::ActionMailer::Events::Deliver

Includes:
Datadog::Tracing::Contrib::ActionMailer::Event
Defined in:
lib/datadog/tracing/contrib/action_mailer/events/deliver.rb

Overview

Defines instrumentation for deliver.action_mailer event

Constant Summary collapse

EVENT_NAME =
'deliver.action_mailer'.freeze

Class Method Summary collapse

Methods included from Datadog::Tracing::Contrib::ActionMailer::Event

included

Class Method Details

.event_nameObject



18
19
20
# File 'lib/datadog/tracing/contrib/action_mailer/events/deliver.rb', line 18

def event_name
  self::EVENT_NAME
end

.process(span, event, _id, payload) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/datadog/tracing/contrib/action_mailer/events/deliver.rb', line 31

def process(span, event, _id, payload)
  super

  span.span_type = span_type
  span.set_tag(Ext::TAG_MAILER, payload[:mailer])
  span.set_tag(Ext::TAG_MSG_ID, payload[:message_id])

  span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_DELIVER)

  # Since email data can contain PII we disable by default
  # Some of these fields can be either strings or arrays, so we try to normalize
  # https://github.com/rails/rails/blob/18707ab17fa492eb25ad2e8f9818a320dc20b823/actionmailer/lib/action_mailer/base.rb#L742-L754
  if configuration[:email_data] == true
    span.set_tag(Ext::TAG_SUBJECT, payload[:subject].to_s) if payload[:subject]
    span.set_tag(Ext::TAG_TO, payload[:to].join(',')) if payload[:to]
    span.set_tag(Ext::TAG_FROM, payload[:from].join(',')) if payload[:from]
    span.set_tag(Ext::TAG_BCC, payload[:bcc].join(',')) if payload[:bcc]
    span.set_tag(Ext::TAG_CC, payload[:cc].join(',')) if payload[:cc]
    span.set_tag(Ext::TAG_DATE, payload[:date].to_s) if payload[:date]
    span.set_tag(Ext::TAG_PERFORM_DELIVERIES, payload[:perform_deliveries]) if payload[:perform_deliveries]
  end
end

.span_nameObject



22
23
24
# File 'lib/datadog/tracing/contrib/action_mailer/events/deliver.rb', line 22

def span_name
  Ext::SPAN_DELIVER
end

.span_typeObject



26
27
28
29
# File 'lib/datadog/tracing/contrib/action_mailer/events/deliver.rb', line 26

def span_type
  # deliver.action_mailer sends emails
  Tracing::Metadata::Ext::AppTypes::TYPE_WORKER
end