-
Notifications
You must be signed in to change notification settings - Fork 68
Add support for OTLP/HTTP Receiver #1765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 12 commits
0ceaea7
496718c
d3e0f50
f3f98de
10b0373
6557831
9a52222
260e6ae
f50e392
1e8519f
71e70ce
88562fa
f35c574
ba15f59
854245f
6d7bc30
5a1c10a
54a592b
3fc39fe
c08ee6e
3ef6cc9
d9c1fdf
704a7b7
a74680b
e7f02e2
cc09b34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| settings: | ||
| default_pipeline_ctrl_msg_channel_size: 100 | ||
| default_node_ctrl_msg_channel_size: 100 | ||
| default_pdata_channel_size: 100 | ||
|
|
||
| nodes: | ||
| receiver: | ||
| kind: receiver | ||
| plugin_urn: "urn:otel:otlp:receiver" | ||
| out_ports: | ||
| out_port: | ||
| destinations: | ||
| - exporter | ||
| dispatch_strategy: round_robin | ||
| config: | ||
| # OTLP/gRPC receiver (default port: 4317) | ||
| listening_addr: "127.0.0.1:4317" | ||
|
|
||
| # OTLP/HTTP receiver (default port: 4318) | ||
| http: | ||
| listening_addr: "127.0.0.1:4318" | ||
| # wait_for_result: false | ||
| # max_concurrent_requests: 0 | ||
| # max_request_body_size: "4MiB" | ||
| # accept_compressed_requests: true | ||
|
|
||
| # timeout: "30s" # Optional: timeout for gRPC requests | ||
|
|
||
| # TLS / mTLS (receiver-side; gRPC only today) | ||
| # tls: | ||
| # cert_file: "/path/to/server.crt" # or `cert_pem: | ...` | ||
| # key_file: "/path/to/server.key" # or `key_pem: | ...` | ||
| # client_ca_file: "/path/to/client-ca.crt" # or `client_ca_pem: | ...` | ||
| # include_system_ca_certs_pool: false | ||
| # handshake_timeout: "10s" | ||
| # reload_interval: "5m" | ||
|
|
||
| exporter: | ||
| kind: exporter | ||
| plugin_urn: "urn:otel:otlp:exporter" | ||
| config: | ||
| # Downstream OTLP/gRPC collector endpoint. | ||
| # Uses a different port than this receiver to avoid accidental loops. | ||
| grpc_endpoint: "http://127.0.0.1:4319" | ||
| # timeout: "15s" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,12 +14,12 @@ | |
| //! | ||
| //! The implementation uses HTTP CONNECT method to establish tunnels through proxies. | ||
|
|
||
| use crate::socket_options; | ||
| use base64::Engine; | ||
| use base64::prelude::*; | ||
| use http::Uri; | ||
| use ipnet::IpNet; | ||
| use serde::Deserialize; | ||
| use socket2::{Socket, TcpKeepalive}; | ||
| use std::borrow::Cow; | ||
| use std::env; | ||
| use std::io; | ||
|
|
@@ -575,52 +575,20 @@ async fn http_connect_tunnel_on_stream( | |
| } | ||
|
|
||
| /// Applies TCP socket options (nodelay, keepalive) to a stream. | ||
| /// | ||
| /// This function performs a series of conversions (tokio -> std -> socket2 -> std -> tokio) | ||
| /// to apply socket options that are not directly exposed by tokio's TcpStream. | ||
| /// Specifically, `socket2` is required to set detailed keepalive parameters (interval, retries). | ||
| fn apply_socket_options( | ||
| stream: TcpStream, | ||
| tcp_nodelay: bool, | ||
| tcp_keepalive: Option<Duration>, | ||
| tcp_keepalive_interval: Option<Duration>, | ||
| tcp_keepalive_retries: Option<u32>, | ||
| ) -> io::Result<TcpStream> { | ||
| // Convert tokio TcpStream to std TcpStream, then to Socket | ||
| stream.set_nodelay(tcp_nodelay)?; | ||
|
|
||
| let std_stream = stream.into_std()?; | ||
| let socket: Socket = std_stream.into(); | ||
|
|
||
| // Apply TCP keepalive settings | ||
| if let Some(keepalive_time) = tcp_keepalive { | ||
| let mut keepalive = TcpKeepalive::new().with_time(keepalive_time); | ||
|
|
||
| if let Some(interval) = tcp_keepalive_interval { | ||
| keepalive = keepalive.with_interval(interval); | ||
| } | ||
|
|
||
| #[cfg(not(target_os = "windows"))] | ||
| if let Some(retries) = tcp_keepalive_retries { | ||
| keepalive = keepalive.with_retries(retries); | ||
| } | ||
|
|
||
| #[cfg(target_os = "windows")] | ||
| if tcp_keepalive_retries.is_some() { | ||
| otap_df_telemetry::otel_warn!( | ||
| "Proxy.KeepaliveRetriesIgnored", | ||
| platform = "windows", | ||
| message = "tcp_keepalive_retries is configured but ignored on Windows: TcpKeepalive::with_retries is not available on this platform" | ||
| ); | ||
| } | ||
|
|
||
| socket.set_tcp_keepalive(&keepalive)?; | ||
| } | ||
|
|
||
| // Convert back to std TcpStream, then to tokio TcpStream | ||
| let std_stream: std::net::TcpStream = socket.into(); | ||
| std_stream.set_nonblocking(true)?; | ||
| TcpStream::from_std(std_stream) | ||
| socket_options::apply_socket_options( | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. socket tuning is now centralized in socket_options.rs because both the proxy and the OTLP/HTTP server need the same keepalive/nodelay configuration (tokio -> std -> socket2 -> std -> tokio dance). This keeps the settings consistent across listeners and avoids duplicating the conversion code. |
||
| stream, | ||
| tcp_nodelay, | ||
| tcp_keepalive, | ||
| tcp_keepalive_interval, | ||
| tcp_keepalive_retries, | ||
| ) | ||
| } | ||
|
|
||
| /// Establishes a TCP connection to a target, optionally through an HTTP CONNECT proxy. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactor just moved the AckSlot construction out of ServerCommon::new into the receiver so HTTP and gRPC can share the same slot pool when HTTP wait-for-result is enabled.