Skip to content

Commit ee7d053

Browse files
TimPansinoumaannamalailrafeei
authored
Distributed Tracing by Default (#379)
* Add CAT deprecation warning. (#332) * CAT/DT--DT by default (#335) * Fix TimeTrace __str__ recursion (#334) * Update repr for time_trace and function_trace * Formatting * Clean up other repr implementations * Formatting * Add bandit config * Fix GHA Config (#340) * Fix GHA config * Format * Add CAT deprecation warning. (#332) * Fix tests that fail due to DT==True, CAT==False * Add fixed aiohttp and pika tests. * Fix agent_features tests. * Modify libcurl tests * Fix tests that fail due to DT==True, CAT==False * Add fixed aiohttp and pika tests. * Fix agent_features tests. * Modify libcurl tests * Remove commented code * Add fixed aiohttp and pika tests. * Fix agent_features tests. * Modify libcurl tests * Add fixed aiohttp and pika tests. * Fix agent_features tests. * Modify libcurl tests * Fix tornado tests. * Format with megalinter Co-authored-by: Timothy Pansino <[email protected]> Co-authored-by: Uma Annamalai <[email protected]> Co-authored-by: Tim Pansino <[email protected]> * Update DT setting in default newrelic.ini. (#342) * Add connect harvest config limits (#341) * Linting files Co-authored-by: Uma Annamalai <[email protected]> * Add override for span event harvest config. Co-authored-by: Tim Pansino <[email protected]> Co-authored-by: Lalleh Rafeei <[email protected]> Update span event harvest config logic. Co-authored-by: Tim Pansino <[email protected]> Co-authored-by: Uma Annamalai <[email protected]> * Add harvest limit env vars (#338) * Add env vars for harvest limits * Format * Change span reservoir size (#359) * Change default span reservoir size Co-authored-by: Uma Annamalai <[email protected]> Co-authored-by: lrafeei <[email protected]> * Trigger Tests * Fix setting test default Co-authored-by: Uma Annamalai <[email protected]> Co-authored-by: lrafeei <[email protected]> Co-authored-by: Uma Annamalai <[email protected]> Co-authored-by: Lalleh Rafeei <[email protected]> Co-authored-by: Uma Annamalai <[email protected]> Co-authored-by: lrafeei <[email protected]>
1 parent a1bf688 commit ee7d053

38 files changed

+3351
-3278
lines changed

newrelic/api/application.py

+12-13
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
import threading
1616
import warnings
1717

18-
import newrelic.core.config
19-
import newrelic.core.agent
2018
import newrelic.api.import_hook
21-
19+
import newrelic.core.agent
20+
import newrelic.core.config
2221
import newrelic.packages.six as six
2322

2423

@@ -99,8 +98,9 @@ def activate(self, timeout=None):
9998
# configuration will later be used. Note that the timeout only
10099
# applies on the first call to activate the application.
101100

102-
self._agent.activate_application(self._name, self._linked, timeout,
103-
newrelic.api.import_hook._uninstrumented_modules)
101+
self._agent.activate_application(
102+
self._name, self._linked, timeout, newrelic.api.import_hook._uninstrumented_modules
103+
)
104104

105105
def shutdown(self):
106106
pass
@@ -112,17 +112,16 @@ def linked_applications(self):
112112
def link_to_application(self, name):
113113
self._linked[name] = True
114114

115-
def record_exception(self, exc=None, value=None, tb=None, params={},
116-
ignore_errors=[]):
115+
def record_exception(self, exc=None, value=None, tb=None, params=None, ignore_errors=None):
117116
# Deprecation Warning
118-
warnings.warn((
119-
'The record_exception function is deprecated. Please use the '
120-
'new api named notice_error instead.'
121-
), DeprecationWarning)
117+
warnings.warn(
118+
("The record_exception function is deprecated. Please use the " "new api named notice_error instead."),
119+
DeprecationWarning,
120+
)
122121

123122
self.notice_error(error=(exc, value, tb), attributes=params, ignore=ignore_errors)
124123

125-
def notice_error(self, error=None, attributes={}, expected=None, ignore=None, status_code=None):
124+
def notice_error(self, error=None, attributes=None, expected=None, ignore=None, status_code=None):
126125
if not self.active:
127126
return
128127

@@ -151,7 +150,7 @@ def record_transaction(self, data):
151150
if self.active:
152151
self._agent.record_transaction(self._name, data)
153152

154-
def normalize_name(self, name, rule_type='url'):
153+
def normalize_name(self, name, rule_type="url"):
155154
if self.active:
156155
return self._agent.normalize_name(self._name, name, rule_type)
157156
return name, False

newrelic/api/database_trace.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def _nr_database_trace_wrapper_(wrapped, instance, args, kwargs):
258258

259259
trace = DatabaseTrace(_sql, dbapi2_module, parent=parent)
260260

261-
if wrapper:
261+
if wrapper: # pylint: disable=W0125,W0126
262262
return wrapper(wrapped, trace)(*args, **kwargs)
263263

264264
with trace:

newrelic/api/datastore_trace.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def _nr_datastore_trace_wrapper_(wrapped, instance, args, kwargs):
189189

190190
trace = DatastoreTrace(_product, _target, _operation, parent=parent)
191191

192-
if wrapper:
192+
if wrapper: # pylint: disable=W0125,W0126
193193
return wrapper(wrapped, trace)(*args, **kwargs)
194194

195195
with trace:

newrelic/api/external_trace.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def dynamic_wrapper(wrapped, instance, args, kwargs):
9696

9797
trace = ExternalTrace(library, _url, _method, parent=parent)
9898

99-
if wrapper:
99+
if wrapper: # pylint: disable=W0125,W0126
100100
return wrapper(wrapped, trace)(*args, **kwargs)
101101

102102
with trace:
@@ -113,8 +113,7 @@ def literal_wrapper(wrapped, instance, args, kwargs):
113113

114114
trace = ExternalTrace(library, url, method, parent=parent)
115115

116-
wrapper = async_wrapper(wrapped)
117-
if wrapper:
116+
if wrapper: # pylint: disable=W0125,W0126
118117
return wrapper(wrapped, trace)(*args, **kwargs)
119118

120119
with trace:

newrelic/api/function_trace.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(self, name, group=None, label=None, params=None, terminal=False, ro
4646
self.params = params
4747

4848
self.terminal = terminal
49-
self.rollup = terminal and rollup or None
49+
self.rollup = rollup if terminal else None
5050

5151
def __enter__(self):
5252
result = TimeTrace.__enter__(self)
@@ -140,7 +140,7 @@ def dynamic_wrapper(wrapped, instance, args, kwargs):
140140

141141
trace = FunctionTrace(_name, _group, _label, _params, terminal, rollup, parent=parent)
142142

143-
if wrapper:
143+
if wrapper: # pylint: disable=W0125,W0126
144144
return wrapper(wrapped, trace)(*args, **kwargs)
145145

146146
with trace:
@@ -159,7 +159,7 @@ def literal_wrapper(wrapped, instance, args, kwargs):
159159

160160
trace = FunctionTrace(_name, group, label, params, terminal, rollup, parent=parent)
161161

162-
if wrapper:
162+
if wrapper: # pylint: disable=W0125,W0126
163163
return wrapper(wrapped, trace)(*args, **kwargs)
164164

165165
with trace:

newrelic/api/graphql_trace.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def _nr_graphql_trace_wrapper_(wrapped, instance, args, kwargs):
116116

117117
trace = GraphQLOperationTrace(parent=parent)
118118

119-
if wrapper:
119+
if wrapper: # pylint: disable=W0125,W0126
120120
return wrapper(wrapped, trace)(*args, **kwargs)
121121

122122
with trace:
@@ -194,7 +194,7 @@ def _nr_graphql_trace_wrapper_(wrapped, instance, args, kwargs):
194194

195195
trace = GraphQLResolverTrace(parent=parent)
196196

197-
if wrapper:
197+
if wrapper: # pylint: disable=W0125,W0126
198198
return wrapper(wrapped, trace)(*args, **kwargs)
199199

200200
with trace:

newrelic/api/memcache_trace.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def _nr_wrapper_memcache_trace_(wrapped, instance, args, kwargs):
7171

7272
trace = MemcacheTrace(_command, parent=parent)
7373

74-
if wrapper:
74+
if wrapper: # pylint: disable=W0125,W0126
7575
return wrapper(wrapped, trace)(*args, **kwargs)
7676

7777
with trace:

newrelic/api/message_trace.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def _nr_message_trace_wrapper_(wrapped, instance, args, kwargs):
134134

135135
trace = MessageTrace(_library, _operation, _destination_type, _destination_name, params={}, parent=parent)
136136

137-
if wrapper:
137+
if wrapper: # pylint: disable=W0125,W0126
138138
return wrapper(wrapped, trace)(*args, **kwargs)
139139

140140
with trace:

newrelic/api/time_trace.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@ def _observe_exception(self, exc_info=None, ignore=None, expected=None, status_c
318318

319319
return fullname, message, tb, is_expected
320320

321-
def notice_error(self, error=None, attributes={}, expected=None, ignore=None, status_code=None):
321+
def notice_error(self, error=None, attributes=None, expected=None, ignore=None, status_code=None):
322+
attributes = attributes if attributes is not None else {}
323+
322324
recorded = self._observe_exception(
323325
error,
324326
ignore=ignore,
@@ -355,7 +357,7 @@ def notice_error(self, error=None, attributes={}, expected=None, ignore=None, st
355357

356358
transaction._create_error_node(settings, fullname, message, is_expected, custom_params, self.guid, tb)
357359

358-
def record_exception(self, exc_info=None, params={}, ignore_errors=[]):
360+
def record_exception(self, exc_info=None, params=None, ignore_errors=None):
359361
# Deprecation Warning
360362
warnings.warn(
361363
("The record_exception function is deprecated. Please use the new api named notice_error instead."),
@@ -563,7 +565,7 @@ def get_linking_metadata():
563565
}
564566

565567

566-
def record_exception(exc=None, value=None, tb=None, params={}, ignore_errors=[], application=None):
568+
def record_exception(exc=None, value=None, tb=None, params=None, ignore_errors=None, application=None):
567569
# Deprecation Warning
568570
warnings.warn(
569571
("The record_exception function is deprecated. Please use the new api named notice_error instead."),
@@ -573,7 +575,7 @@ def record_exception(exc=None, value=None, tb=None, params={}, ignore_errors=[],
573575
notice_error(error=(exc, value, tb), attributes=params, ignore=ignore_errors, application=application)
574576

575577

576-
def notice_error(error=None, attributes={}, expected=None, ignore=None, status_code=None, application=None):
578+
def notice_error(error=None, attributes=None, expected=None, ignore=None, status_code=None, application=None):
577579
if application is None:
578580
trace = current_trace()
579581
if trace:

0 commit comments

Comments
 (0)