send Custom/smtp_connection_time to newrelic

This commit is contained in:
Son 2021-12-30 14:17:46 +01:00
parent 2cd50c582a
commit 22cf8cfe38
1 changed files with 4 additions and 1 deletions

View File

@ -17,6 +17,7 @@ from typing import Tuple, List, Optional, Union
import arrow import arrow
import dkim import dkim
import newrelic.agent
import re2 as re import re2 as re
import spf import spf
from cachetools import cached, TTLCache from cachetools import cached, TTLCache
@ -1307,7 +1308,9 @@ def sl_sendmail(
if POSTFIX_SUBMISSION_TLS: if POSTFIX_SUBMISSION_TLS:
smtp.starttls() smtp.starttls()
LOG.d("getting a smtp connection takes seconds %s", time.time() - start) elapsed = time.time() - start
LOG.d("getting a smtp connection takes seconds %s", elapsed)
newrelic.agent.record_custom_metric("Custom/smtp_connection_time", elapsed)
# smtp.send_message has UnicodeEncodeError # smtp.send_message has UnicodeEncodeError
# encode message raw directly instead # encode message raw directly instead