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") })); }
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}")); }
private static void ConfigureAwsServices(IServiceCollection services) { services.AddSingleton <IAmazonSimpleNotificationService, AmazonSimpleNotificationServiceClient>(); AWSSDKHandler.RegisterXRay <IAmazonSimpleNotificationService>(); services.AddSingleton <IAmazonCloudWatch, AmazonCloudWatchClient>(); AWSSDKHandler.RegisterXRay <IAmazonCloudWatch>(); services.AddSingleton <IAmazonSQS, AmazonSQSClient>(); }
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") })); }
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)); }
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); }
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)); } }
public Function() { AWSXRayRecorder.InitializeInstance(); AWSSDKHandler.RegisterXRay <IAmazonSimpleNotificationService>(); }
public Function() { AWSXRayRecorder.InitializeInstance(); AWSSDKHandler.RegisterXRay <IAmazonSQS>(); }
public Startup(IConfiguration configuration) { Configuration = configuration; AWSXRayRecorder.InitializeInstance(configuration: Configuration); AWSSDKHandler.RegisterXRay <IAmazonDynamoDB>(); }