コード例 #1
0
 private async Task <StartExecutionResponse> StartStepFunctionExecution(string petId, string petType)
 {
     /*
      *
      * // Code to invoke StepFunction through API Gateway
      * var stepFunctionInputModel = new StepFunctionInputModel()
      * {
      *  input = JsonSerializer.Serialize(new SearchParams() {petid = petId, pettype = petType}),
      *  name = $"{petType}-{petId}-{Guid.NewGuid()}",
      *  stateMachineArn = SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration,"petadoptionsstepfnarn")
      * };
      *
      * var content = new StringContent(
      *  JsonSerializer.Serialize(stepFunctionInputModel),
      *  Encoding.UTF8,
      *  "application/json");
      *
      * return await _httpClient.PostAsync(SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration,"petadoptionsstepfnurl"), content);
      *
      */
     // Console.WriteLine($"STEPLOG -ARN - {SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration,"petadoptionsstepfnarn")}");
     //Console.WriteLine($"STEPLOG - SERIALIZE - {JsonSerializer.Serialize(new SearchParams() {petid = petId, pettype = petType})}");
     AWSSDKHandler.RegisterXRay <IAmazonStepFunctions>();
     return(await new AmazonStepFunctionsClient().StartExecutionAsync(new StartExecutionRequest()
     {
         Input = JsonSerializer.Serialize(new SearchParams()
         {
             petid = petId, pettype = petType
         }),
         Name = $"{petType}-{petId}-{Guid.NewGuid()}",
         StateMachineArn = SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration, "petadoptionsstepfnarn")
     }));
 }
コード例 #2
0
        private async Task <PublishResponse> SendNotification(string petId)
        {
            AWSSDKHandler.RegisterXRay <IAmazonService>();

            var snsClient = new AmazonSimpleNotificationServiceClient();

            return(await snsClient.PublishAsync(topicArn : _configuration["snsarn"],
                                                message : $"PetId {petId} was adopted on {DateTime.Now}"));
        }
コード例 #3
0
        private static void ConfigureAwsServices(IServiceCollection services)
        {
            services.AddSingleton <IAmazonSimpleNotificationService, AmazonSimpleNotificationServiceClient>();
            AWSSDKHandler.RegisterXRay <IAmazonSimpleNotificationService>();

            services.AddSingleton <IAmazonCloudWatch, AmazonCloudWatchClient>();
            AWSSDKHandler.RegisterXRay <IAmazonCloudWatch>();

            services.AddSingleton <IAmazonSQS, AmazonSQSClient>();
        }
コード例 #4
0
        private async Task <SendMessageResponse> PostMessageToSqs(string petId, string petType)
        {
            AWSSDKHandler.RegisterXRay <IAmazonSQS>();

            return(await _sqsClient.SendMessageAsync(new SendMessageRequest()
            {
                MessageBody = JsonSerializer.Serialize($"{petId}-{petType}"),
                QueueUrl = SystemsManagerConfigurationProviderWithReloadExtensions.GetConfiguration(_configuration, "queueurl")
            }));
        }
コード例 #5
0
        private async Task <SendMessageResponse> PostMessageToSqs(string petId)
        {
            AWSSDKHandler.RegisterXRay <IAmazonSQS>();
            var sendMessageRequest = new SendMessageRequest()
            {
                MessageBody = JsonSerializer.Serialize(petId),
                QueueUrl    = _configuration["queueurl"]
            };

            return(await _sqsClient.SendMessageAsync(sendMessageRequest));
        }
コード例 #6
0
        public void TestS3SubsegmentNameIsCorrectForAWSSDKHandler()
        {
            AWSSDKHandler.RegisterXRay <IAmazonS3>();
            var s3 = new AmazonS3Client(new AnonymousAWSCredentials(), RegionEndpoint.USEast1);

            CustomResponses.SetResponse(s3, null, null, true);

            AWSXRayRecorder.Instance.BeginSegment("test s3", TraceId);
#if NET45
            s3.GetObject("testBucket", "testKey");
#else
            s3.GetObjectAsync("testBucket", "testKey").Wait();
#endif
            var segment = TraceContext.GetEntity();
            AWSXRayRecorder.Instance.EndSegment();
            Assert.AreEqual("S3", segment.Subsegments[0].Name);
        }
コード例 #7
0
 protected static APIGatewayProxyResponse HandleOptions(Func <APIGatewayProxyResponse> handler)
 {
     AWSSDKHandler.RegisterXRay <IAmazonDynamoDB>();
     AWSSDKHandler.RegisterXRay <IAmazonSimpleDB>();
     AWSSDKHandler.RegisterXRay <ICoreAmazonS3>();
     try
     {
         return(AWSXRayRecorder.Instance.TraceMethod("Handling Request", handler));
     }
     catch (GCUException e)
     {
         return(ResponseHelper.WrapResponse(e.Message, 400));
     }
     catch (Exception e)
     {
         return(ResponseHelper.WrapResponse($"Unexpected Exception : {e.Message}", 500));
     }
 }
コード例 #8
0
ファイル: Function.cs プロジェクト: Jmen/hello-aws-messaging
 public Function()
 {
     AWSXRayRecorder.InitializeInstance();
     AWSSDKHandler.RegisterXRay <IAmazonSimpleNotificationService>();
 }
コード例 #9
0
 public Function()
 {
     AWSXRayRecorder.InitializeInstance();
     AWSSDKHandler.RegisterXRay <IAmazonSQS>();
 }
コード例 #10
0
 public Startup(IConfiguration configuration)
 {
     Configuration = configuration;
     AWSXRayRecorder.InitializeInstance(configuration: Configuration);
     AWSSDKHandler.RegisterXRay <IAmazonDynamoDB>();
 }