Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamline exception handling #6003

Merged
merged 2 commits into from
Mar 10, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions sqlserver/datadog_checks/sqlserver/sqlserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
'''
from __future__ import division

import traceback
from collections import defaultdict
from contextlib import contextmanager

from six import raise_from

from datadog_checks.checks import AgentCheck
from datadog_checks.config import is_affirmative

Expand Down Expand Up @@ -660,13 +661,7 @@ def open_db_connections(self, instance, db_key, db_name=None):
message = "Unable to connect to SQL Server for instance {}.".format(cx)
self.service_check(self.SERVICE_CHECK_NAME, AgentCheck.CRITICAL, tags=service_check_tags, message=message)

password = instance.get('password')
tracebk = traceback.format_exc()
if password is not None:
tracebk = tracebk.replace(password, "*" * 6)

cxn_failure_exp = SQLConnectionError("{} \n {}".format(message, tracebk))
raise cxn_failure_exp
raise_from(SQLConnectionError(message), None)


class SqlServerMetric(object):
Expand Down