tracing/otlp: implement use-tls flag
@@ -10,6 +10,7 @@ import (
type OTLP struct {
Address string `long:"otlp-address" description:"otlp address to send traces to"`
Headers map[string]string `long:"otlp-header" description:"headers to attach to each tracing message"`
+ UseTLS bool `long:"otlp-use-tls" description:"whether to use tls or not"`
}
// IsConfigured identifies if an Address has been set
@@ -19,13 +20,16 @@ func (s OTLP) IsConfigured() bool {
// Exporter returns a SpanExporter to sync spans to OTLP
func (s OTLP) Exporter() (export.SpanSyncer, error) {
- secureOption := otlp.WithTLSCredentials(credentials.NewClientTLSFromCert(nil, ""))
-
- exporter, err := otlp.NewExporter(
- secureOption,
+ options := []otlp.ExporterOption{
otlp.WithAddress(s.Address),
otlp.WithHeaders(s.Headers),
- )
+ }
+
+ if s.UseTLS {
+ options = append(options, otlp.WithTLSCredentials(credentials.NewClientTLSFromCert(nil, "")))
+ }
+
+ exporter, err := otlp.NewExporter(options...)
if err != nil {
return nil, err
