public AfterWrappedMethodDelegate BeforeWrappedMethod(InstrumentedMethodCall instrumentedMethodCall, IAgent agent, ITransaction transaction)
        {
            if (instrumentedMethodCall.IsAsync)
            {
                transaction.AttachToAsync();
            }

            var restClient  = instrumentedMethodCall.MethodCall.InvocationTarget;
            var restRequest = instrumentedMethodCall.MethodCall.MethodArguments[0];

            Uri uri;

            try
            {
                uri = RestSharpHelper.BuildUri(restClient, restRequest);
            }
            catch (Exception)
            {
                //BuildUri will throw an exception in RestSharp if the user does not have BaseUrl set.
                //Since the request will never execute, we will just NoOp.
                return(Delegates.NoOp);
            }

            var method = RestSharpHelper.GetMethod(restRequest).ToString();

            var transactionExperimental = transaction.GetExperimentalApi();

            var externalSegmentData = transactionExperimental.CreateExternalSegmentData(uri, method);
            var segment             = agent.CurrentTransaction.StartExternalRequestSegment(instrumentedMethodCall.MethodCall, uri, method);

            segment.GetExperimentalApi().SetSegmentData(externalSegmentData);

            return(Delegates.GetAsyncDelegateFor <Task>(agent, segment, true, InvokeTryProcessResponse));

            void InvokeTryProcessResponse(Task completedTask)
            {
                TryProcessResponse(agent, completedTask, transaction, segment, externalSegmentData);
            }
        }