Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 0 additions & 22 deletions newrelic/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,16 @@
from newrelic.api.time_trace import current_trace as __current_trace
from newrelic.api.time_trace import get_linking_metadata as __get_linking_metadata
from newrelic.api.time_trace import notice_error as __notice_error
from newrelic.api.time_trace import record_exception as __record_exception
from newrelic.api.transaction import accept_distributed_trace_headers as __accept_distributed_trace_headers
from newrelic.api.transaction import accept_distributed_trace_payload as __accept_distributed_trace_payload
from newrelic.api.transaction import add_custom_attribute as __add_custom_attribute
from newrelic.api.transaction import add_custom_attributes as __add_custom_attributes
from newrelic.api.transaction import add_custom_parameter as __add_custom_parameter
from newrelic.api.transaction import add_custom_parameters as __add_custom_parameters
from newrelic.api.transaction import add_framework_info as __add_framework_info
from newrelic.api.transaction import capture_request_params as __capture_request_params
from newrelic.api.transaction import create_distributed_trace_payload as __create_distributed_trace_payload
from newrelic.api.transaction import current_span_id as __current_span_id
from newrelic.api.transaction import current_trace_id as __current_trace_id
from newrelic.api.transaction import current_transaction as __current_transaction
from newrelic.api.transaction import disable_browser_autorum as __disable_browser_autorum
from newrelic.api.transaction import end_of_transaction as __end_of_transaction
from newrelic.api.transaction import get_browser_timing_footer as __get_browser_timing_footer
from newrelic.api.transaction import get_browser_timing_header as __get_browser_timing_header
from newrelic.api.transaction import ignore_transaction as __ignore_transaction
from newrelic.api.transaction import insert_distributed_trace_headers as __insert_distributed_trace_headers
Expand Down Expand Up @@ -101,8 +95,6 @@ def __asgi_application(*args, **kwargs):
from newrelic.api.generator_trace import wrap_generator_trace as __wrap_generator_trace
from newrelic.api.html_insertion import insert_html_snippet as __insert_html_snippet
from newrelic.api.html_insertion import verify_body_exists as __verify_body_exists
from newrelic.api.lambda_handler import LambdaHandlerWrapper as __LambdaHandlerWrapper
from newrelic.api.lambda_handler import lambda_handler as __lambda_handler
from newrelic.api.llm_custom_attributes import WithLlmCustomAttributes as __WithLlmCustomAttributes
from newrelic.api.message_trace import MessageTrace as __MessageTrace
from newrelic.api.message_trace import MessageTraceWrapper as __MessageTraceWrapper
Expand Down Expand Up @@ -133,7 +125,6 @@ def __asgi_application(*args, **kwargs):
from newrelic.common.object_wrapper import FunctionWrapper as __FunctionWrapper
from newrelic.common.object_wrapper import InFunctionWrapper as __InFunctionWrapper
from newrelic.common.object_wrapper import ObjectProxy as __ObjectProxy
from newrelic.common.object_wrapper import ObjectWrapper as __ObjectWrapper
from newrelic.common.object_wrapper import OutFunctionWrapper as __OutFunctionWrapper
from newrelic.common.object_wrapper import PostFunctionWrapper as __PostFunctionWrapper
from newrelic.common.object_wrapper import PreFunctionWrapper as __PreFunctionWrapper
Expand Down Expand Up @@ -178,15 +169,11 @@ def __asgi_application(*args, **kwargs):
ignore_transaction = __wrap_api_call(__ignore_transaction, "ignore_transaction")
suppress_apdex_metric = __wrap_api_call(__suppress_apdex_metric, "suppress_apdex_metric")
capture_request_params = __wrap_api_call(__capture_request_params, "capture_request_params")
add_custom_parameter = __wrap_api_call(__add_custom_parameter, "add_custom_parameter")
add_custom_parameters = __wrap_api_call(__add_custom_parameters, "add_custom_parameters")
add_custom_attribute = __wrap_api_call(__add_custom_attribute, "add_custom_attribute")
add_custom_attributes = __wrap_api_call(__add_custom_attributes, "add_custom_attributes")
add_framework_info = __wrap_api_call(__add_framework_info, "add_framework_info")
record_exception = __wrap_api_call(__record_exception, "record_exception")
notice_error = __wrap_api_call(__notice_error, "notice_error")
get_browser_timing_header = __wrap_api_call(__get_browser_timing_header, "get_browser_timing_header")
get_browser_timing_footer = __wrap_api_call(__get_browser_timing_footer, "get_browser_timing_footer")
disable_browser_autorum = __wrap_api_call(__disable_browser_autorum, "disable_browser_autorum")
suppress_transaction_trace = __wrap_api_call(__suppress_transaction_trace, "suppress_transaction_trace")
record_custom_metric = __wrap_api_call(__record_custom_metric, "record_custom_metric")
Expand All @@ -195,12 +182,6 @@ def __asgi_application(*args, **kwargs):
record_log_event = __wrap_api_call(__record_log_event, "record_log_event")
record_ml_event = __wrap_api_call(__record_ml_event, "record_ml_event")
WithLlmCustomAttributes = __wrap_api_call(__WithLlmCustomAttributes, "WithLlmCustomAttributes")
accept_distributed_trace_payload = __wrap_api_call(
__accept_distributed_trace_payload, "accept_distributed_trace_payload"
)
create_distributed_trace_payload = __wrap_api_call(
__create_distributed_trace_payload, "create_distributed_trace_payload"
)
accept_distributed_trace_headers = __wrap_api_call(
__accept_distributed_trace_headers, "accept_distributed_trace_headers"
)
Expand All @@ -223,8 +204,6 @@ def __asgi_application(*args, **kwargs):
BackgroundTask = __wrap_api_call(__BackgroundTask, "BackgroundTask")
BackgroundTaskWrapper = __wrap_api_call(__BackgroundTaskWrapper, "BackgroundTaskWrapper")
wrap_background_task = __wrap_api_call(__wrap_background_task, "wrap_background_task")
LambdaHandlerWrapper = __wrap_api_call(__LambdaHandlerWrapper, "LambdaHandlerWrapper")
lambda_handler = __wrap_api_call(__lambda_handler, "lambda_handler")
NewRelicContextFormatter = __wrap_api_call(__NewRelicContextFormatter, "NewRelicContextFormatter")
transaction_name = __wrap_api_call(__transaction_name, "transaction_name")
TransactionNameWrapper = __wrap_api_call(__TransactionNameWrapper, "TransactionNameWrapper")
Expand Down Expand Up @@ -275,7 +254,6 @@ def __asgi_application(*args, **kwargs):
function_wrapper = __wrap_api_call(__function_wrapper, "function_wrapper")
wrap_function_wrapper = __wrap_api_call(__wrap_function_wrapper, "wrap_function_wrapper")
patch_function_wrapper = __wrap_api_call(__patch_function_wrapper, "patch_function_wrapper")
ObjectWrapper = __wrap_api_call(__ObjectWrapper, "ObjectWrapper")
pre_function = __wrap_api_call(__pre_function, "pre_function")
PreFunctionWrapper = __wrap_api_call(__PreFunctionWrapper, "PreFunctionWrapper")
wrap_pre_function = __wrap_api_call(__wrap_pre_function, "wrap_pre_function")
Expand Down
11 changes: 0 additions & 11 deletions newrelic/api/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import threading
import warnings

import newrelic.api.import_hook
import newrelic.core.agent
Expand Down Expand Up @@ -110,16 +109,6 @@ 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=None, ignore_errors=None):
# Deprecation Warning
warnings.warn(
("The record_exception function is deprecated. Please use the new api named notice_error instead."),
DeprecationWarning,
stacklevel=2,
)

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

def notice_error(self, error=None, attributes=None, expected=None, ignore=None, status_code=None):
if not self.active:
return
Expand Down
37 changes: 8 additions & 29 deletions newrelic/api/error_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,21 @@
# limitations under the License.

import functools
import warnings

from newrelic.api.time_trace import current_trace, notice_error
from newrelic.common.object_wrapper import FunctionWrapper, wrap_object


class ErrorTrace:
def __init__(self, ignore_errors=None, ignore=None, expected=None, status_code=None, parent=None):
if ignore_errors is None:
ignore_errors = []
def __init__(self, ignore=None, expected=None, status_code=None, parent=None):
if parent is None:
parent = current_trace()

self._transaction = parent and parent.transaction
self._ignore = ignore if ignore is not None else ignore_errors
self._ignore = ignore
self._expected = expected
self._status_code = status_code

if ignore_errors:
warnings.warn(
("The ignore_errors argument is deprecated. Please use the new ignore argument instead."),
DeprecationWarning,
stacklevel=2,
)

def __enter__(self):
return self

Expand All @@ -53,33 +43,22 @@ def __exit__(self, exc, value, tb):
)


def ErrorTraceWrapper(wrapped, ignore_errors=None, ignore=None, expected=None, status_code=None):
if ignore_errors is None:
ignore_errors = []

def ErrorTraceWrapper(wrapped, ignore=None, expected=None, status_code=None):
def wrapper(wrapped, instance, args, kwargs):
parent = current_trace()

if parent is None:
return wrapped(*args, **kwargs)

with ErrorTrace(ignore_errors, ignore, expected, status_code, parent=parent):
with ErrorTrace(ignore, expected, status_code, parent=parent):
return wrapped(*args, **kwargs)

return FunctionWrapper(wrapped, wrapper)


def error_trace(ignore_errors=None, ignore=None, expected=None, status_code=None):
if ignore_errors is None:
ignore_errors = []

return functools.partial(
ErrorTraceWrapper, ignore_errors=ignore_errors, ignore=ignore, expected=expected, status_code=status_code
)

def error_trace(ignore=None, expected=None, status_code=None):
return functools.partial(ErrorTraceWrapper, ignore=ignore, expected=expected, status_code=status_code)

def wrap_error_trace(module, object_path, ignore_errors=None, ignore=None, expected=None, status_code=None):
if ignore_errors is None:
ignore_errors = []

wrap_object(module, object_path, ErrorTraceWrapper, (ignore_errors, ignore, expected, status_code))
def wrap_error_trace(module, object_path, ignore=None, expected=None, status_code=None):
wrap_object(module, object_path, ErrorTraceWrapper, (ignore, expected, status_code))
17 changes: 0 additions & 17 deletions newrelic/api/in_function.py

This file was deleted.

171 changes: 0 additions & 171 deletions newrelic/api/lambda_handler.py

This file was deleted.

Loading