/// <summary>
    /// OnAsyncMethodEnd callback
    /// </summary>
    /// <typeparam name="TTarget">Type of the target</typeparam>
    /// <typeparam name="TExecutionResult">Type of the execution result value</typeparam>
    /// <param name="instance">Instance value, aka `this` of the instrumented method.</param>
    /// <param name="executionResult">ExecutionResult instance</param>
    /// <param name="exception">Exception instance in case the original code threw an exception.</param>
    /// <param name="state">Calltarget state value</param>
    /// <returns>A response value, in an async scenario will be T of Task of T</returns>
    public static TExecutionResult OnAsyncMethodEnd <TTarget, TExecutionResult>(TTarget instance, TExecutionResult executionResult, Exception exception, CallTargetState state)
    {
        Activity activity = state.Activity;

        if (activity is null)
        {
            return(executionResult);
        }

        try
        {
            if (exception != null)
            {
                activity?.SetException(exception);
            }
            else if (state.State is IExecutionContext context)
            {
                GraphQLCommon.RecordExecutionErrorsIfPresent(activity, ErrorType, context.Errors);
            }
        }
        finally
        {
            activity.Dispose();
        }

        return(executionResult);
    }
    /// <summary>
    /// OnMethodEnd callback
    /// </summary>
    /// <typeparam name="TTarget">Type of the target</typeparam>
    /// <typeparam name="TValidationResult">Type of the validation result value</typeparam>
    /// <param name="instance">Instance value, aka `this` of the instrumented method.</param>
    /// <param name="validationResult">IValidationResult instance</param>
    /// <param name="exception">Exception instance in case the original code threw an exception.</param>
    /// <param name="state">Calltarget state value</param>
    /// <returns>A response value, in an async scenario will be T of Task of T</returns>
    public static CallTargetReturn <TValidationResult> OnMethodEnd <TTarget, TValidationResult>(TTarget instance, TValidationResult validationResult, Exception exception, CallTargetState state)
        where TValidationResult : IValidationResult
    {
        Activity activity = state.Activity;

        if (activity is null)
        {
            return(new CallTargetReturn <TValidationResult>(validationResult));
        }

        try
        {
            if (exception != null)
            {
                activity.SetException(exception);
            }
            else
            {
                GraphQLCommon.RecordExecutionErrorsIfPresent(activity, ErrorType, validationResult.Errors);
            }
        }
        finally
        {
            activity.Dispose();
        }

        return(new CallTargetReturn <TValidationResult>(validationResult));
    }
 internal static CallTargetState OnMethodBegin <TTarget, TValidationContext, TRules>(TTarget instance, TValidationContext validationContext, TRules rules)
     where TValidationContext : IValidationContext
 {
     return(new CallTargetState(GraphQLCommon.CreateScopeFromValidate(Tracer.Instance, validationContext.Document.Source?.ToString())));
 }
 /// <summary>
 /// OnMethodBegin callback
 /// </summary>
 /// <typeparam name="TTarget">Type of the target</typeparam>
 /// <typeparam name="TContext">Type of the execution context</typeparam>
 /// <param name="instance">Instance value, aka `this` of the instrumented method.</param>
 /// <param name="context">The execution context of the GraphQL operation.</param>
 /// <returns>CallTarget state value</returns>
 public static CallTargetState OnMethodBegin <TTarget, TContext>(TTarget instance, TContext context)
     where TContext : IExecutionContext
 {
     return(new CallTargetState(activity: GraphQLCommon.CreateActivityFromExecuteAsync(context), state: context));
 }
예제 #5
0
 /// <summary>
 /// OnMethodBegin callback
 /// </summary>
 /// <typeparam name="TTarget">Type of the target</typeparam>
 /// <typeparam name="TContext">Type of the execution context</typeparam>
 /// <param name="instance">Instance value, aka `this` of the instrumented method.</param>
 /// <param name="context">The execution context of the GraphQL operation.</param>
 /// <returns>Calltarget state value</returns>
 internal static CallTargetState OnMethodBegin <TTarget, TContext>(TTarget instance, TContext context)
     where TContext : IExecutionContextV5
 {
     return(new CallTargetState(scope: GraphQLCommon.CreateScopeFromExecuteAsyncV5(Tracer.Instance, context), state: context));
 }
 /// <summary>
 /// OnMethodBegin callback
 /// </summary>
 /// <typeparam name="TTarget">Type of the target</typeparam>
 /// <typeparam name="TSchema">Type of the schema</typeparam>
 /// <typeparam name="TDocument">Type of the document</typeparam>
 /// <typeparam name="TRules">Type of the rules</typeparam>
 /// <typeparam name="TUserContext">Type of the user context</typeparam>
 /// <typeparam name="TInputs">Type of the inputs</typeparam>
 /// <param name="instance">Instance value, aka `this` of the instrumented method.</param>
 /// <param name="originalQuery">The source of the original GraphQL query</param>
 /// <param name="schema">The GraphQL schema value</param>
 /// <param name="document">The GraphQL document value</param>
 /// <param name="rules">The list of validation rules</param>
 /// <param name="userContext">The user context</param>
 /// <param name="inputs">The input variables</param>
 /// <returns>Calltarget state value</returns>
 public static CallTargetState OnMethodBegin <TTarget, TSchema, TDocument, TRules, TUserContext, TInputs>(TTarget instance, string originalQuery, TSchema schema, TDocument document, TRules rules, TUserContext userContext, TInputs inputs)
     where TDocument : IDocument
 {
     return(new CallTargetState(GraphQLCommon.CreateActivityFromValidate(document)));
 }