diff --git a/Datadog.Trace.sln b/Datadog.Trace.sln index fca5c9a4b65a..9b1deb6736ba 100644 --- a/Datadog.Trace.sln +++ b/Datadog.Trace.sln @@ -589,6 +589,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Generated", "Generated", "{ tracer\build\PackageVersionsLatestSpecific.g.props = tracer\build\PackageVersionsLatestSpecific.g.props EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.AWS.EventBridge", "tracer\test\test-applications\integrations\Samples.AWS.EventBridge\Samples.AWS.EventBridge.csproj", "{D6155F26-8245-4B66-8944-79C3DF9F9DA3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1409,6 +1411,10 @@ Global {2CA0D70C-DFC1-458A-871B-328AB6E87E3A}.Debug|Any CPU.Build.0 = Debug|Any CPU {2CA0D70C-DFC1-458A-871B-328AB6E87E3A}.Release|Any CPU.ActiveCfg = Release|Any CPU {2CA0D70C-DFC1-458A-871B-328AB6E87E3A}.Release|Any CPU.Build.0 = Release|Any CPU + {D6155F26-8245-4B66-8944-79C3DF9F9DA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D6155F26-8245-4B66-8944-79C3DF9F9DA3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D6155F26-8245-4B66-8944-79C3DF9F9DA3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D6155F26-8245-4B66-8944-79C3DF9F9DA3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/tracer/dependabot/Datadog.Dependabot.Integrations.csproj b/tracer/dependabot/Datadog.Dependabot.Integrations.csproj index 1fd3f50207f3..30bb6f348e06 100644 --- a/tracer/dependabot/Datadog.Dependabot.Integrations.csproj +++ b/tracer/dependabot/Datadog.Dependabot.Integrations.csproj @@ -26,6 +26,11 @@ + + + + + diff --git a/tracer/missing-nullability-files.csv b/tracer/missing-nullability-files.csv index a060ea59d9a9..d1dbb091a1c9 100644 --- a/tracer/missing-nullability-files.csv +++ b/tracer/missing-nullability-files.csv @@ -201,6 +201,7 @@ src/Datadog.Trace/Tagging/AspNetCoreMvcTags.cs src/Datadog.Trace/Tagging/AspNetCoreTags.cs src/Datadog.Trace/Tagging/AspNetTags.cs src/Datadog.Trace/Tagging/AwsDynamoDbTags.cs +src/Datadog.Trace/Tagging/AwsEventBridgeTags.cs src/Datadog.Trace/Tagging/AwsKinesisTags.cs src/Datadog.Trace/Tagging/AwsSdkTags.cs src/Datadog.Trace/Tagging/AwsSnsTags.cs diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AWS/AwsEventBridgeTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AWS/AwsEventBridgeTests.cs new file mode 100644 index 000000000000..fc7f1c9666a5 --- /dev/null +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AWS/AwsEventBridgeTests.cs @@ -0,0 +1,93 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Datadog.Trace.Configuration; +using Datadog.Trace.TestHelpers; +using FluentAssertions; +using VerifyXunit; +using Xunit; +using Xunit.Abstractions; + +namespace Datadog.Trace.ClrProfiler.IntegrationTests.AWS +{ + [Trait("RequiresDockerDependency", "true")] + [UsesVerify] + public class AwsEventBridgeTests : TracingIntegrationTest + { + public AwsEventBridgeTests(ITestOutputHelper output) + : base("AWS.EventBridge", output) + { + } + + public static IEnumerable GetEnabledConfig() + => from packageVersionArray in PackageVersions.AwsEventBridge + from metadataSchemaVersion in new[] { "v0", "v1" } + select new[] { packageVersionArray[0], metadataSchemaVersion }; + + public override Result ValidateIntegrationSpan(MockSpan span, string metadataSchemaVersion) => span.Tags["span.kind"] switch + { + SpanKinds.Consumer => span.IsAwsEventBridgeInbound(metadataSchemaVersion), + SpanKinds.Producer => span.IsAwsEventBridgeOutbound(metadataSchemaVersion), + SpanKinds.Client => span.IsAwsEventBridgeRequest(metadataSchemaVersion), + _ => throw new ArgumentException($"span.Tags[\"span.kind\"] is not a supported value for the AWS EventBridge integration: {span.Tags["span.kind"]}", nameof(span)), + }; + + [SkippableTheory] + [MemberData(nameof(GetEnabledConfig))] + [Trait("Category", "EndToEnd")] + public async Task SubmitsTraces(string packageVersion, string metadataSchemaVersion) + { + SetEnvironmentVariable("DD_TRACE_SPAN_ATTRIBUTE_SCHEMA", metadataSchemaVersion); + var isExternalSpan = metadataSchemaVersion == "v0"; + var clientSpanServiceName = isExternalSpan ? $"{EnvironmentHelper.FullSampleName}-aws-eventbridge" : EnvironmentHelper.FullSampleName; + + using var telemetry = this.ConfigureTelemetry(); + using (var agent = EnvironmentHelper.GetMockAgent()) + using (await RunSampleAndWaitForExit(agent, packageVersion: packageVersion)) + { +#if NETFRAMEWORK + var expectedCount = 8; + var frameworkName = "NetFramework"; +#else + var expectedCount = 4; + var frameworkName = "NetCore"; +#endif + var spans = agent.WaitForSpans(expectedCount); + var eventBridgeSpans = spans.Where(span => span.Tags.TryGetValue("component", out var component) && component == "aws-sdk"); + + eventBridgeSpans.Should().NotBeEmpty(); + ValidateIntegrationSpans(eventBridgeSpans, metadataSchemaVersion, expectedServiceName: clientSpanServiceName, isExternalSpan); + + var host = Environment.GetEnvironmentVariable("AWS_SDK_HOST"); + + var settings = VerifyHelper.GetSpanVerifierSettings(); + + settings.UseFileName($"{nameof(AwsEventBridgeTests)}.{frameworkName}.Schema{metadataSchemaVersion.ToUpper()}"); + settings.AddSimpleScrubber("out.host: localhost", "out.host: aws_eventbridge"); + settings.AddSimpleScrubber("out.host: localstack", "out.host: aws_eventbridge"); + settings.AddSimpleScrubber("out.host: localstack_arm64", "out.host: aws_eventbridge"); + settings.AddSimpleScrubber("peer.service: localhost", "peer.service: aws_eventbridge"); + settings.AddSimpleScrubber("peer.service: localstack", "peer.service: aws_eventbridge"); + settings.AddSimpleScrubber("peer.service: localstack_arm64", "peer.service: aws_eventbridge"); + if (!string.IsNullOrWhiteSpace(host)) + { + settings.AddSimpleScrubber(host, "localhost:00000"); + } + + settings.DisableRequireUniquePrefix(); + + // Note: http.request spans are expected for the EventBridge APIs that don't have explicit support + // (Only PutEvents and PutEventsAsync are supported right now) + await VerifyHelper.VerifySpans(spans, settings); + + telemetry.AssertIntegrationEnabled(IntegrationId.AwsEventBridge); + } + } + } +} diff --git a/tracer/test/Datadog.Trace.TestHelpers/SpanMetadataAPI.cs b/tracer/test/Datadog.Trace.TestHelpers/SpanMetadataAPI.cs index 9b64a9b73290..3578b2bdac5c 100644 --- a/tracer/test/Datadog.Trace.TestHelpers/SpanMetadataAPI.cs +++ b/tracer/test/Datadog.Trace.TestHelpers/SpanMetadataAPI.cs @@ -116,6 +116,27 @@ public static Result IsAwsSnsRequest(this MockSpan span, string metadataSchemaVe _ => span.IsAwsSnsRequestV0(), }; + public static Result IsAwsEventBridgeInbound(this MockSpan span, string metadataSchemaVersion) => + metadataSchemaVersion switch + { + "v1" => span.IsAwsEventBridgeInboundV1(), + _ => span.IsAwsEventBridgeRequestV0(), + }; + + public static Result IsAwsEventBridgeOutbound(this MockSpan span, string metadataSchemaVersion) => + metadataSchemaVersion switch + { + "v1" => span.IsAwsEventBridgeOutboundV1(), + _ => span.IsAwsEventBridgeRequestV0(), + }; + + public static Result IsAwsEventBridgeRequest(this MockSpan span, string metadataSchemaVersion) => + metadataSchemaVersion switch + { + "v1" => span.IsAwsEventBridgeRequestV1(), + _ => span.IsAwsEventBridgeRequestV0(), + }; + public static Result IsAzureServiceBusInbound(this MockSpan span, string metadataSchemaVersion, ISet excludeTags = null) => metadataSchemaVersion switch { diff --git a/tracer/test/Datadog.Trace.TestHelpers/SpanMetadataV0Rules.cs b/tracer/test/Datadog.Trace.TestHelpers/SpanMetadataV0Rules.cs index f9fee104ec11..c8d3aa7c8766 100644 --- a/tracer/test/Datadog.Trace.TestHelpers/SpanMetadataV0Rules.cs +++ b/tracer/test/Datadog.Trace.TestHelpers/SpanMetadataV0Rules.cs @@ -216,6 +216,26 @@ public static Result IsAwsSnsRequestV0(this MockSpan span) => Result.FromSpan(sp .Matches("component", "aws-sdk") .Matches("span.kind", "client")); + public static Result IsAwsEventBridgeRequestV0(this MockSpan span) => Result.FromSpan(span) + .Properties(s => s + .Matches(Name, "eventbridge.request") + .Matches(Type, "http")) + .Tags(s => s + .Matches("aws.agent", "dotnet-aws-sdk") + .IsPresent("aws.operation") + .IsOptional("aws.region") + .IsOptional("region") + .IsPresent("aws.requestId") + .Matches("aws.service", "EventBridge") + .Matches("aws_service", "EventBridge") + .IsPresent("eventbusname") + .IsPresent("http.method") + .IsPresent("http.status_code") + .IsPresent("http.url") + .IsOptional("_dd.base_service") + .Matches("component", "aws-sdk") + .Matches("span.kind", "client")); + public static Result IsAzureServiceBusInboundV0(this MockSpan span, ISet excludeTags = null) => Result.FromSpan(span, excludeTags) .Properties(s => s .MatchesOneOf(Name, "servicebus.receive", "servicebus.process", "consumer") diff --git a/tracer/test/Datadog.Trace.TestHelpers/SpanMetadataV1Rules.cs b/tracer/test/Datadog.Trace.TestHelpers/SpanMetadataV1Rules.cs index 00333d1121b6..161308c20063 100644 --- a/tracer/test/Datadog.Trace.TestHelpers/SpanMetadataV1Rules.cs +++ b/tracer/test/Datadog.Trace.TestHelpers/SpanMetadataV1Rules.cs @@ -324,6 +324,69 @@ public static Result IsAwsSnsRequestV1(this MockSpan span) => Result.FromSpan(sp .Matches("component", "aws-sdk") .Matches("span.kind", "client")); + public static Result IsAwsEventBridgeInboundV1(this MockSpan span) => Result.FromSpan(span) + .Properties(s => s + .Matches(Name, "aws.eventbridge.process") + .Matches(Type, "http")) + .Tags(s => s + .Matches("aws.agent", "dotnet-aws-sdk") + .IsPresent("aws.operation") + .IsOptional("aws.region") + .IsOptional("region") + .IsPresent("aws.requestId") + .Matches("aws.service", "EventBridge") + .Matches("aws_service", "EventBridge") + .IsPresent("eventbusname") + .IsPresent("http.method") + .IsPresent("http.status_code") + .IsPresent("http.url") + .IsOptional("_dd.base_service") + .Matches("component", "aws-sdk") + .Matches("span.kind", "consumer")); + + public static Result IsAwsEventBridgeOutboundV1(this MockSpan span) => Result.FromSpan(span) + .Properties(s => s + .Matches(Name, "aws.eventbridge.send") + .Matches(Type, "http")) + .Tags(s => s + .Matches("aws.agent", "dotnet-aws-sdk") + .IsPresent("aws.operation") + .IsOptional("aws.region") + .IsOptional("region") + .IsPresent("aws.requestId") + .Matches("aws.service", "EventBridge") + .Matches("aws_service", "EventBridge") + .IsPresent("eventbusname") + .IsPresent("http.method") + .IsPresent("http.status_code") + .IsPresent("http.url") + .IsPresent("peer.service") + .IsOptional("peer.service.remapped_from") + .MatchesOneOf("_dd.peer.service.source", "eventbusname", "peer.service") + .Matches("component", "aws-sdk") + .Matches("span.kind", "producer")); + + public static Result IsAwsEventBridgeRequestV1(this MockSpan span) => Result.FromSpan(span) + .Properties(s => s + .Matches(Name, "aws.eventbridge.request") + .Matches(Type, "http")) + .Tags(s => s + .Matches("aws.agent", "dotnet-aws-sdk") + .IsPresent("aws.operation") + .IsOptional("aws.region") + .IsOptional("region") + .IsPresent("aws.requestId") + .Matches("aws.service", "EventBridge") + .Matches("aws_service", "EventBridge") + .IsPresent("eventbusname") + .IsPresent("http.method") + .IsPresent("http.status_code") + .IsPresent("http.url") + .IsPresent("peer.service") + .IsOptional("peer.service.remapped_from") + .Matches("component", "aws-sdk") + .Matches("span.kind", "client")); + public static Result IsAzureServiceBusInboundV1(this MockSpan span, ISet excludeTags = null) => Result.FromSpan(span, excludeTags) .Properties(s => s .MatchesOneOf(Name, "servicebus.receive", "servicebus.process", "consumer") diff --git a/tracer/test/snapshots/AwsEventBridgeTests.NetCore.SchemaV0.verified.txt b/tracer/test/snapshots/AwsEventBridgeTests.NetCore.SchemaV0.verified.txt new file mode 100644 index 000000000000..15ad1d449729 --- /dev/null +++ b/tracer/test/snapshots/AwsEventBridgeTests.NetCore.SchemaV0.verified.txt @@ -0,0 +1,99 @@ +[ + { + TraceId: Id_1, + SpanId: Id_2, + Name: async-methods, + Resource: async-methods, + Service: Samples.AWS.EventBridge, + Tags: { + env: integration_tests, + language: dotnet, + runtime-id: Guid_1 + }, + Metrics: { + process_id: 0, + _dd.top_level: 1.0, + _dd.tracer_kr: 1.0, + _sampling_priority_v1: 1.0 + } + }, + { + TraceId: Id_1, + SpanId: Id_3, + Name: http.request, + Resource: POST localhost:00000/, + Service: Samples.AWS.EventBridge-http-client, + Type: http, + ParentId: Id_2, + Tags: { + component: HttpMessageHandler, + env: integration_tests, + http-client-handler-type: System.Net.Http.HttpClientHandler, + http.method: POST, + http.status_code: 200, + http.url: http://localhost:00000/, + language: dotnet, + out.host: aws_eventbridge, + runtime-id: Guid_1, + span.kind: client, + _dd.base_service: Samples.AWS.EventBridge + }, + Metrics: { + _dd.top_level: 1.0 + } + }, + { + TraceId: Id_1, + SpanId: Id_4, + Name: eventbridge.request, + Resource: EventBridge.PutEvents, + Service: Samples.AWS.EventBridge-aws-eventbridge, + Type: http, + ParentId: Id_2, + Tags: { + aws.agent: dotnet-aws-sdk, + aws.operation: PutEvents, + aws.requestId: Guid_2, + aws.service: EventBridge, + aws_service: EventBridge, + component: aws-sdk, + env: integration_tests, + eventbusname: MyEventBus, + http.method: POST, + http.status_code: 200, + http.url: http://localhost:00000/, + language: dotnet, + runtime-id: Guid_1, + span.kind: client, + _dd.base_service: Samples.AWS.EventBridge + }, + Metrics: { + _dd.top_level: 1.0 + } + }, + { + TraceId: Id_1, + SpanId: Id_5, + Name: http.request, + Resource: POST localhost:00000/, + Service: Samples.AWS.EventBridge-http-client, + Type: http, + ParentId: Id_2, + Tags: { + component: HttpMessageHandler, + env: integration_tests, + http-client-handler-type: System.Net.Http.HttpClientHandler, + http.method: POST, + http.status_code: 200, + http.url: http://localhost:00000/, + language: dotnet, + out.host: aws_eventbridge, + runtime-id: Guid_1, + span.kind: client, + _dd.base_service: Samples.AWS.EventBridge + }, + Metrics: { + _dd.top_level: 1.0 + } + } +] \ No newline at end of file diff --git a/tracer/test/snapshots/AwsEventBridgeTests.NetCore.SchemaV1.verified.txt b/tracer/test/snapshots/AwsEventBridgeTests.NetCore.SchemaV1.verified.txt new file mode 100644 index 000000000000..6f7dc36e286e --- /dev/null +++ b/tracer/test/snapshots/AwsEventBridgeTests.NetCore.SchemaV1.verified.txt @@ -0,0 +1,90 @@ +[ + { + TraceId: Id_1, + SpanId: Id_2, + Name: async-methods, + Resource: async-methods, + Service: Samples.AWS.EventBridge, + Tags: { + env: integration_tests, + language: dotnet, + runtime-id: Guid_1 + }, + Metrics: { + process_id: 0, + _dd.top_level: 1.0, + _dd.tracer_kr: 1.0, + _sampling_priority_v1: 1.0 + } + }, + { + TraceId: Id_1, + SpanId: Id_3, + Name: http.client.request, + Resource: POST localhost:00000/, + Service: Samples.AWS.EventBridge, + Type: http, + ParentId: Id_2, + Tags: { + component: HttpMessageHandler, + env: integration_tests, + http-client-handler-type: System.Net.Http.HttpClientHandler, + http.method: POST, + http.status_code: 200, + http.url: http://localhost:00000/, + language: dotnet, + out.host: aws_eventbridge, + peer.service: aws_eventbridge, + span.kind: client, + _dd.peer.service.source: out.host + } + }, + { + TraceId: Id_1, + SpanId: Id_4, + Name: aws.eventbridge.send, + Resource: EventBridge.PutEvents, + Service: Samples.AWS.EventBridge, + Type: http, + ParentId: Id_2, + Tags: { + aws.agent: dotnet-aws-sdk, + aws.operation: PutEvents, + aws.requestId: Guid_2, + aws.service: EventBridge, + aws_service: EventBridge, + component: aws-sdk, + env: integration_tests, + eventbusname: MyEventBus, + http.method: POST, + http.status_code: 200, + http.url: http://localhost:00000/, + language: dotnet, + peer.service: MyEventBus, + span.kind: producer, + _dd.peer.service.source: eventbusname + } + }, + { + TraceId: Id_1, + SpanId: Id_5, + Name: http.client.request, + Resource: POST localhost:00000/, + Service: Samples.AWS.EventBridge, + Type: http, + ParentId: Id_2, + Tags: { + component: HttpMessageHandler, + env: integration_tests, + http-client-handler-type: System.Net.Http.HttpClientHandler, + http.method: POST, + http.status_code: 200, + http.url: http://localhost:00000/, + language: dotnet, + out.host: aws_eventbridge, + peer.service: aws_eventbridge, + span.kind: client, + _dd.peer.service.source: out.host + } + } +] \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/Samples.AWS.EventBridge/AsyncHelpers.cs b/tracer/test/test-applications/integrations/Samples.AWS.EventBridge/AsyncHelpers.cs new file mode 100644 index 000000000000..6b45cb08e631 --- /dev/null +++ b/tracer/test/test-applications/integrations/Samples.AWS.EventBridge/AsyncHelpers.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Amazon.EventBridge; +using Amazon.EventBridge.Model; + +namespace Samples.AWS.EventBridge +{ + static class AsyncHelpers + { + private const string EventBusName = "MyEventBus"; + private const string EventDetail = "{\"foo\":\"bar\"}"; + + public static async Task StartEventBridgeTasks(AmazonEventBridgeClient eventBridgeClient) + { + Console.WriteLine("Beginning Async methods"); + using (var scope = SampleHelpers.CreateScope("async-methods")) + { + await CreateEventBusAsync(eventBridgeClient, EventBusName); + + // Allow time for the resource to be ready + Thread.Sleep(1000); + + await PutEventsAsync(eventBridgeClient, EventBusName); + + await DeleteEventBusAsync(eventBridgeClient, EventBusName); + + // Allow time for the resource to be deleted + Thread.Sleep(1000); + } + } + + private static async Task PutEventsAsync(AmazonEventBridgeClient eventBridgeClient, string eventBusName) + { + var request = new PutEventsRequest + { + Entries = new List + { + new PutEventsRequestEntry + { + Source = "my.app", + DetailType = "appEvent", + Detail = EventDetail, + EventBusName = eventBusName + } + } + }; + + var response = await eventBridgeClient.PutEventsAsync(request); + + Console.WriteLine($"PutEventsAsync(PutEventsRequest) HTTP status code: {response.HttpStatusCode}"); + } + + private static async Task DeleteEventBusAsync(AmazonEventBridgeClient eventBridgeClient, string eventBusName) + { + var deleteEventBusRequest = new DeleteEventBusRequest + { + Name = eventBusName + }; + + var response = await eventBridgeClient.DeleteEventBusAsync(deleteEventBusRequest); + + Console.WriteLine($"DeleteEventBusAsync(DeleteEventBusRequest) HTTP status code: {response.HttpStatusCode}"); + } + + private static async Task CreateEventBusAsync(AmazonEventBridgeClient eventBridgeClient, string eventBusName) + { + var createEventBusRequest = new CreateEventBusRequest + { + Name = eventBusName + }; + + var response = await eventBridgeClient.CreateEventBusAsync(createEventBusRequest); + + Console.WriteLine($"CreateEventBusAsync(CreateEventBusRequest) HTTP status code: {response.HttpStatusCode}"); + } + } +} diff --git a/tracer/test/test-applications/integrations/Samples.AWS.EventBridge/Program.cs b/tracer/test/test-applications/integrations/Samples.AWS.EventBridge/Program.cs new file mode 100644 index 000000000000..248324c875ac --- /dev/null +++ b/tracer/test/test-applications/integrations/Samples.AWS.EventBridge/Program.cs @@ -0,0 +1,41 @@ +using System; +using System.Threading.Tasks; +using Amazon.Runtime; +using Amazon.EventBridge; + +namespace Samples.AWS.EventBridge +{ + public class Program + { + private static async Task Main(string[] args) + { + var eventBridgeClient = GetAmazonEventBridgeClient(); +#if NETFRAMEWORK + SyncHelpers.StartEventBridgeTasks(eventBridgeClient); +#endif + await AsyncHelpers.StartEventBridgeTasks(eventBridgeClient); + } + + private static AmazonEventBridgeClient GetAmazonEventBridgeClient() + { + if (Environment.GetEnvironmentVariable("AWS_ACCESSKEY") is string accessKey && + Environment.GetEnvironmentVariable("AWS_SECRETKEY") is string secretKey && + Environment.GetEnvironmentVariable("AWS_REGION") is string region) + { + var awsCredentials = new BasicAWSCredentials(accessKey, secretKey); + return new AmazonEventBridgeClient(awsCredentials, Amazon.RegionEndpoint.GetBySystemName(region)); + } + else + { + var awsCredentials = new BasicAWSCredentials("x", "x"); + var eventBridgeConfig = new AmazonEventBridgeConfig { ServiceURL = "http://" + Host() }; + return new AmazonEventBridgeClient(awsCredentials, eventBridgeConfig); + } + } + + private static string Host() + { + return Environment.GetEnvironmentVariable("AWS_SDK_HOST") ?? "localhost:4566"; + } + } +} diff --git a/tracer/test/test-applications/integrations/Samples.AWS.EventBridge/Properties/launchSettings.json b/tracer/test/test-applications/integrations/Samples.AWS.EventBridge/Properties/launchSettings.json new file mode 100644 index 000000000000..098764909fce --- /dev/null +++ b/tracer/test/test-applications/integrations/Samples.AWS.EventBridge/Properties/launchSettings.json @@ -0,0 +1,21 @@ +{ + "profiles": { + "Samples.AWS.EventBridge": { + "commandName": "Project", + "environmentVariables": { + "COR_ENABLE_PROFILING": "1", + "COR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "COR_PROFILER_PATH": "$(SolutionDir)shared\\bin\\monitoring-home\\win-x64\\Datadog.Trace.ClrProfiler.Native.dll", + + "CORECLR_ENABLE_PROFILING": "1", + "CORECLR_PROFILER": "{846F5F1C-F9AE-4B07-969E-05C26BC060D8}", + "CORECLR_PROFILER_PATH": "$(SolutionDir)shared\\bin\\monitoring-home\\win-x64\\Datadog.Trace.ClrProfiler.Native.dll", + + "DD_DOTNET_TRACER_HOME": "$(SolutionDir)shared\\bin\\monitoring-home", + "DD_VERSION": "1.0.0" + }, + + "nativeDebugging": false + } + } +} \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/Samples.AWS.EventBridge/Samples.AWS.EventBridge.csproj b/tracer/test/test-applications/integrations/Samples.AWS.EventBridge/Samples.AWS.EventBridge.csproj new file mode 100644 index 000000000000..50b5e8375490 --- /dev/null +++ b/tracer/test/test-applications/integrations/Samples.AWS.EventBridge/Samples.AWS.EventBridge.csproj @@ -0,0 +1,19 @@ + + + + 3.3.100 + + + false + false + + true + + + + + + + + + \ No newline at end of file diff --git a/tracer/test/test-applications/integrations/Samples.AWS.EventBridge/SyncHelpers.cs b/tracer/test/test-applications/integrations/Samples.AWS.EventBridge/SyncHelpers.cs new file mode 100644 index 000000000000..2b01a4f4a3ae --- /dev/null +++ b/tracer/test/test-applications/integrations/Samples.AWS.EventBridge/SyncHelpers.cs @@ -0,0 +1,82 @@ +#if NETFRAMEWORK + +using System; +using System.Collections.Generic; +using System.Threading; +using Amazon.EventBridge; +using Amazon.EventBridge.Model; + +namespace Samples.AWS.EventBridge +{ + static class SyncHelpers + { + private const string EventBusName = "MyEventBus"; + private const string EventDetail = "{\"foo\":\"bar\"}"; + + public static void StartEventBridgeTasks(AmazonEventBridgeClient eventBridgeClient) + { + Console.WriteLine("Beginning Sync methods"); + using (var scope = SampleHelpers.CreateScope("sync-methods")) + { + CreateEventBus(eventBridgeClient, EventBusName); + + // Allow time for the resource to be ready + Thread.Sleep(1000); + + PutEvents(eventBridgeClient, EventBusName); + + DeleteEventBus(eventBridgeClient, EventBusName); + + // Allow time for the resource to be deleted + Thread.Sleep(1000); + } + } + + private static void PutEvents(AmazonEventBridgeClient eventBridgeClient, string eventBusName) + { + var request = new PutEventsRequest + { + Entries = new List + { + new PutEventsRequestEntry + { + Source = "my.app", + DetailType = "appEvent", + Detail = EventDetail, + EventBusName = eventBusName + } + } + }; + + var response = eventBridgeClient.PutEvents(request); + + Console.WriteLine($"PutEvents(PutEventsRequest) HTTP status code: {response.HttpStatusCode}"); + } + + private static void DeleteEventBus(AmazonEventBridgeClient eventBridgeClient, string eventBusName) + { + var deleteEventBusRequest = new DeleteEventBusRequest + { + Name = eventBusName + }; + + var response = eventBridgeClient.DeleteEventBus(deleteEventBusRequest); + + Console.WriteLine($"DeleteEventBus(DeleteEventBusRequest) HTTP status code: {response.HttpStatusCode}"); + } + + private static void CreateEventBus(AmazonEventBridgeClient eventBridgeClient, string eventBusName) + { + var createEventBusRequest = new CreateEventBusRequest + { + Name = eventBusName + }; + + var response = eventBridgeClient.CreateEventBus(createEventBusRequest); + + Console.WriteLine($"CreateEventBus(CreateEventBusRequest) HTTP status code: {response.HttpStatusCode}"); + } + } +} + +#endif