-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
640 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AWS/AwsEventBridgeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// <copyright file="AwsEventBridgeTests.cs" company="Datadog"> | ||
// 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. | ||
// </copyright> | ||
|
||
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<object[]> 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); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
tracer/test/snapshots/AwsEventBridgeTests.NetCore.SchemaV0.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} | ||
] |
Oops, something went wrong.