Skip to content

Commit

Permalink
Distributed Tracing by Default (#379)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
5 people authored Sep 22, 2021
1 parent a1bf688 commit ee7d053
Show file tree
Hide file tree
Showing 38 changed files with 3,351 additions and 3,278 deletions.
25 changes: 12 additions & 13 deletions newrelic/api/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
import threading
import warnings

import newrelic.core.config
import newrelic.core.agent
import newrelic.api.import_hook

import newrelic.core.agent
import newrelic.core.config
import newrelic.packages.six as six


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

self._agent.activate_application(self._name, self._linked, timeout,
newrelic.api.import_hook._uninstrumented_modules)
self._agent.activate_application(
self._name, self._linked, timeout, newrelic.api.import_hook._uninstrumented_modules
)

def shutdown(self):
pass
Expand All @@ -112,17 +112,16 @@ def linked_applications(self):
def link_to_application(self, name):
self._linked[name] = True

def record_exception(self, exc=None, value=None, tb=None, params={},
ignore_errors=[]):
def record_exception(self, exc=None, value=None, tb=None, params=None, ignore_errors=None):
# Deprecation Warning
warnings.warn((
'The record_exception function is deprecated. Please use the '
'new api named notice_error instead.'
), DeprecationWarning)
warnings.warn(
("The record_exception function is deprecated. Please use the " "new api named notice_error instead."),
DeprecationWarning,
)

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

def notice_error(self, error=None, attributes={}, expected=None, ignore=None, status_code=None):
def notice_error(self, error=None, attributes=None, expected=None, ignore=None, status_code=None):
if not self.active:
return

Expand Down Expand Up @@ -151,7 +150,7 @@ def record_transaction(self, data):
if self.active:
self._agent.record_transaction(self._name, data)

def normalize_name(self, name, rule_type='url'):
def normalize_name(self, name, rule_type="url"):
if self.active:
return self._agent.normalize_name(self._name, name, rule_type)
return name, False
Expand Down
2 changes: 1 addition & 1 deletion newrelic/api/database_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def _nr_database_trace_wrapper_(wrapped, instance, args, kwargs):

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

if wrapper:
if wrapper: # pylint: disable=W0125,W0126
return wrapper(wrapped, trace)(*args, **kwargs)

with trace:
Expand Down
2 changes: 1 addition & 1 deletion newrelic/api/datastore_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def _nr_datastore_trace_wrapper_(wrapped, instance, args, kwargs):

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

if wrapper:
if wrapper: # pylint: disable=W0125,W0126
return wrapper(wrapped, trace)(*args, **kwargs)

with trace:
Expand Down
5 changes: 2 additions & 3 deletions newrelic/api/external_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def dynamic_wrapper(wrapped, instance, args, kwargs):

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

if wrapper:
if wrapper: # pylint: disable=W0125,W0126
return wrapper(wrapped, trace)(*args, **kwargs)

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

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

wrapper = async_wrapper(wrapped)
if wrapper:
if wrapper: # pylint: disable=W0125,W0126
return wrapper(wrapped, trace)(*args, **kwargs)

with trace:
Expand Down
6 changes: 3 additions & 3 deletions newrelic/api/function_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, name, group=None, label=None, params=None, terminal=False, ro
self.params = params

self.terminal = terminal
self.rollup = terminal and rollup or None
self.rollup = rollup if terminal else None

def __enter__(self):
result = TimeTrace.__enter__(self)
Expand Down Expand Up @@ -140,7 +140,7 @@ def dynamic_wrapper(wrapped, instance, args, kwargs):

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

if wrapper:
if wrapper: # pylint: disable=W0125,W0126
return wrapper(wrapped, trace)(*args, **kwargs)

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

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

if wrapper:
if wrapper: # pylint: disable=W0125,W0126
return wrapper(wrapped, trace)(*args, **kwargs)

with trace:
Expand Down
4 changes: 2 additions & 2 deletions newrelic/api/graphql_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _nr_graphql_trace_wrapper_(wrapped, instance, args, kwargs):

trace = GraphQLOperationTrace(parent=parent)

if wrapper:
if wrapper: # pylint: disable=W0125,W0126
return wrapper(wrapped, trace)(*args, **kwargs)

with trace:
Expand Down Expand Up @@ -194,7 +194,7 @@ def _nr_graphql_trace_wrapper_(wrapped, instance, args, kwargs):

trace = GraphQLResolverTrace(parent=parent)

if wrapper:
if wrapper: # pylint: disable=W0125,W0126
return wrapper(wrapped, trace)(*args, **kwargs)

with trace:
Expand Down
2 changes: 1 addition & 1 deletion newrelic/api/memcache_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _nr_wrapper_memcache_trace_(wrapped, instance, args, kwargs):

trace = MemcacheTrace(_command, parent=parent)

if wrapper:
if wrapper: # pylint: disable=W0125,W0126
return wrapper(wrapped, trace)(*args, **kwargs)

with trace:
Expand Down
2 changes: 1 addition & 1 deletion newrelic/api/message_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _nr_message_trace_wrapper_(wrapped, instance, args, kwargs):

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

if wrapper:
if wrapper: # pylint: disable=W0125,W0126
return wrapper(wrapped, trace)(*args, **kwargs)

with trace:
Expand Down
10 changes: 6 additions & 4 deletions newrelic/api/time_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,9 @@ def _observe_exception(self, exc_info=None, ignore=None, expected=None, status_c

return fullname, message, tb, is_expected

def notice_error(self, error=None, attributes={}, expected=None, ignore=None, status_code=None):
def notice_error(self, error=None, attributes=None, expected=None, ignore=None, status_code=None):
attributes = attributes if attributes is not None else {}

recorded = self._observe_exception(
error,
ignore=ignore,
Expand Down Expand Up @@ -355,7 +357,7 @@ def notice_error(self, error=None, attributes={}, expected=None, ignore=None, st

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

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


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


def notice_error(error=None, attributes={}, expected=None, ignore=None, status_code=None, application=None):
def notice_error(error=None, attributes=None, expected=None, ignore=None, status_code=None, application=None):
if application is None:
trace = current_trace()
if trace:
Expand Down
Loading

0 comments on commit ee7d053

Please sign in to comment.