Skip to content

elixir: add ClientSignals.Plug for recording signals on request spans#3

Merged
dangra merged 1 commit into
mainfrom
dgrana/elixir-plug
Jul 8, 2026
Merged

elixir: add ClientSignals.Plug for recording signals on request spans#3
dangra merged 1 commit into
mainfrom
dgrana/elixir-plug

Conversation

@dangra

@dangra dangra commented Jul 8, 2026

Copy link
Copy Markdown
Member

Adds ClientSignals.Plug, a server-side counterpart to the existing header-generation API: it reads the Fly-Client-* headers this package produces off incoming requests and attaches them as fly.client.* attributes on the current OTel span.

Details

  • elixir/lib/client_signals/plug.exClientSignals.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.
  • :plug and :opentelemetry_api are added to elixir/mix.exs as optional: true deps, and the whole module is wrapped in if 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 in elixir/AGENTS.md.
  • .github/workflows/checks.yml now runs mix deps.get before mix test for the elixir job, since the package has real (optional) deps for the first time. elixir/deps/ is gitignored.
  • These values are self-reported by the caller and are only ever attached to spans for observability; they must never be used for gating, enforcement, or any per-request trust decision.

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.
Copilot AI review requested due to automatic review settings July 8, 2026 20:48
@dangra dangra merged commit 71a7194 into main Jul 8, 2026
8 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Plug for extracting/trimming/truncating header values and attaching them to the current OTel span.
  • Adds ExUnit coverage for header parsing behavior and plug call/2 behavior.
  • 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.

Comment thread elixir/lib/client_signals/plug.ex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants