Skip to content

Commit

Permalink
INFOPLAT-1560 Allows AuthHeaderProvider to be used instead of stati…
Browse files Browse the repository at this point in the history
…c `AuthHeaders`

Need this for migration of existing usage - current users of beholder can still use never verions while using static headers, but can make the switch across to setting `AuthHeaderProvider`
  • Loading branch information
hendoxc committed Dec 13, 2024
1 parent 42d052b commit 2ed4940
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions pkg/beholder/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
sdkresource "go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
oteltrace "go.opentelemetry.io/otel/trace"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)
Expand Down Expand Up @@ -92,7 +93,11 @@ func newGRPCClient(cfg Config, otlploggrpcNew otlploggrpcFactory) (*Client, erro
opts := []otlploggrpc.Option{
otlploggrpc.WithTLSCredentials(creds),
otlploggrpc.WithEndpoint(cfg.OtelExporterGRPCEndpoint),
otlploggrpc.WithHeaders(cfg.AuthHeaders),
}
if cfg.AuthHeaderProvider != nil {
opts = append(opts, otlploggrpc.WithDialOption(grpc.WithPerRPCCredentials(cfg.AuthHeaderProvider.Credentials())))
} else {
opts = append(opts, otlploggrpc.WithHeaders(cfg.AuthHeaders))
}
if cfg.LogRetryConfig != nil {
// NOTE: By default, the retry is enabled in the OTel SDK
Expand Down Expand Up @@ -305,7 +310,11 @@ func newTracerProvider(config Config, resource *sdkresource.Resource, creds cred
exporterOpts := []otlptracegrpc.Option{
otlptracegrpc.WithTLSCredentials(creds),
otlptracegrpc.WithEndpoint(config.OtelExporterGRPCEndpoint),
otlptracegrpc.WithHeaders(config.AuthHeaders),
}
if config.AuthHeaderProvider != nil {
exporterOpts = append(exporterOpts, otlptracegrpc.WithDialOption(grpc.WithPerRPCCredentials(config.AuthHeaderProvider.Credentials())))
} else {
exporterOpts = append(exporterOpts, otlptracegrpc.WithHeaders(config.AuthHeaders))
}
if config.TraceRetryConfig != nil {
// NOTE: By default, the retry is enabled in the OTel SDK
Expand Down Expand Up @@ -345,7 +354,11 @@ func newMeterProvider(config Config, resource *sdkresource.Resource, creds crede
opts := []otlpmetricgrpc.Option{
otlpmetricgrpc.WithTLSCredentials(creds),
otlpmetricgrpc.WithEndpoint(config.OtelExporterGRPCEndpoint),
otlpmetricgrpc.WithHeaders(config.AuthHeaders),
}
if config.AuthHeaderProvider != nil {
opts = append(opts, otlpmetricgrpc.WithDialOption(grpc.WithPerRPCCredentials(config.AuthHeaderProvider.Credentials())))
} else {
opts = append(opts, otlpmetricgrpc.WithHeaders(config.AuthHeaders))
}
if config.MetricRetryConfig != nil {
// NOTE: By default, the retry is enabled in the OTel SDK
Expand Down

0 comments on commit 2ed4940

Please sign in to comment.