jzelinskie / cobrautil

A collection of utility functions when using Cobra.
https://github.com/jzelinskie/cobrautil
Apache License 2.0
5 stars 10 forks source link

introduce flag for insecure communication #14

Closed vroldanbet closed 2 years ago

vroldanbet commented 2 years ago

closes https://github.com/jzelinskie/cobrautil/issues/13

this is particularly useful in development environments so that folks don't have to setup TLS in their collector

jzelinskie commented 2 years ago

Let's double check there isn't a way to do this with environment variables first.

vroldanbet commented 2 years ago

Closing - you can achieve this by using OTELs OTEL_EXPORTER_OTLP_ENDPOINT env var like http://localhost:4318. Otel library calls WithInsecure if http is set.

https://github.com/open-telemetry/opentelemetry-go/blob/main/exporters/otlp/otlptrace/internal/otlpconfig/envconfig.go#L97-L104

vroldanbet commented 2 years ago

@jzelinskie I've reopened this. Even though it's possible to enable insecure communication via OTEL environment variables, it's not immediately obvious to users of applications using cobrautil. For example SpiceDB offers --help flag with all options, including those related to OTEL provided by cobrautil. It would be a better UX - we cannot expect folks to go and check the opentelemetry go library source code to figure out they can achieve it with OTEL_EXPORTER_OTLP_ENDPOINT.

Until it's decided to deprecate cobrautil/otel flags in favour of OTEL's native envs, we should provide a cohesive interface in cobrautil.

jzelinskie commented 2 years ago

I think that's reasonable, is there an equivalent for Jaeger though? Because the cobrautil flag is not tied to a particular provider, ideally it can also trigger the behavior for Jaeger.

vroldanbet commented 2 years ago

@jzelinskie

I think that's reasonable, is there an equivalent for Jaeger though? Because the cobrautil flag is not tied to a particular provider, ideally it can also trigger the behavior for Jaeger.

in Jaeger the endpoint must have the protocol as prefix, so it's defined through that. Nothing in the API showed the equivalent, but I can dig a bit more

EDIT: I couldn't wind any equivalent in the otel Jaeger exporter. It would seem to be delegated to the http.Client, which figures out based on the endpoint URL