Repository navigation
Add proxy support with Basic authentication to OTLP exporters - #9064
Draft
cleverchuk wants to merge 2 commits into
Draft
cleverchuk wants to merge 2 commits into
cleverchuk wants to merge 2 commits into
Conversation
- ProxyOptions: optional Basic credentials (create(address, username, password)), noProxy(), credentials redacted from toString(). - OkHttp senders: install a proxy authenticator that answers proxy challenges (including OkHttp's preemptive CONNECT challenge) with Basic credentials, sent only to the proxy. - JDK HTTP sender: proxy credentials support. - gRPC exporters: setProxy(ProxyOptions) on the OTLP span, metric, log and profiles gRPC exporter builders, wired through GrpcSenderConfig. - Plaintext gRPC (http:// endpoints) through an HTTP proxy on all supported OkHttp versions: OkHttp 4.x does not CONNECT-tunnel HTTP/2 prior-knowledge connections, so OkHttpGrpcSender establishes the tunnel itself (GrpcH2cConnectTunnelSocketFactory) and lets the proxy resolve the target hostname. - Declarative config: proxy/development (url, username, password) on otlp_http and otlp_grpc exporters. Schema pinned to open-telemetry/opentelemetry-configuration#807 and the OTLP exporter models regenerated (ExperimentalProxyModel and accessors). - Tests: TestHttpProxy (CONNECT-only proxy with optional Basic auth), proxy tunnel tests for gRPC and HTTP exporters on OkHttp 4 and 5, GrpcH2cConnectTunnelSocketFactory, ProxyOptions and proxy/development parsing. - Update apidiffs.
Regenerating models from the pinned opentelemetry-configuration commit also picks up upstream schema changes unrelated to proxy support: max_export_batch_size on the periodic metric reader graduated from max_export_batch_size/development to a stable property. - PeriodicMetricReaderModel: stable maxExportBatchSize property; the /development key is still read via the graduation fallback. - MetricReaderFactory and MetricReaderFactoryTest use the stable getter/setter. - Remove PeriodicMetricReaderModelAccessor, left behind by the generator now that the property is stable. - ExperimentalResourceDetectionModel: detectors Javadoc updated from the schema.
Contributor
|
Pull request dashboard statusWaiting on the author · refreshed 2026-11-26 05:36 UTC Move out of draft to request review. Status above doesn't look right?
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements open-telemetry/opentelemetry-configuration#807
TL;DR
ProxyOptionsgains optional Basic credentials and an explicitnoProxy().setProxy(ProxyOptions), including plaintext (http://) endpoints,which are tunnelled through the proxy with
CONNECTon every supported OkHttp version.proxy/development(url,username,password) onotlp_httpandotlp_grpcexporters.(schema pinned to that commit).
Changes
ProxyOptionscreate(InetSocketAddress, String username, String password)— HTTP proxy at the address, withBasic authentication to the proxy.
noProxy()— always connect directly, ignoring ambient JVM proxy configuration(
http(s).proxyHost,ProxySelector.getDefault()). Differs from leaving proxy options unset,which keeps the sender's default behavior.
getUsername()/getPassword(); the password is never included intoString().GrpcSenderConfig#getProxyOptions()(defaultnull) so gRPC sender providers receive proxyoptions.
HTTP senders
OkHttp's preemptive challenge for
CONNECTtunnels. It only answers407s from the proxy (neverserver challenges) and gives up after one rejection instead of retrying forever.
Authenticatorthat supplies credentials forRequestorType.PROXYonly. The JDKHttpClientdisables Basic forCONNECTtunnels by default(
jdk.http.auth.tunneling.disabledSchemes), so authenticated proxies forhttpsendpoints needthat property overridden; this is documented in the sender, not worked around.
gRPC exporters
setProxy(ProxyOptions)on the OTLP span, metric, log and profiles gRPC exporter builders, wiredthrough
GrpcSenderConfigto the OkHttp gRPC sender.httpsendpoints: OkHttp's nativeCONNECTtunnelling plus the proxy authenticator above.httpendpoints (h2c prior knowledge): OkHttp 5 tunnelsH2_PRIOR_KNOWLEDGEthrough HTTP proxies, but OkHttp 4.x only tunnels TLS and would send HTTP/2 frames straight to
the proxy. To behave the same on both, when the selector picks an HTTP proxy for an
httpendpoint the sender configures OkHttp with
Proxy.NO_PROXYand a socket factory that establishesthe tunnel itself:
CONNECT host:port(IPv6 literals bracketed) with a preemptiveProxy-Authorizationheader when credentials are set;accepts only
2xx, closes the socket on failure;the proxy's network); falls back to a direct connection if the selector stops returning an
HTTP proxy.
Declarative configuration
proxy/developmentonotlp_httpandotlp_grpcexporters:proxy/developmentis absent, exporters created from declarative config useProxyOptions.noProxy(), i.e. they no longer pick up ambient JVM proxy settings.are regenerated (
ExperimentalProxyModelplus accessors). Revert to a release tag once Array values for span attributes #807 ships.API compatibility
ProxyOptionsmethods,GrpcSenderConfig#getProxyOptions()(default method), and
setProxyon the three stable OTLP gRPC exporter builders.setProxyon the span builder,setProxyOptionsonthe log and metric builders).
Testing
TestHttpProxy: a minimalCONNECT-only test proxy with optional Basic auth that records themethod, target and
Proxy-Authorizationof each request; non-CONNECTrequests get405.httpsand plaintexthttpendpoints, with and withoutBasic auth, on OkHttp 5 and OkHttp 4.11 (skipped for the
ManagedChannel-based senders).CONNECTtunnel to anhttpsendpoint (OkHttp; skipped for the JDKsender, see above) and rejection on wrong credentials.
407, malformed andoversized responses, direct fallback) and
proxy/developmentparsing (value retained, no"unknown property" warning).
local collector and TLS gRPC to a remote collector.