Copilot commented on code in PR #3028:
URL: https://github.com/apache/dubbo-go/pull/3028#discussion_r2357243603
##########
otel/trace/otlp/exporter.go:
##########
@@ -57,7 +57,18 @@ func newHttpExporter(config *trace.ExporterConfig)
(trace.Exporter, error) {
if httpInstance == nil {
initHttpOnce.Do(func() {
customFunc := func() (sdktrace.SpanExporter, error) {
- client :=
otlptracehttp.NewClient(otlptracehttp.WithEndpoint(config.Endpoint))
+ var client otlptrace.Client
+ if config.Insecure {
+ client = otlptracehttp.NewClient(
+
otlptracehttp.WithEndpoint(config.Endpoint),
+ otlptracehttp.WithInsecure(),
+ )
+ } else {
+ client = otlptracehttp.NewClient(
+
otlptracehttp.WithEndpoint(config.Endpoint),
+ )
+ }
Review Comment:
The code duplicates the endpoint configuration in both branches. Consider
refactoring to reduce duplication by creating the options slice first and
conditionally appending the insecure option.
```suggestion
opts := []otlptracehttp.Option{
otlptracehttp.WithEndpoint(config.Endpoint),
}
if config.Insecure {
opts = append(opts,
otlptracehttp.WithInsecure())
}
client = otlptracehttp.NewClient(opts...)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]