mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-28 18:06:34 +02:00
* update tracing config definitions * new tracing system * performance improvements * only configure tracing in envoy if it is enabled in pomerium * [tracing] refactor to use custom extension for trace id editing (#5420) refactor to use custom extension for trace id editing * set default tracing sample rate to 1.0 * fix proxy service http middleware * improve some existing auth related traces * test fixes * bump envoyproxy/go-control-plane * code cleanup * test fixes * Fix missing spans for well-known endpoints * import extension apis from pomerium/envoy-custom
44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package config
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/pomerium/pomerium/internal/telemetry/trace"
|
|
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
|
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
|
|
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
|
|
)
|
|
|
|
var ErrNoTracingConfig = errors.New("no tracing config")
|
|
|
|
func NewTraceClientFromOptions(opts *Options) (otlptrace.Client, error) {
|
|
switch opts.TracingProvider {
|
|
case "otlp":
|
|
endpoint := opts.TracingOTLPEndpoint
|
|
protocol := opts.TracingOTLPProtocol
|
|
if protocol == "" && endpoint != "" {
|
|
// treat this field as equivalent to OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
|
|
protocol = trace.BestEffortProtocolFromOTLPEndpoint(opts.TracingOTLPEndpoint, true)
|
|
}
|
|
switch strings.ToLower(strings.TrimSpace(protocol)) {
|
|
case "grpc":
|
|
return otlptracegrpc.NewClient(
|
|
otlptracegrpc.WithEndpointURL(endpoint),
|
|
), nil
|
|
case "http/protobuf", "":
|
|
return otlptracehttp.NewClient(
|
|
otlptracehttp.WithEndpointURL(endpoint),
|
|
), nil
|
|
default:
|
|
return nil, fmt.Errorf(`unknown otlp trace exporter protocol %q, expected "grpc" or "http/protobuf"\n`, protocol)
|
|
}
|
|
case "none", "noop":
|
|
return trace.NoopClient{}, nil
|
|
case "":
|
|
return nil, ErrNoTracingConfig
|
|
default:
|
|
return nil, fmt.Errorf(`unknown tracing provider %q, expected one of ["otlp"]`, opts.TracingProvider)
|
|
}
|
|
}
|