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

Fix merge conflicts for develop scikitlearn #922

Merged
merged 33 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
db07523
Exclude command line functionality from test coverage (#855)
lrafeei Jun 27, 2023
c2fd5e3
FIX: resilient environment settings (#825)
aaeabdo Jun 27, 2023
9883c2b
Replace drop_transaction logic by using transaction context manager (…
lrafeei Jun 28, 2023
998b035
Upgrade to Pypy38 for TypedDict (#861)
lrafeei Jun 30, 2023
66c2e19
Add profile_trace testing (#858)
umaannamalai Jun 30, 2023
e663c36
Add Transaction API Tests (#857)
lrafeei Jun 30, 2023
3bdb013
Add tests for jinja2. (#842)
umaannamalai Jun 30, 2023
6644846
Add tests for newrelic/config.py (#860)
hmstepanek Jun 30, 2023
ee92363
Fix starlette testing matrix for updated behavior. (#869)
TimPansino Jul 14, 2023
53fc51a
Correct Serverless Distributed Tracing Logic (#870)
TimPansino Jul 14, 2023
2f580af
Fix Kafka CI (#863)
TimPansino Jul 14, 2023
a7080e9
Change image tag to latest (#871)
hmstepanek Jul 17, 2023
56ea815
Add full version for pypy3.8 to tox (#872)
lrafeei Jul 18, 2023
a248688
Instrument RedisCluster (#809)
hmstepanek Jul 27, 2023
08eec5e
Ignore Django instrumentation from older versions (#859)
lrafeei Jul 28, 2023
4b3768b
Modify postgresql tests to include WITH query (#885)
lrafeei Aug 2, 2023
17f8937
Develop redis addons (#888)
lrafeei Aug 10, 2023
8ebe9a3
Add google firestore instrumentation (#893)
umaannamalai Aug 10, 2023
238b64d
Base Devcontainer on CI Image (#873)
TimPansino Aug 10, 2023
dc87bd3
Add support for redis v5. (#895)
umaannamalai Aug 15, 2023
7d76243
Use importlib.metadata first to avoid deprecation warnings (#878)
renanivo Aug 16, 2023
f1a673e
Fix Normalization Rules (#894)
TimPansino Aug 16, 2023
6a6228f
Fix database instance metric bug (#905)
hmstepanek Aug 18, 2023
62abb45
Add check for both path and file (#907)
hmstepanek Aug 21, 2023
399c81f
Update structlog instrumentation. (#865)
umaannamalai Aug 23, 2023
3988ecc
GraphQL Async Instrumentation Support (#908)
umaannamalai Aug 28, 2023
0baf8d5
Develop swap redis asyncio commits (#913)
lrafeei Aug 28, 2023
faaccd0
Increase days until stale. (#909)
umaannamalai Aug 28, 2023
b1be563
Pin anyio version to below 4.0.0 (#916)
lrafeei Sep 1, 2023
e371b02
Add redis.asyncio.Connection instrumentation (#919)
lrafeei Sep 12, 2023
eff66b5
Update testing matrix for supported packages. (#904)
umaannamalai Sep 14, 2023
1f9c0ac
Merge branch 'main' into develop-scikitlearn
TimPansino Sep 14, 2023
c2d1d57
Correct merge conflicts for develop-sklearn
TimPansino Sep 14, 2023
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
3 changes: 0 additions & 3 deletions .github/containers/install-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ main() {

# Set all installed versions as globally accessible
pyenv global ${PYENV_VERSIONS[@]}

# Install dependencies for main python installation
pyenv exec pip install --upgrade -r /requirements.txt
}

main
106 changes: 54 additions & 52 deletions newrelic/hooks/framework_bottle.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,21 @@

import functools

from newrelic.api.function_trace import (FunctionTrace, FunctionTraceWrapper,
wrap_function_trace)
from newrelic.api.function_trace import (
FunctionTrace,
FunctionTraceWrapper,
wrap_function_trace,
)
from newrelic.api.transaction import current_transaction
from newrelic.api.wsgi_application import wrap_wsgi_application
from newrelic.common.object_names import callable_name
from newrelic.common.object_wrapper import (wrap_out_function,
function_wrapper, ObjectProxy, wrap_object_attribute,
wrap_function_wrapper)
from newrelic.common.object_wrapper import (
ObjectProxy,
function_wrapper,
wrap_function_wrapper,
wrap_object_attribute,
wrap_out_function,
)

module_bottle = None

Expand All @@ -34,17 +41,17 @@ def status_code(exc, value, tb):
# The HTTPError class derives from HTTPResponse and so we do not
# need to check for it seperately as isinstance() will pick it up.

if isinstance(value, module_bottle.HTTPResponse):
if hasattr(value, 'status_code'):
if isinstance(value, module_bottle.HTTPResponse): # pragma: no cover
if hasattr(value, "status_code"):
return value.status_code
elif hasattr(value, 'status'):
elif hasattr(value, "status"):
return value.status
elif hasattr(value, 'http_status_code'):
elif hasattr(value, "http_status_code"):
return value.http_status_code


def should_ignore(exc, value, tb):
if hasattr(module_bottle, 'RouteReset'):
if hasattr(module_bottle, "RouteReset"):
if isinstance(value, module_bottle.RouteReset):
return True

Expand Down Expand Up @@ -113,8 +120,7 @@ def get(self, status, default=None):
transaction.set_transaction_name(name, priority=1)
handler = FunctionTraceWrapper(handler, name=name)
else:
transaction.set_transaction_name(str(status),
group='StatusCode', priority=1)
transaction.set_transaction_name(str(status), group="StatusCode", priority=1)

return handler or default

Expand All @@ -140,43 +146,39 @@ def instrument_bottle(module):
global module_bottle
module_bottle = module

framework_details = ('Bottle', getattr(module, '__version__'))

if hasattr(module.Bottle, 'wsgi'): # version >= 0.9
wrap_wsgi_application(module, 'Bottle.wsgi',
framework=framework_details)
elif hasattr(module.Bottle, '__call__'): # version < 0.9
wrap_wsgi_application(module, 'Bottle.__call__',
framework=framework_details)

if (hasattr(module, 'Route') and
hasattr(module.Route, '_make_callback')): # version >= 0.10
wrap_out_function(module, 'Route._make_callback',
output_wrapper_Route_make_callback)
elif hasattr(module.Bottle, '_match'): # version >= 0.9
wrap_out_function(module, 'Bottle._match',
output_wrapper_Bottle_match)
elif hasattr(module.Bottle, 'match_url'): # version < 0.9
wrap_out_function(module, 'Bottle.match_url',
output_wrapper_Bottle_match)

wrap_object_attribute(module, 'Bottle.error_handler',
proxy_Bottle_error_handler)

if hasattr(module, 'auth_basic'):
wrap_function_wrapper(module, 'auth_basic', wrapper_auth_basic)

if hasattr(module, 'SimpleTemplate'):
wrap_function_trace(module, 'SimpleTemplate.render')

if hasattr(module, 'MakoTemplate'):
wrap_function_trace(module, 'MakoTemplate.render')

if hasattr(module, 'CheetahTemplate'):
wrap_function_trace(module, 'CheetahTemplate.render')

if hasattr(module, 'Jinja2Template'):
wrap_function_trace(module, 'Jinja2Template.render')

if hasattr(module, 'SimpleTALTemplate'):
wrap_function_trace(module, 'SimpleTALTemplate.render')
framework_details = ("Bottle", getattr(module, "__version__"))
# version >= 0.9
if hasattr(module.Bottle, "wsgi"): # pragma: no cover
wrap_wsgi_application(module, "Bottle.wsgi", framework=framework_details)
# version < 0.9
elif hasattr(module.Bottle, "__call__"): # pragma: no cover
wrap_wsgi_application(module, "Bottle.__call__", framework=framework_details)
# version >= 0.10
if hasattr(module, "Route") and hasattr(module.Route, "_make_callback"): # pragma: no cover
wrap_out_function(module, "Route._make_callback", output_wrapper_Route_make_callback)
# version >= 0.9
elif hasattr(module.Bottle, "_match"): # pragma: no cover
wrap_out_function(module, "Bottle._match", output_wrapper_Bottle_match)
# version < 0.9
elif hasattr(module.Bottle, "match_url"): # pragma: no cover
wrap_out_function(module, "Bottle.match_url", output_wrapper_Bottle_match)

wrap_object_attribute(module, "Bottle.error_handler", proxy_Bottle_error_handler)

if hasattr(module, "auth_basic"):
wrap_function_wrapper(module, "auth_basic", wrapper_auth_basic)

if hasattr(module, "SimpleTemplate"):
wrap_function_trace(module, "SimpleTemplate.render")

if hasattr(module, "MakoTemplate"):
wrap_function_trace(module, "MakoTemplate.render")

if hasattr(module, "CheetahTemplate"):
wrap_function_trace(module, "CheetahTemplate.render")

if hasattr(module, "Jinja2Template"):
wrap_function_trace(module, "Jinja2Template.render")

if hasattr(module, "SimpleTALTemplate"): # pragma: no cover
wrap_function_trace(module, "SimpleTALTemplate.render")
48 changes: 25 additions & 23 deletions newrelic/hooks/framework_pyramid.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,29 @@
from newrelic.api.transaction import current_transaction
from newrelic.api.wsgi_application import wrap_wsgi_application
from newrelic.common.object_names import callable_name
from newrelic.common.object_wrapper import (FunctionWrapper, wrap_out_function,
wrap_function_wrapper)
from newrelic.common.object_wrapper import (
FunctionWrapper,
wrap_function_wrapper,
wrap_out_function,
)


def instrument_pyramid_router(module):
pyramid_version = None

try:
import pkg_resources
pyramid_version = pkg_resources.get_distribution('pyramid').version

pyramid_version = pkg_resources.get_distribution("pyramid").version
except Exception:
pass

wrap_wsgi_application(
module, 'Router.__call__', framework=('Pyramid', pyramid_version))
wrap_wsgi_application(module, "Router.__call__", framework=("Pyramid", pyramid_version))


def status_code(exc, value, tb):
from pyramid.httpexceptions import HTTPException

# Ignore certain exceptions based on HTTP status codes.

if isinstance(value, HTTPException):
Expand All @@ -75,6 +79,7 @@ def status_code(exc, value, tb):

def should_ignore(exc, value, tb):
from pyramid.exceptions import PredicateMismatch

# Always ignore PredicateMismatch as it is raised by views to force
# subsequent views to be consulted when multi views are being used.
# It isn't therefore strictly an error as such as a subsequent view
Expand All @@ -100,9 +105,7 @@ def view_handler_wrapper(wrapped, instance, args, kwargs):

# set exception views to priority=1 so they won't take precedence over
# the original view callable
transaction.set_transaction_name(
name,
priority=1 if args and isinstance(args[0], Exception) else 2)
transaction.set_transaction_name(name, priority=1 if args and isinstance(args[0], Exception) else 2)

with FunctionTrace(name, source=view_callable) as trace:
try:
Expand All @@ -114,7 +117,7 @@ def view_handler_wrapper(wrapped, instance, args, kwargs):


def wrap_view_handler(mapped_view):
if hasattr(mapped_view, '_nr_wrapped'):
if hasattr(mapped_view, "_nr_wrapped"): # pragma: no cover
return mapped_view
else:
wrapped = FunctionWrapper(mapped_view, view_handler_wrapper)
Expand Down Expand Up @@ -157,7 +160,7 @@ def _wrapper(context, request):
return wrapper(context, request)
finally:
attr = instance.attr
inst = getattr(request, '__view__', None)
inst = getattr(request, "__view__", None)
if inst is not None:
if attr:
handler = getattr(inst, attr)
Expand All @@ -166,7 +169,7 @@ def _wrapper(context, request):
tracer.name = name
tracer.add_code_level_metrics(handler)
else:
method = getattr(inst, '__call__')
method = getattr(inst, "__call__")
if method:
name = callable_name(method)
transaction.set_transaction_name(name, priority=2)
Expand All @@ -180,22 +183,21 @@ def instrument_pyramid_config_views(module):
# Location of the ViewDeriver class changed from pyramid.config to
# pyramid.config.views so check if present before trying to update.

if hasattr(module, 'ViewDeriver'):
wrap_out_function(module, 'ViewDeriver.__call__', wrap_view_handler)
elif hasattr(module, 'Configurator'):
wrap_out_function(module, 'Configurator._derive_view',
wrap_view_handler)
if hasattr(module, "ViewDeriver"): # pragma: no cover
wrap_out_function(module, "ViewDeriver.__call__", wrap_view_handler)
elif hasattr(module, "Configurator"):
wrap_out_function(module, "Configurator._derive_view", wrap_view_handler)

if hasattr(module, 'DefaultViewMapper'):
if hasattr(module, "DefaultViewMapper"):
module.DefaultViewMapper.map_class_requestonly = FunctionWrapper(
module.DefaultViewMapper.map_class_requestonly,
default_view_mapper_wrapper)
module.DefaultViewMapper.map_class_requestonly, default_view_mapper_wrapper
)
module.DefaultViewMapper.map_class_native = FunctionWrapper(
module.DefaultViewMapper.map_class_native,
default_view_mapper_wrapper)
module.DefaultViewMapper.map_class_native, default_view_mapper_wrapper
)


def instrument_pyramid_config_tweens(module):
wrap_function_wrapper(module, 'Tweens.add_explicit', wrap_add_tween)
wrap_function_wrapper(module, "Tweens.add_explicit", wrap_add_tween)

wrap_function_wrapper(module, 'Tweens.add_implicit', wrap_add_tween)
wrap_function_wrapper(module, "Tweens.add_implicit", wrap_add_tween)
2 changes: 1 addition & 1 deletion newrelic/hooks/logger_loguru.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def patch_loguru_logger(logger):
if not hasattr(logger._core, "_nr_instrumented"):
logger.add(_nr_log_forwarder, format="{message}")
logger._core._nr_instrumented = True
elif not hasattr(logger, "_nr_instrumented"):
elif not hasattr(logger, "_nr_instrumented"): # pragma: no cover
for _, handler in six.iteritems(logger._handlers):
if handler._writer is _nr_log_forwarder:
logger._nr_instrumented = True
Expand Down
8 changes: 3 additions & 5 deletions newrelic/hooks/messagebroker_pika.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@


def _add_consume_rabbitmq_trace(transaction, method, properties, nr_start_time, queue_name=None):

routing_key = None
if hasattr(method, "routing_key"):
routing_key = method.routing_key
Expand Down Expand Up @@ -197,7 +196,7 @@ def _wrap_basic_get_Channel(wrapper, queue, callback, *args, **kwargs):
return queue, args, kwargs


def _wrap_basic_get_Channel_old(wrapper, callback=None, queue="", *args, **kwargs):
def _wrap_basic_get_Channel_old(wrapper, callback=None, queue="", *args, **kwargs): # pragma: no cover
if callback is not None:
callback = wrapper(callback)
args = (callback, queue) + args
Expand Down Expand Up @@ -368,7 +367,6 @@ def callback_wrapper(wrapped, instance, args, kwargs):
correlation_id=correlation_id,
source=wrapped,
) as mt:

# Improve transaction naming
_new_txn_name = "RabbitMQ/Exchange/%s/%s" % (exchange, name)
mt.set_transaction_name(_new_txn_name, group="Message")
Expand Down Expand Up @@ -404,7 +402,7 @@ def instrument_pika_adapters(module):

version = tuple(int(num) for num in pika.__version__.split(".", 1)[0])

if version[0] < 1:
if version[0] < 1: # pragma: no cover
wrap_consume = _wrap_basic_consume_BlockingChannel_old
else:
wrap_consume = _wrap_basic_consume_Channel
Expand All @@ -426,7 +424,7 @@ def instrument_pika_channel(module):

version = tuple(int(num) for num in pika.__version__.split(".", 1)[0])

if version[0] < 1:
if version[0] < 1: # pragma: no cover
wrap_consume = _wrap_basic_consume_Channel_old
wrap_get = _wrap_basic_get_Channel_old
else:
Expand Down
Loading
Loading