Skip to content

Commit

Permalink
add public type for HTTPTransportProxyFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
MickaelAlliel committed Mar 6, 2024
1 parent 4b8fd69 commit a1320f5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions exporters/otlp/otlptrace/otlptracehttp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package otlptracehttp // import "go.opentelemetry.io/otel/exporters/otlp/otlptra

import (
"crypto/tls"
"net/http"
"net/url"
"time"

"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig"
Expand All @@ -15,6 +17,11 @@ import (
// collector.
type Compression otlpconfig.Compression

// HTTPTransportProxyFunc is a function that resolves which URL to use as proxy for a given request.
// This type is compatible with http.Transport.Proxy and can be used to set a custom proxy function
// to the OTLP HTTP client.
type HTTPTransportProxyFunc func(*http.Request) (*url.URL, error)

const (
// NoCompression tells the driver to send payloads without
// compression.
Expand Down Expand Up @@ -136,6 +143,6 @@ func WithRetry(rc RetryConfig) Option {
// WithProxy sets the Proxy function the client will use to determine the
// proxy to use for an HTTP request. If this option is not used, the client
// will use [http.ProxyFromEnvironment].
func WithProxy(pf otlpconfig.HTTPTransportProxyFunc) Option {
return wrappedOption{otlpconfig.WithProxy(pf)}
func WithProxy(pf HTTPTransportProxyFunc) Option {
return wrappedOption{otlpconfig.WithProxy(otlpconfig.HTTPTransportProxyFunc(pf))}
}

0 comments on commit a1320f5

Please sign in to comment.