Repository navigation
Allow configuring the gRPC export channel - #156
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
adriangb
approved these changes
Sep 24, 2026
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.
Adds
AdvancedOptions::with_grpc_channel, which lets the caller build thetonicchannel for gRPC exports from theEndpointthat the SDK prepares. Before this change, the SDK always calledEndpoint::connect_lazy(), so no transport option could be set.Why
A gRPC exporter keeps one HTTP/2 connection open, and an export that times out does not close it. If the collector host stops responding without closing the connection, every later export on that connection times out too. The connection only closes when the kernel stops retransmitting, which takes about 15 minutes with the Linux defaults. For that time, the exporter drops every batch.
Two settings fix this, and neither was reachable before:
TCP_USER_TIMEOUTcloses a connection whose sent data stays unacknowledged.tonichas no option for it, so it needs a custom connector.Endpoint::connect_timeoutbounds a reconnect to an address that does not answer.TCP_USER_TIMEOUTdoes not apply while a connection is being opened.A hook covers both, and every other
Endpointoption, without one SDK method per option:Change
AdvancedOptions::with_grpc_channel(impl Fn(Endpoint) -> Channel), available with theexport-grpcfeature. TheEndpointhas the export URL and, forhttps, TLS configured. The SDK callsbuildonce for each of the span, log and metric exporters, inside the export runtime.ExportOptionscarries the hook to the exporters. The publicspan_exporter,metric_exporterandlog_exporterfunctions keep their signatures.connect_lazy()as before.This puts
tonictypes in the public API behindexport-grpc. Thetonicversion already followsopentelemetry-otlp, which is part of each breakinglogfirerelease.HTTP exports are unchanged. They use HTTP/1.1, where an export that times out closes its connection.
Validation
cargo clippy --workspace --all-features -- -D warningspasses.cargo check --workspace --no-default-featurespasses with no export feature, with each export feature, and with all of them.cargo docwith-D warnings --cfg docsrspasses.