public void GetTraceExportClient_UnsupportedProtocol_Throws() { var options = new OtlpExporterOptions { Protocol = (OtlpExportProtocol)123, }; Assert.Throws <NotSupportedException>(() => options.GetTraceExportClient()); }
public void GetTraceExportClient_SupportedProtocol_ReturnsCorrectExportClient(OtlpExportProtocol protocol, Type expectedExportClientType) { var options = new OtlpExporterOptions { Protocol = protocol, }; var exportClient = options.GetTraceExportClient(); Assert.Equal(expectedExportClientType, exportClient.GetType()); }
public void GetTraceExportClient_SupportedProtocol_ReturnsCorrectExportClient(OtlpExportProtocol protocol, Type expectedExportClientType) { if (protocol == OtlpExportProtocol.Grpc && Environment.Version.Major == 3) { // Adding the OtlpExporter creates a GrpcChannel. // 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); } var options = new OtlpExporterOptions { Protocol = protocol, }; var exportClient = options.GetTraceExportClient(); Assert.Equal(expectedExportClientType, exportClient.GetType()); }
public void GetTraceExportClient_GetClientForGrpcWithoutUnencryptedFlag_ThrowsException() { // Adding the OtlpExporter creates a GrpcChannel. // 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", false); var options = new OtlpExporterOptions { Protocol = OtlpExportProtocol.Grpc, }; var exception = Record.Exception(() => options.GetTraceExportClient()); if (Environment.Version.Major == 3) { Assert.NotNull(exception); Assert.IsType <InvalidOperationException>(exception); } else { Assert.Null(exception); } }