Conversation
There was a problem hiding this comment.
Pull request overview
Adds OpenTelemetry tracing to correlate a device’s proxy assignment with its first observed proxy connection, enabling connectivity success-rate and time-to-connect analysis in SigNoz.
Changes:
- Emit a
device_id.connectedspan when CLIENTINFO is received on routed TCP/packet connections. - Add OTLP/HTTP trace exporter initialization alongside existing metrics exporter initialization.
- Wire clientcontext manager into the run path by default and add a local ping script / Makefile flag plumbing.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
tracker/clientcontext/manager.go |
Emits device_id.connected span with client attributes on successful CLIENTINFO parsing. |
otel/otel.go |
Adds InitGlobalTracerProvider using OTLP/HTTP exporter and SDK tracer provider. |
cmd/main.go |
Initializes global meter + tracer providers during CLI pre-run when proxy info is available. |
cmd/cmd_run.go |
Always registers the clientcontext manager (previously conditional) to enable tracing. |
cmd/Makefile |
Passes --telemetry-endpoint through make run. |
scripts/ping.sh |
Adds a script intended to exercise CLIENTINFO and produce the new span. |
go.mod / go.sum |
Adds OTLP trace HTTP exporter dependencies. |
.gitignore |
Ignores cmd/cmd. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # which triggers the device_id.connected span in telemetry. | ||
|
|
||
| set -e | ||
|
|
||
| HOST="${1:-127.0.0.1}" | ||
| PORT="${2:-8888}" | ||
|
|
||
| echo "Connecting to $HOST:$PORT..." | ||
|
|
||
| ( | ||
| echo -e "CONNECT example.com:443 HTTP/1.1\r\nHost: example.com:443\r\n\r" | ||
| sleep 0.5 | ||
| echo -n 'CLIENTINFO {"DeviceID":"test-device","Platform":"linux","IsPro":false,"CountryCode":"US","Version":"1.0.0"}' | ||
| sleep 0.5 | ||
| ) | nc -w 2 "$HOST" "$PORT" | head -1 | ||
|
|
There was a problem hiding this comment.
This script won’t trigger the CLIENTINFO handling / device_id.connected span as written: the server-side Manager expects the first bytes on the connection to start with the CLIENTINFO prefix. Sending an HTTP CONNECT request first means the Manager will treat the connection as non-CLIENTINFO and the later CLIENTINFO ... bytes will just be forwarded as normal payload. Also, the CONNECT request line terminator looks incomplete (\r\n\r instead of \r\n\r\n). Consider sending the CLIENTINFO {...} packet first and reading the OK response (or otherwise matching the actual injector protocol) so this is a reliable test.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
purpose
Provide mechanism for recording a
device_id's first connection to a route to provide an indication of poor network conditions.mechanism
Emit a span with
device_id(and some attrs) when a proxy is assigned by the API during config request. Then also emit a span (here, this code) when adevice_idfirst connects to a proxy.In SigNoz, we can calculate (using some kinda gnarly ClickHouse queries as discussed in https://github.com/getlantern/engineering/issues/2987):