Tracing: chore make insecure option configurable (#99236)

* Tracing: chore: make insecure option configurable

In case of insecure set to false, default system cert pool will be used to create otlpgrpc client.

* test: add tracing/insecure config checks

This is to verify whether insecure configuration is properly parsed.

* chore: update configura Grafana docs with new setting

* chore: also update comment in the ini files

---------

Co-authored-by: Matheus Macabu <macabu.matheus@gmail.com>
This commit is contained in:
Emre Yazıcı
2025-03-27 17:37:23 +01:00
committed by GitHub
parent 38c96c4c7d
commit 7aa71aa734
6 changed files with 40 additions and 1 deletions

View File

@ -25,6 +25,7 @@ import (
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
trace "go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"
"google.golang.org/grpc/credentials"
"github.com/go-kit/log/level"
@ -167,7 +168,14 @@ func (ots *TracingService) initJaegerTracerProvider() (*tracesdk.TracerProvider,
}
func (ots *TracingService) initOTLPTracerProvider() (*tracesdk.TracerProvider, error) {
client := otlptracegrpc.NewClient(otlptracegrpc.WithEndpoint(ots.cfg.Address), otlptracegrpc.WithInsecure())
opts := []otlptracegrpc.Option{otlptracegrpc.WithEndpoint(ots.cfg.Address)}
if ots.cfg.Insecure {
opts = append(opts, otlptracegrpc.WithInsecure())
} else {
opts = append(opts, otlptracegrpc.WithTLSCredentials(credentials.NewTLS(nil)))
}
client := otlptracegrpc.NewClient(opts...)
exp, err := otlptrace.New(context.Background(), client)
if err != nil {
return nil, err