elixir: add ClientSignals.Plug for recording signals on request spans#3
Merged
Conversation
Reads the Fly-Client-* headers this package produces off incoming requests and attaches them as fly.client.* attributes on the current OTel span, so services consuming this package's headers (flaps, ui-ex, sprites-api) can share one implementation instead of each vendoring their own copy. :plug and :opentelemetry_api are added as optional deps so the core signal-detection API stays dependency-free for CLI consumers; the new module is only compiled when both are loaded.
There was a problem hiding this comment.
Pull request overview
Adds an Elixir server-side ClientSignals.Plug to read incoming Fly-Client-* request headers and record them as fly.client.* OpenTelemetry span attributes, consolidating logic previously duplicated across Phoenix services.
Changes:
- Introduces
ClientSignals.Plugfor extracting/trimming/truncating header values and attaching them to the current OTel span. - Adds ExUnit coverage for header parsing behavior and plug
call/2behavior. - Adds optional Elixir deps (
:plug,:opentelemetry_api), updates docs/agent guidance, and adjusts CI to fetch deps before running tests.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| elixir/lib/client_signals/plug.ex | New Plug implementation to read Fly-Client-* headers and set fly.client.* OTel attributes (compile fix needed). |
| elixir/test/client_signals/plug_test.exs | New tests covering header extraction, trimming, truncation, and call/2 behavior. |
| elixir/mix.exs | Adds optional deps for Plug + OpenTelemetry API. |
| elixir/mix.lock | New lockfile capturing the optional dependency versions used for tests/dev. |
| elixir/README.md | Documents how to use ClientSignals.Plug in a Plug/Phoenix pipeline. |
| elixir/AGENTS.md | Documents the deliberate narrow exception for optional deps to support ClientSignals.Plug. |
| .github/workflows/checks.yml | Ensures Elixir CI fetches deps prior to running tests. |
| .gitignore | Ignores deps/ directories (covers Elixir deps/). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
ClientSignals.Plug, a server-side counterpart to the existing header-generation API: it reads theFly-Client-*headers this package produces off incoming requests and attaches them asfly.client.*attributes on the current OTel span.Details
elixir/lib/client_signals/plug.ex—ClientSignals.Plug. Only headers actually present are recorded; unparseable booleans are ignored; string values are trimmed and truncated to 256 chars since headers are caller-controlled.:plugand:opentelemetry_apiare added toelixir/mix.exsasoptional: truedeps, and the whole module is wrapped inif Code.ensure_loaded?(Plug.Conn) and Code.ensure_loaded?(OpenTelemetry.Tracer) do ... end— this keeps the core signal-detection API dependency-free for CLI consumers that never touch Plug, while letting Phoenix-style consumers that already depend on both use the plug. Documented as a deliberate, narrow exception inelixir/AGENTS.md..github/workflows/checks.ymlnow runsmix deps.getbeforemix testfor the elixir job, since the package has real (optional) deps for the first time.elixir/deps/is gitignored.