Skip to content

Commit

Permalink
different environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
golangisfun123 committed Sep 5, 2024
1 parent 829812b commit e831fe9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions core/metrics/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (n *otlpHandler) Start(ctx context.Context) (err error) {
transportFromString(
core.GetEnv(otlpTransportEnv, otlpTransportGRPC.String()),
),
core.GetEnv(otlpTransportEnv, "localhost:4317"),
)
if err != nil {
return fmt.Errorf("could not create client: %w", err)
Expand All @@ -42,6 +43,7 @@ func (n *otlpHandler) Start(ctx context.Context) (err error) {
transportFromString(
core.GetEnv(otlpTransportEnvSecondary, otlpTransportGRPC.String()),
),
core.GetEnv(otlpTransportEnvSecondary, "localhost:4317"),
)
if err != nil {
return fmt.Errorf("could not create secondary client: %w", err)

Check warning on line 49 in core/metrics/otlp.go

View check run for this annotation

Codecov / codecov/patch

core/metrics/otlp.go#L49

Added line #L49 was not covered by tests
Expand Down Expand Up @@ -113,7 +115,7 @@ func handleShutdown(ctx context.Context, provider *tracesdk.TracerProvider) {
}

const (
otlpTransportEnv = "OTEL_EXPORTER_OTLP_TRANSPORT"
otlpTransportEnv = "OTEL_EXPORTER_OTLP_TRANSPORT_PRIMARY"
otlpTransportEnvSecondary = "OTEL_EXPORTER_OTLP_TRANSPORT_SECONDARY"
)

Expand All @@ -125,12 +127,12 @@ const (
otlpTransportGRPC // grpc
)

func buildClientFromTransport(transport otlpTransportType) (otlptrace.Client, error) {
func buildClientFromTransport(transport otlpTransportType, url string) (otlptrace.Client, error) {
switch transport {
case otlpTransportHTTP:
return otlptracehttp.NewClient(), nil
return otlptracehttp.NewClient(otlptracehttp.WithEndpointURL(url)), nil

Check warning on line 133 in core/metrics/otlp.go

View check run for this annotation

Codecov / codecov/patch

core/metrics/otlp.go#L132-L133

Added lines #L132 - L133 were not covered by tests
case otlpTransportGRPC:
return otlptracegrpc.NewClient(), nil
return otlptracegrpc.NewClient(otlptracegrpc.WithEndpointURL(url)), nil
default:
return nil, fmt.Errorf("unknown transport type: %s", transport.String())

Check warning on line 137 in core/metrics/otlp.go

View check run for this annotation

Codecov / codecov/patch

core/metrics/otlp.go#L136-L137

Added lines #L136 - L137 were not covered by tests
}
Expand Down

0 comments on commit e831fe9

Please sign in to comment.