Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

otlp.ExporterOption WithInsecure should take a boolean parameter. #1344

Closed
seanschade opened this issue Nov 16, 2020 · 3 comments
Closed

otlp.ExporterOption WithInsecure should take a boolean parameter. #1344

seanschade opened this issue Nov 16, 2020 · 3 comments
Labels
help wanted Extra attention is needed pkg:exporter:otlp Related to the OTLP exporter package

Comments

@seanschade
Copy link
Contributor

seanschade commented Nov 16, 2020

func WithInsecure() ExporterOption {

The current design makes it harder to map this option to configuration. You need to check if the value was set, and then add the WithInsecure option. All of the other options take a parameter for the value. This is nice because you can just pass the value into the option.

https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/protocol/exporter.md#configuration-options

If I define the configuration parameter using the default outlined in specification then I can't easily map this value to an ExporterOption.

// Whether to enable client transport security for the exporter's grpc or http connection.
Insecure bool `env:"OTEL_EXPORTER_OTLP_INSECURE,default=false"`

Current:

func (e *ExporterConfiguration) Insecure() otlp.ExporterOption {
	if e.OTLP.Insecure {
		return otlp.WithInsecure()
	}
	return nil
}

Proposed:

func (e *ExporterConfiguration) Insecure() otlp.ExporterOption {
	return otlp.WithInsecure(e.OTLP.Insecure)
}

The code change is minor, but it would be a breaking change.

// WithInsecure disables client transport security for the exporter's gRPC connection
// just like grpc.WithInsecure() https://pkg.go.dev/google.golang.org/grpc#WithInsecure
// does. Note, by default, client security is required unless WithInsecure is used.
func WithInsecure(insecure bool) ExporterOption {
	return func(cfg *config) {
		cfg.canDialInsecure = insecure
	}
}
@seanschade seanschade changed the title WithInsecure should take a boolean parameter. otlp.ExporterOption WithInsecure should take a boolean parameter. Nov 16, 2020
@seanschade
Copy link
Contributor Author

I realize that this option just mirrors the grpc.WithInsecure() option, but it also suffers from the same problem IMO.

https://pkg.go.dev/google.golang.org/grpc#WithInsecure

@Aneurysm9
Copy link
Member

I'm definitely on board with ensuring options are easily managed through configuration and niladic options to set flags don't really fit well in that model. I wonder whether the consonance with the grpc.WithInsecure() option is enough to leave that interface as it is and perhaps add an additional interface. I could see something like this working:

func WithTLSVerify(verify bool) ExporterOption {
  return func(cfg *config) {
    cfg.canDialInsecure = !verify
  }
}

func WithInsecure() ExporterOption {
  return WithTLSVerify(false)
}

@MrAlias MrAlias added this to To do in OpenTelemetry Go RC via automation Nov 19, 2020
@MrAlias MrAlias added this to the RC1 milestone Nov 19, 2020
@MrAlias MrAlias removed this from the RC1 milestone Feb 16, 2021
@punya punya removed this from To do in OpenTelemetry Go RC Feb 17, 2021
@MrAlias MrAlias added pkg:exporter:otlp Related to the OTLP exporter package and removed pkg:exporter labels Apr 6, 2021
@MrAlias MrAlias added the help wanted Extra attention is needed label May 3, 2022
@pellared pellared reopened this Apr 12, 2024
@pellared
Copy link
Member

The OTLP exporters are already stable.

I am against adding more exported options until it is necessary.

This can be solved by something like

var opts []otlp.ExporterOption
if insecure {
  opts = append(opts, grpc.WithInsecure())
}

@MrAlias MrAlias closed this as not planned Won't fix, can't repro, duplicate, stale Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed pkg:exporter:otlp Related to the OTLP exporter package
Projects
None yet
Development

No branches or pull requests

5 participants