-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathHttpNetFrameworkTests.cs
55 lines (43 loc) · 2.06 KB
/
HttpNetFrameworkTests.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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#if NETFRAMEWORK
using IntegrationTests.Helpers;
using Xunit.Abstractions;
namespace IntegrationTests;
public class HttpNetFrameworkTests : TestHelper
{
public HttpNetFrameworkTests(ITestOutputHelper output)
: base("Http.NetFramework", output)
{
}
[Fact]
[Trait("Category", "EndToEnd")]
public void SubmitTraces()
{
using var collector = new MockSpansCollector(Output);
SetExporter(collector);
collector.Expect("OpenTelemetry.Instrumentation.Http.HttpWebRequest");
RunTestApplication();
collector.AssertExpectations();
}
[Fact]
public void SubmitTracesCapturesHttpHeaders()
{
using var collector = new MockSpansCollector(Output);
SetExporter(collector);
collector.Expect("OpenTelemetry.Instrumentation.Http.HttpWebRequest", span =>
{
return span.Attributes.Any(x => x.Key == "http.request.header.custom-request-test-header1" && x.Value.StringValue == "Test-Value1")
&& span.Attributes.Any(x => x.Key == "http.request.header.custom-request-test-header3" && x.Value.StringValue == "Test-Value3")
&& span.Attributes.All(x => x.Key != "http.request.header.custom-request-test-header2")
&& span.Attributes.Any(x => x.Key == "http.response.header.custom-response-test-header2" && x.Value.StringValue == "Test-Value2")
&& span.Attributes.All(x => x.Key != "http.response.header.custom-response-test-header1")
&& span.Attributes.All(x => x.Key != "http.response.header.custom-response-test-header3");
});
SetEnvironmentVariable("OTEL_DOTNET_AUTO_TRACES_HTTP_INSTRUMENTATION_CAPTURE_REQUEST_HEADERS", "Custom-Request-Test-Header1,Custom-Request-Test-Header3");
SetEnvironmentVariable("OTEL_DOTNET_AUTO_TRACES_HTTP_INSTRUMENTATION_CAPTURE_RESPONSE_HEADERS", "Custom-Response-Test-Header2");
RunTestApplication();
collector.AssertExpectations();
}
}
#endif