def test_celery_tasks_ignore_transaction(): """ No transaction is recorded, due to the call to ignore_transaction(), so no validation fixture is used. The purpose of this test is to make sure the agent doesn't throw an error. """ add_result = add(1, 2) assert add_result == 3 ignore_transaction() tsum_result = tsum([1, 2, 3]) assert tsum_result == 6
def wrap_execute_operation(wrapped, instance, args, kwargs): transaction = current_transaction() trace = current_trace() if not transaction: return wrapped(*args, **kwargs) if not isinstance(trace, GraphQLOperationTrace): _logger.warning( "Runtime instrumentation warning. GraphQL operation found without active GraphQLOperationTrace." ) return wrapped(*args, **kwargs) try: operation = bind_operation_v3(*args, **kwargs) except TypeError: try: operation = bind_operation_v2(*args, **kwargs) except TypeError: return wrapped(*args, **kwargs) if graphql_version() < (3, 0): execution_context = args[0] else: execution_context = instance trace.operation_name = get_node_value(operation, "name") or "<anonymous>" trace.operation_type = get_node_value(operation, "operation", "name").lower() or "<unknown>" if operation.selection_set is not None: fields = operation.selection_set.selections # Ignore transactions for introspection queries for field in fields: if get_node_value(field, "name") in GRAPHQL_INTROSPECTION_FIELDS: ignore_transaction() fragments = execution_context.fragments trace.deepest_path = ".".join(traverse_deepest_unique_path(fields, fragments)) or "" transaction.set_transaction_name(callable_name(wrapped), "GraphQL", priority=11) result = wrapped(*args, **kwargs) if not execution_context.errors: if hasattr(trace, "set_transaction_name"): # Operation trace sets transaction name trace.set_transaction_name(priority=14) return result
def _nr_aiohttp_wrap_system_route_(wrapped, instance, args, kwargs): ignore_transaction() return wrapped(*args, **kwargs)
def test(): ignore_transaction() exercise_record_log_event()