newrelic / newrelic-python-agent

New Relic Python Agent
https://docs.newrelic.com/docs/agents/python-agent
Apache License 2.0
178 stars 103 forks source link

GQL ariadne hook throws blocking error #814

Open jollysahil opened 1 year ago

jollysahil commented 1 year ago

Description Ariadne GQL execute wrapper throws an unhandled error. The same GQL operation succeeds when newrelic is disabled.

Expected Behavior

  1. There shouldn't be an error thrown
  2. Errors in wrappers should be handled and not block critical operations

Troubleshooting or NR Diag results

Traceback (most recent call last):
 File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1820, in full_dispatch_request
 rv = self.dispatch_request()
 File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1796, in dispatch_request
 return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
 File "/usr/local/lib/python3.10/site-packages/newrelic/hooks/framework_flask.py", line 82, in _nr_wrapper_handler_
 return wrapped(*args, **kwargs)
 File "/usr/local/lib/python3.10/site-packages/flask_restful/__init__.py", line 467, in wrapper
 resp = resource(*args, **kwargs)
 File "/usr/local/lib/python3.10/site-packages/flask/views.py", line 107, in view
 return current_app.ensure_sync(self.dispatch_request)(**kwargs)
 File "/usr/local/lib/python3.10/site-packages/flask_restful/__init__.py", line 582, in dispatch_request
 resp = meth(*args, **kwargs)
 File "/app/alpha/blueprints/graphql/graphql.py", line 43, in post
 success, result = ariadne.graphql_sync(
 File "/usr/local/lib/python3.10/site-packages/newrelic/hooks/framework_ariadne.py", line 66, in wrap_graphql_sync
 return wrapped(*args, **kwargs)
 File "/usr/local/lib/python3.10/site-packages/ariadne/graphql.py", line 183, in graphql_sync
 result = execute_sync(
 File "/usr/local/lib/python3.10/site-packages/graphql/execution/execute.py", line 1082, in execute_sync
 result = execute(
 File "/usr/local/lib/python3.10/site-packages/graphql/execution/execute.py", line 1030, in execute
 result = exe_context.execute_operation(operation, root_value)
 File "/usr/local/lib/python3.10/site-packages/newrelic/hooks/framework_graphql.py", line 143, in wrap_execute_operation
 trace.deepest_path = ".".join(traverse_deepest_unique_path(fields, fragments)) or ""
 TypeError: sequence item 1: expected str instance, NoneType found

Steps to Reproduce Not all GQL operations are failing due to this, I cannot share our specific operations

Your Environment newrelic==8.8.0 ariadne==0.19 graphql-core==3.2.1 Flask==2.2.2

newrelic.config

files:
  "/etc/newrelic-infra.yml" :
    mode: "000644"
    owner: root
    group: root
    content: |
      license_key: <redacted>

commands:
# Create the agent’s yum repository
  "01-agent-repository":
    command: sudo curl -o /etc/yum.repos.d/newrelic-infra.repo https://download.newrelic.com/infrastructure_agent/linux/yum/amazonlinux/2/x86_64/newrelic-infra.repo
#
# Update your yum cache
  "02-update-yum-cache":
    command: yum -q makecache -y --disablerepo='*' --enablerepo='newrelic-infra'
#
# Run the installation script
  "03-run-installation-script":
    command: sudo yum install newrelic-infra -y

newrelic.ini

distributed_tracing.enabled = true
monitor_mode = true
log_level = info
ssl = true
high_security = false
transaction_tracer.enabled = true
transaction_tracer.transaction_threshold = apdex_f
transaction_tracer.record_sql = obfuscated
transaction_tracer.stack_trace_threshold = 0.5
transaction_tracer.explain_enabled = true
transaction_tracer.explain_threshold = 0.5
error_collector.enabled = true
browser_monitoring.auto_instrument = true
thread_profiler.enabled = true

Additional context

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.