Revert "log "Custom/smtp_connection_time" metric in newrelic"

This reverts commit 378bad6253.
This commit is contained in:
Son 2021-12-30 11:55:48 +01:00
parent 378bad6253
commit c5185eddf3
3 changed files with 8 additions and 15 deletions

View file

@ -7,7 +7,6 @@ from ast import literal_eval
from typing import Callable
from urllib.parse import urlparse
import newrelic.agent
from dotenv import load_dotenv
SHA1 = subprocess.getoutput("git rev-parse HEAD")
@ -403,12 +402,6 @@ except Exception:
HIBP_API_KEYS = sl_getenv("HIBP_API_KEYS", list) or []
NEWRELIC_CONFIG_PATH = os.environ.get("NEWRELIC_CONFIG_PATH")
newrelic_app = None
if NEWRELIC_CONFIG_PATH:
newrelic.agent.initialize(NEWRELIC_CONFIG_PATH)
newrelic_app = newrelic.agent.register_application()
POSTMASTER = os.environ.get("POSTMASTER")

View file

@ -17,7 +17,6 @@ from typing import Tuple, List, Optional, Union
import arrow
import dkim
import newrelic.agent
import re2 as re
import spf
from cachetools import cached, TTLCache
@ -54,7 +53,6 @@ from app.config import (
TEMP_DIR,
ALIAS_AUTOMATIC_DISABLE,
RSPAMD_SIGN_DKIM,
newrelic_app,
)
from app.db import Session
from app.dns_utils import get_mx_domains
@ -1309,11 +1307,7 @@ def sl_sendmail(
if POSTFIX_SUBMISSION_TLS:
smtp.starttls()
elapsed = time.time() - start
LOG.d("getting a smtp connection takes seconds %s", elapsed)
newrelic.agent.record_custom_metric(
"Custom/smtp_connection_time", elapsed, newrelic_app
)
LOG.d("getting a smtp connection takes seconds %s", time.time() - start)
# smtp.send_message has UnicodeEncodeError
# encode message raw directly instead

View file

@ -78,13 +78,13 @@ from app.config import (
TRANSACTIONAL_BOUNCE_SUFFIX,
ENABLE_SPAM_ASSASSIN,
BOUNCE_PREFIX_FOR_REPLY_PHASE,
NEWRELIC_CONFIG_PATH,
POSTMASTER,
ALERT_HOTMAIL_COMPLAINT,
ALERT_YAHOO_COMPLAINT,
ALERT_HOTMAIL_COMPLAINT_TRANSACTIONAL,
ALERT_HOTMAIL_COMPLAINT_REPLY_PHASE,
OLD_UNSUBSCRIBER,
newrelic_app,
)
from app.db import Session
from app.email import status, headers
@ -145,6 +145,12 @@ from app.utils import sanitize_email
from init_app import load_pgp_public_keys
from server import create_light_app
newrelic_app = None
if NEWRELIC_CONFIG_PATH:
newrelic.agent.initialize(NEWRELIC_CONFIG_PATH)
newrelic_app = newrelic.agent.register_application()
def get_or_create_contact(from_header: str, mail_from: str, alias: Alias) -> Contact:
"""