Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #831 from mozilla-services/bug/830
Browse files Browse the repository at this point in the history
bug: Don't send non-priority messages to sentry
  • Loading branch information
jrconlin authored Mar 1, 2017
2 parents f57286e + 9446529 commit b1cdf4e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
8 changes: 8 additions & 0 deletions autopush/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ def connection_main(sysargs=None, use_files=True):
env=args.env,
hello_timeout=args.hello_timeout,
preflight_uaid="deadbeef000000000deadbeef" + postfix,
debug=args.debug,
)
if not settings:
return 1 # pragma: nocover
Expand All @@ -507,6 +508,7 @@ def connection_main(sysargs=None, use_files=True):
default_host=settings.router_hostname, debug=args.debug,
log_function=skip_request_logging
)
site.noisy = args.debug
mount_health_handlers(site, settings)

# Public websocket server
Expand All @@ -532,6 +534,9 @@ def connection_main(sysargs=None, use_files=True):
resource = DefaultResource(WebSocketResource(factory))
resource.putChild("status", StatusResource())
site_factory = Site(resource)
# Silence starting/stopping messages
site_factory.noisy = args.debug
site.noisy = args.debug

# Start the WebSocket listener.
if args.ssl_key:
Expand Down Expand Up @@ -588,6 +593,7 @@ def endpoint_main(sysargs=None, use_files=True):
enable_cors=not args.no_cors,
bear_hash_key=args.auth_key,
preflight_uaid="deadbeef000000000deadbeef" + postfix,
debug=args.debug
)
if not settings:
return 1
Expand All @@ -607,6 +613,7 @@ def endpoint_main(sysargs=None, use_files=True):
site.protocol = LimitedHTTPConnection
site.protocol.maxData = settings.max_data
mount_health_handlers(site, settings)
site.noisy = args.debug

settings.metrics.start()

Expand Down Expand Up @@ -658,4 +665,5 @@ def create_memusage_site(settings, port, debug):
debug=debug,
log_function=skip_request_logging
)
site.noisy = debug
return reactor.listenTCP(port, site)
3 changes: 2 additions & 1 deletion autopush/router/apns2.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ def send(self, router_token, payload, apns_id,
reason),
status_code=502,
response_body="APNS could not process "
"your message {}".format(reason)
"your message {}".format(reason),
log_exception=False
)
except HTTP20Error:
connection.close()
Expand Down
3 changes: 2 additions & 1 deletion autopush/router/fcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ def _process_reply(self, reply, notification, router_data, ttl):
raise RouterException("FCM failure to deliver",
status_code=err['err'],
response_body="Please try request "
"later.")
"later.",
log_exception=False)
creds = router_data["creds"]
self.log.info("{msg} : {info}",
msg=err['msg'],
Expand Down
11 changes: 10 additions & 1 deletion autopush/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
returnValue,
)
from twisted.internet.threads import deferToThread
from twisted.web.client import Agent, HTTPConnectionPool
from twisted.web.client import Agent, HTTPConnectionPool, _HTTP11ClientFactory

from autopush.db import (
get_router_table,
Expand Down Expand Up @@ -44,6 +44,11 @@
from autopush.crypto_key import (CryptoKey, CryptoKeyException)


class QuietClientFactory(_HTTP11ClientFactory):
"""Silence the start/stop factory messages."""
noisy = False


class AutopushSettings(object):
"""Main Autopush Settings Object"""
options = ["crypto_key", "hostname", "min_ping_interval",
Expand Down Expand Up @@ -86,6 +91,7 @@ def __init__(self,
ami_id=None,
client_certs=None,
msg_limit=100,
debug=False,
):
"""Initialize the Settings object
Expand All @@ -96,6 +102,9 @@ def __init__(self,
"""
# Use a persistent connection pool for HTTP requests.
pool = HTTPConnectionPool(reactor)
if not debug:
pool._factory = QuietClientFactory

self.agent = Agent(reactor, connectTimeout=5, pool=pool)

if not crypto_key:
Expand Down

0 comments on commit b1cdf4e

Please sign in to comment.