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'

Class Method Summary collapse

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

included

Class Method Details

.event_nameObject



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

def event_name
  self::EVENT_NAME
end

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



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/datadog/tracing/contrib/action_mailer/events/deliver.rb', line 39

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

  span.resource = payload[:mailer] # Mailer is not available at `on_start`

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

  # 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

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



33
34
35
36
37
# File 'lib/datadog/tracing/contrib/action_mailer/events/deliver.rb', line 33

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

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

.span_nameObject



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

def span_name
  Ext::SPAN_DELIVER
end

.span_typeObject



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

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