public async Task<APIGatewayProxyResponse> InvokeAPIGatewayProxyAsync(
            Func<APIGatewayProxyRequest, ILambdaContext, Task<APIGatewayProxyResponse>> asyncHandler,
            APIGatewayProxyRequest request,
            ILambdaContext context,
            string operationName = null,
            IEnumerable<KeyValuePair<string, string>> tags = null)
        {
            using (var tracker = new TelemetryTracker(context, operationName, tags, request.Headers))
            {
                try
                {
                    APIGatewayProxyResponse apiGatewayProxyResponse = await asyncHandler(request, context);
                    if (!apiGatewayProxyResponse.IsSuccessStatusCode())
                    {
                        tracker.SetErrorCounter();

                        // Preserve the legacy logging.
                        LambdaLogger.Log($"[ERR] Invoking lambda function. Http status code: {apiGatewayProxyResponse.StatusCode}. Response body: {apiGatewayProxyResponse.Body}{Environment.NewLine}");
                    }

                    return apiGatewayProxyResponse;
                }
                catch (Exception e)
                {
                    tracker.SetException(e);
                    throw;
                }
            }
        }
        public async Task <APIGatewayHttpApiV2ProxyResponse> InvokeAPIGatewayHttpApiV2ProxyAsync(
            Func <APIGatewayHttpApiV2ProxyRequest, ILambdaContext, Task <APIGatewayHttpApiV2ProxyResponse> > asyncHandler,
            APIGatewayHttpApiV2ProxyRequest request,
            ILambdaContext context,
            string operationName = null,
            IDictionary <string, string> tags = null)
        {
            IHeadersCollection headersCollection = null;

            if (TelemetryConfiguration.ContextPropagationEnabled)
            {
                headersCollection = new CommaDelimitedValueHeaders(request.Headers);
            }

            using (var tracker = new TelemetryTracker(context, operationName, tags, headersCollection))
            {
                try
                {
                    APIGatewayHttpApiV2ProxyResponse apiGatewayProxyResponse = await asyncHandler(request, context);

                    if (!apiGatewayProxyResponse.IsSuccessStatusCode())
                    {
                        tracker.SetErrorCounter();

                        // Preserve the legacy logging.
                        LambdaLogger.Log($"[ERR] Invoking lambda function. Http status code: {apiGatewayProxyResponse.StatusCode}. Response body: {apiGatewayProxyResponse.Body}{Environment.NewLine}");
                    }

                    return(apiGatewayProxyResponse);
                }
                catch (Exception e)
                {
                    tracker.SetException(e);
                    throw;
                }
            }
        }