Skip to content

Commit

Permalink
OtlpExporter: Enable support for both http and https - no tests (#1804)
Browse files Browse the repository at this point in the history
Enable support for both http and https endpoint in OTLP Exporter
  • Loading branch information
alanwest authored Feb 8, 2021
1 parent 044ba3e commit d485768
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Add back support for secure gRPC connections over https.
([#1804](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1804))

## 1.0.0-rc3

Released 2021-Feb-04
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,25 @@ internal OtlpTraceExporter(OtlpExporterOptions options, OtlpCollector.TraceServi
}
else
{
if (options.Endpoint.Scheme == Uri.UriSchemeHttps)
if (options.Endpoint.Scheme != Uri.UriSchemeHttp && options.Endpoint.Scheme != Uri.UriSchemeHttps)
{
throw new NotSupportedException("Https Endpoint is not supported.");
throw new NotSupportedException($"Endpoint URI scheme ({options.Endpoint.Scheme}) is not supported. Currently only \"http\" and \"https\" are supported.");
}

#if NETSTANDARD2_1
this.channel = GrpcChannel.ForAddress(options.Endpoint);
#else
this.channel = new Channel(options.Endpoint.Authority, ChannelCredentials.Insecure);
ChannelCredentials channelCredentials;
if (options.Endpoint.Scheme == Uri.UriSchemeHttps)
{
channelCredentials = new SslCredentials();
}
else
{
channelCredentials = ChannelCredentials.Insecure;
}

this.channel = new Channel(options.Endpoint.Authority, channelCredentials);
#endif
this.traceClient = new OtlpCollector.TraceService.TraceServiceClient(this.channel);
}
Expand Down

0 comments on commit d485768

Please sign in to comment.