Add HTTP protocol test case to OTLP exporter integration tests (#2692)
This commit is contained in:
parent
2c9501fcd5
commit
f5b0ea3826
|
|
@ -86,7 +86,7 @@ namespace Examples.AspNetCore
|
|||
break;
|
||||
case "otlp":
|
||||
// Adding the OtlpExporter creates a GrpcChannel.
|
||||
// This switch must be set before creating a GrpcChannel/HttpClient when calling an insecure gRPC service.
|
||||
// This switch must be set before creating a GrpcChannel when calling an insecure gRPC service.
|
||||
// See: https://docs.microsoft.com/aspnet/core/grpc/troubleshoot#call-insecure-grpc-services-with-net-core-client
|
||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace Examples.Console
|
|||
*/
|
||||
|
||||
// Adding the OtlpExporter creates a GrpcChannel.
|
||||
// This switch must be set before creating a GrpcChannel/HttpClient when calling an insecure gRPC service.
|
||||
// This switch must be set before creating a GrpcChannel when calling an insecure gRPC service.
|
||||
// See: https://docs.microsoft.com/aspnet/core/grpc/troubleshoot#call-insecure-grpc-services-with-net-core-client
|
||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ namespace Examples.Console
|
|||
*/
|
||||
|
||||
// Adding the OtlpExporter creates a GrpcChannel.
|
||||
// This switch must be set before creating a GrpcChannel/HttpClient when calling an insecure gRPC service.
|
||||
// This switch must be set before creating a GrpcChannel when calling an insecure gRPC service.
|
||||
// See: https://docs.microsoft.com/aspnet/core/grpc/troubleshoot#call-insecure-grpc-services-with-net-core-client
|
||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ namespace Examples.Console
|
|||
private static object RunWithActivitySource(string endpoint, string protocol)
|
||||
{
|
||||
// Adding the OtlpExporter creates a GrpcChannel.
|
||||
// This switch must be set before creating a GrpcChannel/HttpClient when calling an insecure gRPC service.
|
||||
// This switch must be set before creating a GrpcChannel when calling an insecure gRPC service.
|
||||
// See: https://docs.microsoft.com/aspnet/core/grpc/troubleshoot#call-insecure-grpc-services-with-net-core-client
|
||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,23 +24,29 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests
|
|||
{
|
||||
public class IntegrationTests
|
||||
{
|
||||
private const string CollectorEndpointEnvVarName = "OTEL_EXPORTER_OTLP_ENDPOINT";
|
||||
private static readonly string CollectorEndpoint = SkipUnlessEnvVarFoundFactAttribute.GetEnvironmentVariable(CollectorEndpointEnvVarName);
|
||||
private const string CollectorHostnameEnvVarName = "OTEL_COLLECTOR_HOSTNAME";
|
||||
private static readonly string CollectorHostname = SkipUnlessEnvVarFoundTheoryAttribute.GetEnvironmentVariable(CollectorHostnameEnvVarName);
|
||||
|
||||
[InlineData(OtlpExportProtocol.Grpc, ":4317")]
|
||||
[InlineData(OtlpExportProtocol.HttpProtobuf, ":4318/v1/traces")]
|
||||
[Trait("CategoryName", "CollectorIntegrationTests")]
|
||||
[SkipUnlessEnvVarFoundFact(CollectorEndpointEnvVarName)]
|
||||
public void ExportResultIsSuccess()
|
||||
[SkipUnlessEnvVarFoundTheory(CollectorHostnameEnvVarName)]
|
||||
public void ExportResultIsSuccess(OtlpExportProtocol protocol, string endpoint)
|
||||
{
|
||||
#if NETCOREAPP3_1
|
||||
// Adding the OtlpExporter creates a GrpcChannel.
|
||||
// This switch must be set before creating a GrpcChannel/HttpClient when calling an insecure gRPC service.
|
||||
// This switch must be set before creating a GrpcChannel when calling an insecure HTTP/2 endpoint.
|
||||
// See: https://docs.microsoft.com/aspnet/core/grpc/troubleshoot#call-insecure-grpc-services-with-net-core-client
|
||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
|
||||
if (protocol == OtlpExportProtocol.Grpc)
|
||||
{
|
||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
|
||||
}
|
||||
#endif
|
||||
|
||||
var exporterOptions = new OtlpExporterOptions
|
||||
{
|
||||
Endpoint = new System.Uri($"http://{CollectorEndpoint}"),
|
||||
Endpoint = new System.Uri($"http://{CollectorHostname}{endpoint}"),
|
||||
Protocol = protocol,
|
||||
};
|
||||
|
||||
var otlpExporter = new OtlpTraceExporter(exporterOptions);
|
||||
|
|
@ -56,7 +62,7 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests
|
|||
using var tracerProvider = builder.Build();
|
||||
|
||||
var source = new ActivitySource(activitySourceName);
|
||||
var activity = source.StartActivity("Test Activity");
|
||||
var activity = source.StartActivity($"{protocol} Test Activity");
|
||||
activity?.Stop();
|
||||
|
||||
Assert.Single(delegatingExporter.ExportResults);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\DelegatingTestExporter.cs" Link="Includes\DelegatingTestExporter.cs" />
|
||||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\EventSourceTestHelper.cs" Link="Includes\EventSourceTestHelper.cs" />
|
||||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\SkipUnlessEnvVarFoundFactAttribute.cs" Link="Includes\SkipUnlessEnvVarFoundFactAttribute.cs" />
|
||||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\SkipUnlessEnvVarFoundTheoryAttribute.cs" Link="Includes\SkipUnlessEnvVarFoundTheoryAttribute.cs" />
|
||||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\TestActivityProcessor.cs" Link="Includes\TestActivityProcessor.cs" />
|
||||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\TestEventListener.cs" Link="Includes\TestEventListener.cs" />
|
||||
<Compile Include="$(RepoRoot)\test\OpenTelemetry.Tests\Shared\Utils.cs" Link="Includes\Utils.cs" />
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ receivers:
|
|||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
endpoint: 0.0.0.0:4317
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
|
||||
exporters:
|
||||
logging:
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ services:
|
|||
command: --config=/cfg/config.yaml
|
||||
ports:
|
||||
- "4317:4317"
|
||||
- "4318:4318"
|
||||
|
||||
tests:
|
||||
build:
|
||||
|
|
@ -19,6 +20,6 @@ services:
|
|||
dockerfile: ./test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/Dockerfile
|
||||
command: --TestCaseFilter:CategoryName=CollectorIntegrationTests
|
||||
environment:
|
||||
- OTEL_EXPORTER_OTLP_ENDPOINT=otel-collector:4317
|
||||
- OTEL_COLLECTOR_HOSTNAME=otel-collector
|
||||
depends_on:
|
||||
- otel-collector
|
||||
|
|
|
|||
Loading…
Reference in New Issue