-
Notifications
You must be signed in to change notification settings - Fork 147
/
Copy pathGoogleProtobufTests.cs
90 lines (79 loc) · 3.39 KB
/
GoogleProtobufTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// <copyright file="GoogleProtobufTests.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.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Datadog.Trace.Configuration;
using Datadog.Trace.TestHelpers;
using FluentAssertions;
using FluentAssertions.Execution;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming
#pragma warning disable SA1402 // File may only contain a single type
namespace Datadog.Trace.ClrProfiler.IntegrationTests;
[UsesVerify]
public class GoogleProtobufTests : TracingIntegrationTest
{
public GoogleProtobufTests(ITestOutputHelper output)
: base("GoogleProtobuf", output)
{
}
public static IEnumerable<object[]> GetEnabledConfig()
{
return from metadataSchemaVersion in new[] { "v0", "v1" }
select new[] { metadataSchemaVersion };
}
public override Result ValidateIntegrationSpan(MockSpan span, string metadataSchemaVersion)
{
return span.IsProtobuf(metadataSchemaVersion);
}
[SkippableTheory]
[MemberData(nameof(GetEnabledConfig))]
[Trait("Category", "EndToEnd")]
public async Task TagTraces(string metadataSchemaVersion)
{
using var telemetry = this.ConfigureTelemetry();
using var agent = EnvironmentHelper.GetMockAgent();
using (await RunSampleAndWaitForExit(agent, $"{TestPrefix}"))
{
using var assertionScope = new AssertionScope();
var spans = agent.WaitForSpans(2);
ValidateIntegrationSpans(spans, metadataSchemaVersion, "Samples.GoogleProtobuf", isExternalSpan: true);
var settings = VerifyHelper.GetSpanVerifierSettings();
var filename = $"{nameof(GoogleProtobufTests)}";
// Default sorting isn't very reliable, so use our own (adds in name and resource)
await VerifyHelper.VerifySpans(
spans,
settings,
s => s
.OrderBy(x => VerifyHelper.GetRootSpanResourceName(x, spans))
.ThenBy(x => VerifyHelper.GetSpanDepth(x, spans))
.ThenBy(x => x.Name)
.ThenBy(x => x.Resource)
.ThenBy(x => x.Start)
.ThenBy(x => x.Duration))
.UseFileName(filename + $".Schema{metadataSchemaVersion.ToUpper()}")
.DisableRequireUniquePrefix();
}
}
[Fact]
[Trait("Category", "EndToEnd")]
public async Task OnlyEnabledWithDsm()
{
SetEnvironmentVariable(ConfigurationKeys.DataStreamsMonitoring.Enabled, "0");
using var telemetry = this.ConfigureTelemetry();
using var agent = EnvironmentHelper.GetMockAgent();
using (await RunSampleAndWaitForExit(agent, $"{TestPrefix}"))
{
var spans = agent.WaitForSpans(2);
foreach (var span in spans)
{
span.Tags.Should().NotContain(t => t.Key.StartsWith("schema."));
}
}
}
}